我是虚拟主机新手。我已关注本教程创建虚拟主机来运行 php 项目。此外,我还使用了 symlink 方法这里。第一个教程中的步骤(如安装 apache、创建文件、授予权限、设置虚拟主机文件)似乎没问题。符号链接也已设置。但是当我转到链接时,我无法查看任何文件 - 因此我无法运行任何 php 脚本 - 以下是与此问题相关的数据:
/etc/hosts
127.0.0.1 localhost
#Virtual Hosts
127.0.1.2 larav.el // Domain I've used for...
...
/etc/apache2/sites-available/larav.el
<VirtualHost *:80>
ServerName larav.el
ServerAlias www.larav.el
DocumentRoot /var/www/larav.el/public_html
</VirtualHost>
➜ ~ ls -la /var/www/larav.el/public_html
lrwxrwxrwx 1 ekrem ekrem 52 May 27 01:32 /var/www/larav.el/public_html -> /home/ekrem/workspace/laravel-laravel-58d6b11/public
➜ ~ ls -la /home/ekrem/workspace/laravel-laravel-58d6b11/public
total 36
drwx------ 7 ekrem ekrem 4096 May 27 00:40 .
drwx------ 7 ekrem ekrem 4096 May 27 00:40 ..
drwx------ 2 ekrem ekrem 4096 May 27 00:40 bundles
drwx------ 2 ekrem ekrem 4096 May 27 00:40 css
-rw-rw-r-- 1 ekrem ekrem 0 May 22 04:05 favicon.ico
-rw-rw-r-- 1 ekrem ekrem 801 May 22 04:05 .htaccess
drwx------ 2 ekrem ekrem 4096 May 27 00:40 img
-rw-rw-r-- 1 ekrem ekrem 1156 May 22 04:05 index.php
drwx------ 2 ekrem ekrem 4096 May 27 00:40 js
drwx------ 5 ekrem ekrem 4096 May 27 00:40 laravel
➜ ~ ls -ld /home/ekrem/workspace/laravel-laravel-58d6b11/
drwx------ 7 ekrem ekrem 4096 May 27 00:40 /home/ekrem/workspace/laravel-laravel-58d6b11/
➜ ~ ls -ld /home/ekrem/workspace/
drwxrwxr-x 6 ekrem ekrem 4096 May 27 00:40 /home/ekrem/workspace/
➜ ~ ls -ld /home/ekrem/
drwxr-xr-x 47 ekrem ekrem 4096 May 27 02:51 /home/ekrem/
更新 /etc/apache2/sites-available/larav.el
default
-从 slibling文件复制粘贴,因此</Directory>
定义可能缺失或错误-
<VirtualHost *:80>
ServerName larav.el
ServerAlias www.larav.el
DocumentRoot /var/www/larav.el/public_html
<Directory /home/ekrem/workspace/laravel-laravel-58d6b11/public>
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/larav.el/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
➜ ~ tail -f /var/log/apache2/error.log
[Mon May 27 01:27:30 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.4.15-1~precise+1 configured -- resuming normal operations
[Mon May 27 01:32:15 2013] [notice] caught SIGTERM, shutting down
[Mon May 27 01:32:16 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.4.15-1~precise+1 configured -- resuming normal operations
[Mon May 27 01:32:55 2013] [error] [client 127.0.0.1] script '/var/www/larav.el/index.php' not found or unable to stat
[Mon May 27 01:34:30 2013] [notice] caught SIGTERM, shutting down
[Mon May 27 01:34:31 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.4.15-1~precise+1 configured -- resuming normal operations
[Mon May 27 01:39:18 2013] [notice] Graceful restart requested, doing restart
[Mon May 27 01:39:18 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.4.15-1~precise+1 configured -- resuming normal operations
[Mon May 27 02:58:51 2013] [notice] caught SIGTERM, shutting down
[Mon May 27 02:58:52 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.4.15-1~precise+1 configured -- resuming normal operations
非常感谢...
答案1
- 如果您的 Apache 不是以 ekrem 或 root 身份运行,那么您必须使子目录对于 Apache 用户可读且可执行。
- 还检查父目录的访问权限:
ls -ld /home/ekrem/ /home/ekrem/workspace/ /home/ekrem/workspace/laravel-laravel-58d6b11/
- 您需要一个
<directory>
定义,/home/ekrem/workspace/laravel-laravel-58d6b11/public
以便允许访问。 - 您还需要一个允许跟踪符号链接
<directory>
的定义。/var/www/larav.el/
编辑1:
您可以通过更改为 Apache 用户并尝试读取文件来检查您的(文件系统)访问权限:
# sudo -u wwwrun -s
wwwrun@server:/> less /var/www/larav.el/public_html/index.php