我有一个网站,之前在本地部署时使用以下命令:sudo /etc/init.d/apache2 start
,然后在浏览器中输入URL:http://XXX/myfirstphpsite/src
。其中XXX是我的IP地址,myfirstphpsite/src是包含我的网站的目录。
然而,现在我想要在本地部署网站时输入如下URL:http://pharaohohparis.tld
。
为此,我进行了以下操作:
I went to the repertory:
/etc/apache2/sites-available/
and created a new file named:pharaohofparis.tld.conf
in which I inserted:<VirtualHost *:80> ServerName pharaohofparis.tld DocumentRoot /var/www/html/myfirstphpsite/src <Directory /var/www/html/myfirstphpsite/src> Options Indexes FollowSymLinks Includes AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
I actived the virtual host by typing:
使用以下命令:
sudo a2ensite pharaohofparis.tld.conf
sudo service apache2 reload
- 我编辑了文件
/etc/hosts
,并添加了以下行:
127.0.0.1 pharaohofparis.tld
然而,当我输入网址:http://pharaohofparis.tld
时,出现了DNS错误“DNS_PROBE_FINISHED_NXDOMAIN”。我该如何解决这个问题?
编辑:问题在于Linux子系统。在真正的Ubuntu上没有问题。
files
?你需要这样做才能检查本地主机文件以进行 DNS 解析。 - Nic3500nslookup http:///pharaohofparis.tld
,它应该返回您本地主机的IP地址。如果没有,请先解决这个问题。如果这并没有帮助,将LogLevel debug
放入您的httpd.conf文件中。在您的VirtualHost *:80中,添加一个新的error_log和一个新的CustomLog,这样您就可以在一般配置和特定的VirtualHost之间分离日志。然后再尝试一次。希望这些日志能帮助您。嘘,répertoire 在英语中是 "directory" :) - Nic3500nslookup
命令返回的是我的当前 IP 地址,而不是127.0.0.1
。我认为问题可能在于我正在使用 WSL(Linux 子系统),因此我的 Windows 操作系统正在使用另一种配置来部署网站。无论如何,我计划安装双启动并再次尝试。如果成功了,我会告诉你的。另外,抱歉回复晚了。Et merci pour l'info. :) - PharaohOfParis