网站的链接建设,免费软件如何盈利,专门做教育咨询有限公司网站,网站网页开发公司最近在练习搭建网站#xff0c;遇到游览器找不到服务器上的php文件的问题。后来查找发现#xff0c;apache文档根目录跟apache虚拟主机文档根目录不同#xff0c;服务器开启了虚拟主机功能。这导致游览器找不到php文件。使用的环境LAMP 里操作系统和软件版本如下#xff1a…最近在练习搭建网站遇到游览器找不到服务器上的php文件的问题。后来查找发现apache文档根目录跟apache虚拟主机文档根目录不同服务器开启了虚拟主机功能。这导致游览器找不到php文件。使用的环境LAMP 里操作系统和软件版本如下CentOS 7.8 64bitApache 2.4.46 MariaDB 10.5.9PHP 7.4.29 。
可以修过虚拟主机的文档根地址来处理这个问题。或者不开启虚拟主机功能。
注意事项/home/www/htdxxx只是目录名的一个示意名具体要根据计算机的实际来设置。
1、apache 的 httpd.conf 文件部分内容
1.1、apache文件根目录
DocumentRoot /home/www/htdxxx Directory /home/www/htdxxx Options FollowSymLinks AllowOverride All Require all granted /Directory
1.2、是否包含vhost.conf。这里设置了不包含该文件
# Virtual hosts# Include conf/extra/httpd-vhosts.conf
1.3、目录索引DirectoryIndex。index.html与index.php的位置影响网站的网页能否正常显示。
# DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # IfModule dir_module DirectoryIndex index.html index.php /IfModule
2、httpd-vhosts.conf文件部分内容
VirtualHost *:80 ServerAdmin webmasterdummy-host.example.com DocumentRoot /home/www/htdxxx/dummy-host.example.com ServerName dummy-host.example.com ServerAlias www.dummy-host.example.com ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common /VirtualHost
VirtualHost *:80 ...... # 备注省略了几行 /VirtualHost