成功安装Varnish后,PHPmyadmin不能在文档根目录上工作

上周我安装了Varnish,我的网站现在可以正常工作 – 我可以无误地导航和更改它们。 当我安装它的时候,我把Varnish放在80端口上,把Apache移到8080端口。

我后来注意到,如果我在我的浏览器中运行以下,我不能访问phpmyadmin

MY_IP:80 / phpmyadmin MY_IP:8080 / phpmyadmin

但是,如果我移动phpmyadmin说/ var / www / html / site_dir / phpmyadmin我确实可以访问它没有问题通过domain.tld / phpmyadmin

但是这里有一些奇怪的东西,现在看来,没有任何一个IP_ADDRESS可以工作,甚至没有在浏览器中工作的网站:

MY_IP / domain.tld MY_IP / domain.tld / phpmyadmin MY_IP:8080 / domain.tld / phpmyadmin

我的问题是,为什么我不能从任何浏览器访问除了Apache index.html页面之外的IP地址的服务器?


我安装光油的方式是这样的:

cd ~ apt-get update && apt-get install varnish -y sed -i 's/Listen 80/Listen 8080/g' /etc/apache2/ports.conf sed -i 's/\*\:80/\*\:8080/g' /etc/apache2/sites-available/000-default.conf sed -i 's/\*\:80/\*\:8080/g' /etc/apache2/sites-available/domain.tld.conf && domain.tld.conf mkdir -p /etc/systemd/system/varnish.service.d # Be aware! You might not need this in the future. cat <<-'VARNISH' > /etc/systemd/system/varnish.service.d/customexec.conf [Service] ExecStart= ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m VARNISH systemctl restart apache2.service && systemctl daemon-reload && systemctl restart varnish.service 

这是(相对)正常的行为。

您的Apacheconfiguration已configuration为从您的域中提供/var/www/html/site_dir 。 这意味着,当您从您的域中ping您的网站时,您实际上不能访问不在此目录中的任何内容。 如果您想从域名访问PHPmyAdmin,则必须将其移至site_dir ,或者将您的webroot更改为/var/www/html并移动所有其他文件。

或者,您可以使用自己的域名为PHPmyAdmin创build一个新的virthost,如下所示:

 <VirtualHost pma.example.com:8080> ServerName pma.example.com ServerAdmin [email protected] DocumentRoot /var/www/html/phpmyadmin/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined [ anything else ... ] </VirtualHost> 

至于为什么你不能通过你的IP地址访问任何东西,这是因为你的域的virthost被configuration成你的域名。 当Apache无法匹配你的任何virthost时,它会回000_default ,它没有设置ServerName并监听所有的事情 。 如果您希望始终访问您的网站(通过IP或其他方式),则需要按照000_defaultconfiguration(或重新configuration000_default并禁用您的定制virthost)的方式来configuration当前的virthost。 或者,创build一个与您的IP相匹配的新virthost。

如果你想把你的IP地址作为一个“后门”来pipe理PHPmyAdmin和其他所有存储在/var/www/html ,你可以通过确保DocumentRoot/var/www/html来设置它。 但是,请注意,这将带来一个小的安全威胁,特别是如果您从您的网站托pipe多个域名。