Apache 不能在 localhost 以外的网站上运行
Apache does not work on website other than localhost
VirtualHost 文件仅在 localhost 用户中有效,在任何 ip 中都无效,无论是 public,private 还是 self。这是放在 sites-enabled
文件夹中的 VirtualHost 文件内容:
<VirtualHost *:80>
ServerName localhost
ServerAdmin root@localhost
DocumentRoot /home/matecat/cattool
DirectoryIndex index.php index.php3 index.html index.htm index.shtml
<Directory /home/matecat/cattool/>
Options All
AllowOverride All
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
ExpiresActive On
ExpiresByType text/html "access plus 1 hour"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
ExpiresByType image/jpg "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType image/vnd.microsoft.icon "access plus 1 week"
ExpiresByType image/ico "access plus 1 week"
ExpiresByType application/x-shockwave-flash "access plus 1 week"
</Directory>
php_flag register_globals off
php_flag magic_quotes_gpc off
php_admin_flag short_open_tag on
php_value memory_limit 1024M
php_value upload_max_filesize 200M
php_value post_max_size 200M
LogLevel error
ErrorLog /var/log/apache2/matecat.error.log
CustomLog /var/log/apache2/matecat.log combined
ServerSignature Off
# Configuration for Nodejs proxy
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location /sse/ >
ProxyPass http://0.0.0.0:7788/
ProxyPassReverse http://0.0.0.0:7788/
</Location>
</VirtualHost>
我注释掉了以下几行:
Servername localhost
ServerAdmin root@localhost
但是重启apache服务器后使用系统的"IPv4"还是不行
如果您没有指定域,而是通过 IP 访问它,Apache 将使用它找到的第一个匹配的 VirtualHost,自上而下。
这里任意IP(*),端口80。所以如果默认配置VirtualHost没有被注释掉,Apache会使用这个默认配置。所以注释掉默认的,或者把你的移到默认的上面。但是无论如何没有人需要那个默认配置:-)
VirtualHost 文件仅在 localhost 用户中有效,在任何 ip 中都无效,无论是 public,private 还是 self。这是放在 sites-enabled
文件夹中的 VirtualHost 文件内容:
<VirtualHost *:80>
ServerName localhost
ServerAdmin root@localhost
DocumentRoot /home/matecat/cattool
DirectoryIndex index.php index.php3 index.html index.htm index.shtml
<Directory /home/matecat/cattool/>
Options All
AllowOverride All
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
ExpiresActive On
ExpiresByType text/html "access plus 1 hour"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
ExpiresByType image/jpg "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType image/vnd.microsoft.icon "access plus 1 week"
ExpiresByType image/ico "access plus 1 week"
ExpiresByType application/x-shockwave-flash "access plus 1 week"
</Directory>
php_flag register_globals off
php_flag magic_quotes_gpc off
php_admin_flag short_open_tag on
php_value memory_limit 1024M
php_value upload_max_filesize 200M
php_value post_max_size 200M
LogLevel error
ErrorLog /var/log/apache2/matecat.error.log
CustomLog /var/log/apache2/matecat.log combined
ServerSignature Off
# Configuration for Nodejs proxy
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location /sse/ >
ProxyPass http://0.0.0.0:7788/
ProxyPassReverse http://0.0.0.0:7788/
</Location>
</VirtualHost>
我注释掉了以下几行:
Servername localhost
ServerAdmin root@localhost
但是重启apache服务器后使用系统的"IPv4"还是不行
如果您没有指定域,而是通过 IP 访问它,Apache 将使用它找到的第一个匹配的 VirtualHost,自上而下。
这里任意IP(*),端口80。所以如果默认配置VirtualHost没有被注释掉,Apache会使用这个默认配置。所以注释掉默认的,或者把你的移到默认的上面。但是无论如何没有人需要那个默认配置:-)