正在尝试使用 /var/www/html 以外的文件夹
Attempting to use folder other than /var/www/html
我正在为我的网络服务器运行 Ubuntu (+LAMP) 堆栈。网络服务器的一切似乎都运行良好。例如,我有 index.php 页面
<?php
phpinfo();
?>
在 /var/www/html 内,也在 /var/www/mytestsite.com/ 下
在网络服务器内部,@ http://MyServerIPAddress/hello.php
和 http://MyServerIPAddress/mytestsite.com/hello.php
两个站点都在显示正确的 phpinfo。
当我从服务器外部测试时,我只能访问内部页面 /var/www/html
http://MyServerIPAddress/hello.php
但是页面访问
http://MyServerIPAddress/mytestsite.com/hello.php
消息显示
Not Found
The requested URL /example.com was not found on this server.
Apache/2.4.7 (Ubuntu) Server at *MyServerIPAddress* Port 80.
这里是mytestsite.com.conf我用的是apache
<VirtualHost *:80>
ServerAdmin admin@mytestsite.com
ServerName mytestsite.com
ServerAlias www.mytestsite.com
DocumentRoot /var/www/mytestsite.com
</VirtualHost>
并且还将文件夹访问和所有者设置与 /var/www/html 和 /var/www/mytestsite.com
的匹配项相匹配
我需要什么额外配置才能访问 /var/www/html 文件夹外的站点?
在查看 apache 日志和其他人的帮助后,我找到了自己问题的答案
首先,我将网站的 apache conf 文件更改为
<VirtualHost *:80>
ServerAdmin admin@mytestsite.com
ServerName mytestsite.com
ServerName <ServerIpAddress>
DocumentRoot /var/www
<Directory /var/www/mytestsite.com/public_html**/>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我还对 /etc/hosts 文件进行了更改,以将站点包含为
<localhostIp> localhost
<localhostIp> ubuntu
<ServerIpAddress> mytestsite.com mytestsite.com
修改后,我可以从服务器外部访问站点
我正在为我的网络服务器运行 Ubuntu (+LAMP) 堆栈。网络服务器的一切似乎都运行良好。例如,我有 index.php 页面
<?php
phpinfo();
?>
在 /var/www/html 内,也在 /var/www/mytestsite.com/ 下
在网络服务器内部,@ http://MyServerIPAddress/hello.php
和 http://MyServerIPAddress/mytestsite.com/hello.php
两个站点都在显示正确的 phpinfo。
当我从服务器外部测试时,我只能访问内部页面 /var/www/html
http://MyServerIPAddress/hello.php
但是页面访问
http://MyServerIPAddress/mytestsite.com/hello.php
消息显示
Not Found
The requested URL /example.com was not found on this server.
Apache/2.4.7 (Ubuntu) Server at *MyServerIPAddress* Port 80.
这里是mytestsite.com.conf我用的是apache
<VirtualHost *:80>
ServerAdmin admin@mytestsite.com
ServerName mytestsite.com
ServerAlias www.mytestsite.com
DocumentRoot /var/www/mytestsite.com
</VirtualHost>
并且还将文件夹访问和所有者设置与 /var/www/html 和 /var/www/mytestsite.com
的匹配项相匹配我需要什么额外配置才能访问 /var/www/html 文件夹外的站点?
在查看 apache 日志和其他人的帮助后,我找到了自己问题的答案 首先,我将网站的 apache conf 文件更改为
<VirtualHost *:80>
ServerAdmin admin@mytestsite.com
ServerName mytestsite.com
ServerName <ServerIpAddress>
DocumentRoot /var/www
<Directory /var/www/mytestsite.com/public_html**/>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我还对 /etc/hosts 文件进行了更改,以将站点包含为
<localhostIp> localhost
<localhostIp> ubuntu
<ServerIpAddress> mytestsite.com mytestsite.com
修改后,我可以从服务器外部访问站点