Linux Apache配置-您不需要';您没有访问/访问此服务器的权限吗?
如何告诉Apache将Linux Apache配置-您不需要';您没有访问/访问此服务器的权限吗?,linux,apache,ubuntu,apache2,Linux,Apache,Ubuntu,Apache2,如何告诉Apache将127.0.0.1指向一个特定的文件夹,如/var/www/projects/mysite1/ 我使用的是sudogedit/etc/apache2/apache2.conf,这是我的配置: <Directory /> Options FollowSymLinks AllowOverride all Require all denied </Directory> <Directory /usr/share>
127.0.0.1
指向一个特定的文件夹,如/var/www/projects/mysite1/
我使用的是sudogedit/etc/apache2/apache2.conf
,这是我的配置:
<Directory />
Options FollowSymLinks
AllowOverride all
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
选项如下符号链接
允许超越所有
要求全部拒绝
不允许超限
要求所有授权
选项索引跟随符号链接
允许超越所有
要求所有授权
因此,如果我将/var/www/
更改为/var/www/projects/mysite1/
,并尝试访问http://127.0.0.1/
重新启动服务器后,在我的浏览器上出现以下错误:
禁止的
您没有访问/访问此服务器的权限
Apache/2.4.7(Ubuntu)服务器127.0.0.1端口80
你知道我该怎么做吗?我认为实现这一目标的最佳方法是创建虚拟主机
/etc/apache2/sites available
中,创建一个mysite1.conf
文件。在这里,您应该具有以下配置:
<VirtualHost 127.0.0.1:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/projects/mysite1/
<Directory /var/www/projects/mysite1/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/mysite1_error.log
CustomLog ${APACHE_LOG_DIR}/mysite1_access.log combined
</VirtualHost>
sudo service apache2 reload
非常感谢你的回答!
sudo service apache2 reload