标签: apache2

如何配置 apache 查看隐藏(`.`)文件?

如何使 apache 中的目录列表显示./hidden 文件?我都尝试过

    <Directory /var/www/*>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>
Run Code Online (Sandbox Code Playgroud)

和

    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>
Run Code Online (Sandbox Code Playgroud)

但都不显示隐藏文件

apache apache2 directory-listing apache-config

2
推荐指数
1
解决办法
6304
查看次数

从 cpan 安装 Perl CGI 模块时出错

cpan install CGI我在执行时得到以下结果Ubuntu 10.4。

Test Summary Report
-------------------
t/tmpdir.t             (Wstat: 0 Tests: 9 Failed: 0)
  TODO passed:   3, 6, 8
t/url.t                (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: No plan found in TAP output
Files=39, Tests=695,  2 wallclock secs ( 0.45 usr  0.11 sys +  1.19 cusr  0.21 csys =      1.96 CPU)
Result: FAIL
Failed 1/39 test programs. 0/695 subtests failed.
make: *** [test_dynamic] Error 255
  MARKSTOS/CGI.pm-3.55.tar.gz
  /usr/bin/make test -- NOT OK …
Run Code Online (Sandbox Code Playgroud)

perl cgi cpan apache2

2
推荐指数
1
解决办法
4652
查看次数

写入并发日志文件

我在 apache2 上有一个 WSGI 应用程序,它以最简单的方式写入日志文件:

def log (msg):
    with open (LOGFILE, 'a') as f: f.write (msg)
Run Code Online (Sandbox Code Playgroud)

在我的沙箱环境中它运行良好,但我有点担心并发性。如果apache2运行各种线程,我是否需要担心并发问题?我的日志文件可能会被扰乱吗?log (msg)如果另一个线程已经在记录日志,调用可能会失败吗?如果是这种情况,我该如何预防呢?

编辑: 为了测试,我从两个 shell 同时运行两个脚本:

#! /usr/bin/python3.2

def log ():
    with open ('log', 'a') as f:
        f.write ('message from thread A\n')

while (True): log ()
Run Code Online (Sandbox Code Playgroud)

和

#! /usr/bin/python3.2

def log ():
    with open ('log', 'a') as f:
        f.write ('message from thread B\n')

while (True): log ()
Run Code Online (Sandbox Code Playgroud)

日志文件看起来不错,没有发生错误。我很幸运,或者从两个不同的线程写入同一个文件是否安全。文件系统是ext4。

python logging wsgi apache2

2
推荐指数
1
解决办法
2120
查看次数

配置 Apache 以隐藏 .json 类型的文件

我在 apache 的 DocumentRoot 上有一些 .json 类型的文件。当公共查看者使用 URL 访问时,我需要隐藏或不允许向他们显示这些文件。http://somehostname/somefile.json,如何禁用不显示这些文件的选项。

webserver apache2 mime-types

2
推荐指数
1
解决办法
1952
查看次数

使用正则表达式阻止 .htaccess 中的 URL

我想阻止几个 URL(如果它们与 htaccess 文件中的正则表达式匹配)。

这些是我想在 htaccess 中阻止的 URL。

URL 模式中包含以下内容的任何内容:

  • mp4:
  • wp 内容
  • php我的管理员

全部不区分大小写,请注意“mp4:”必须包含冒号以匹配表达式。

我怎样才能做到这一点?

谢谢!

php regex apache .htaccess apache2

2
推荐指数
1
解决办法
4089
查看次数

Apache2 vHost conf - 重定向到不同的服务器

情况

服务器 1:Apache2 从端口 80 为常规网站提供服务

服务器 2:运行从端口 8080 提供服务的专用 JAVA 网站应用程序(应用程序默认)

使用异地 DNS 服务将我的域名的所有端口 80 请求定向到我的外部 IP。服务器 1 使用多个 vHost 配置文件指向 Apache2 html 文件夹,以便用户看到正确的网站。

问题

在不使用内部 DNS 服务器的情况下,通过服务器 1 Apache2 vHost 配置文件将 1 个域名定向到服务器 2。

这个例子

默认网站的服务器 1 vHost 配置文件:

<VirtualHost *:80>
ServerName www.mdom.com
ServerAlias www.mdom.com

DocumentRoot /var/www/html/public_html

<Directory /var/www/html/public_html>
    Options -Indexes
    AllowOverride All
    <IfModule mod_auth_core.c>
        Require all granted
    </IfModule>
</Directory>

CustomLog /var/log/apache2/www.mdom.com-access.log "Combined"
ErrorLog /var/log/apache2/www.mdom.com-error.log
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

用于定向到服务器 2 应用程序的服务器 1 虚拟主机配置文件:

<VirtualHost *:80>
ServerName app.mdom.com
ServerAlias app.mdom.com

DocumentRoot …
Run Code Online (Sandbox Code Playgroud)

port redirect apache2 virtualhost

2
推荐指数
1
解决办法
3784
查看次数

Django 未运行:ModuleNotFoundError:没有名为“encodings”的模块

我已经在新的 Ubuntu 17.10 服务器上安装了 django 网站。它基于python3。当我使用以下命令在开发模式下运行网站时效果很好

python manage.py runserver

但是当我尝试通过 apache2 网络服务器配置它时,port 80 通过编辑默认配置文件在 apache 中添加 wsgi ,如图所示。

<VirtualHost *:80>

    ServerAdmin webmaster@localhost

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /home/usr/mygpsproject/gps_restapi/gps_restapi>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess gps_restapi python-path=/home/usr/mygpsproject/gps_restapi/ python-home=/home/usr/mygpsproject/venv/bin/
    WSGIProcessGroup gps_restapi
    WSGIScriptAlias / /home/usr/mygpsproject/gps_restapi/gps_restapi/wsgi.py

</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

但网站无法正常工作。当我检查apache错误日志时发现这个错误......

[Sat Apr 14 16:16:09.201739 2018] [core:notice] [pid 5089:tid 140258267696064] AH00051: child pid 7500 exit signal Aborted (6), possible coredump in /etc/apache2
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: …
Run Code Online (Sandbox Code Playgroud)

django ubuntu mod-wsgi apache2 python-3.x

2
推荐指数
1
解决办法
4641
查看次数

具有 SSL 配置的 Apache 不适用于 Django 应用程序的 WSGI 配置

这是 github 上以下问题的后续:

https://github.com/certbot/certbot/issues/1820

和

https://github.com/certbot/certbot/issues/2546

Letsencrypt无法处理apache的WSGI配置

我正在使用以下配置运行 apache2

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used …
Run Code Online (Sandbox Code Playgroud)

django ssl apache2 lets-encrypt certbot

2
推荐指数
1
解决办法
2893
查看次数

phpmyadmin - php 7.4 中缺少 mbstring 扩展

php 版本:7.4.8 操作系统:ubuntu

当我尝试 localhost/phpmyadmin 时出现此错误

缺少 mbstring 扩展名。请检查您的 PHP 配置。

我已经安装了 mbstring

sudo apt-get install php-mbstring
Reading package lists... Done
Building dependency tree       
Reading state information... Done
php-mbstring is already the newest version (2:7.4+76+ubuntu18.04.1+deb.sury.org+9).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

sudo apt-get install php7.4-mbstring
Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    php-mbstring is already the newest version (2:7.4+76+ubuntu18.04.1+deb.sury.org+9).
    0 upgraded, 0 newly installed, 0 to remove and 0 not …
Run Code Online (Sandbox Code Playgroud)

php ubuntu apache2 php-7.4

2
推荐指数
1
解决办法
4754
查看次数

Apache2 通过添加标头来修改从 CIFS 挂载存储库下载的文件。文件已损坏

我的目录/var/www/html/(其中包含可以下载的文件)包含指向 CIFS 挂载文件系统 ( /mnt/netappIllumina/) 中包含的目录的软链接。

从该目录下载文件时,由于向其中添加了标头(见下文),文件会损坏。

 15:22:10 GMT
ETag: "1d-5af1f5d7cb0cc"
Accept-Ranges: bytes
Content-Length: 29
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive

Run Code Online (Sandbox Code Playgroud)

我真的不知道那里发生了什么以及如何抑制它。此后,我的 apache.conf 中一些可能有趣的行

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
        EnableSendfile Off
</Directory>
Run Code Online (Sandbox Code Playgroud)

我接受任何建议......我完全迷失了。我在那里发现了最近的类似问题,但没有人找到任何解决方案。

跑步 :

Server version: Apache/2.4.29 (Ubuntu)
Server built:   2020-08-12T21:33:25
Run Code Online (Sandbox Code Playgroud)

apache webserver cifs apache2

2
推荐指数
1
解决办法
284
查看次数