我想创建一个Linux/Ubuntu本地环境。
我已经安装了Apache 2.4.7(使用apt-get)。
我已经更改了我的/etc/hosts文件为以下内容:
我还添加了一个名为"example.dev.conf"的文件到"/etc/apache2/sites-available"中,其内容如下:
但是当我访问example.dev时,出现以下消息:
我已经使用了a2ensite。但仍然不起作用。
我已经安装了Apache 2.4.7(使用apt-get)。
我已经更改了我的/etc/hosts文件为以下内容:
127.0.0.1 example.dev
127.0.0.1 localhost
...
我还添加了一个名为"example.dev.conf"的文件到"/etc/apache2/sites-available"中,其内容如下:
<VirtualHost *:80>
ServerName example.dev
DocumentRoot "/home/yahya/path/to/projec"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/home/yahya/path/to/project">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
但是当我访问example.dev时,出现以下消息:
我还根据此链接 Forbidden You don't have permission to access / on this server 和 Error message "Forbidden You don't have permission to access / on this server" 编辑了 apache.conf 中的403 禁止访问!您没有权限访问此服务器上的 / 目录。
<Directory />
部分。<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
到
<Directory />
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Require all granted
</Directory>
我已经使用了a2ensite。但仍然不起作用。
www-data
用户是否具有足够的权限在文件夹/home/yahya/path/to/projec
中列出文件? - Cheeryls -la
命令,检查www-data
是否具有访问权限。 参考http://askubuntu.com/questions/43485/how-to-show-current-permissions-of-a-folder 等。 在Linux中做任何事情之前,您必须至少了解权限基础知识。否则,您可能会损坏整个系统。 - Cheeryls -la /home/yahya/path/to/projec
列出/home/yahya/path/to/projec
的权限,你将会看到该文件夹的所有者。用户www-data
需要对此文件夹具备读取权限。 - daentech