Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am newbie in virtual host. I have followed this tutorial to create a virtual host to run php projects. Also, I've used symlink method described here. Steps in first tutorial like installing apache, creating files, granting permissions, setting virtual host files seems ok. Symlink is set up, too. But when I go to link, I could not view any file -so I couldn't run any php script- Here are data related with this issue:

/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/

UPDATED /etc/apache2/sites-available/larav.el -copy pasted from slibling default file, so </Directory> definitions may be missing or wrong-

    <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

Many many thanks...

share|improve this question
    
What is in the error log? –  Hauke Laging May 27 '13 at 0:10
    
@HaukeLaging log is added to question –  ekremkaraca May 27 '13 at 0:21
    
Strange. It says "'/var/www/larav.el/index.php' not found" in the log. I expected "'/var/www/larav.el/public_html/index.php' not found" instead. There seems to be a problem with the DocumentRoot definition but I don't know which. –  Hauke Laging May 27 '13 at 0:37

1 Answer 1

  1. If your Apache does not happen to run as ekrem or root then you have to make the subdirectories readable and executable for the Apache user.
  2. Check also the access rights of the parent directories: ls -ld /home/ekrem/ /home/ekrem/workspace/ /home/ekrem/workspace/laravel-laravel-58d6b11/
  3. You need a <directory> definition for /home/ekrem/workspace/laravel-laravel-58d6b11/public so that access is allowed there.
  4. You also need a <directory> definition for /var/www/larav.el/ which allows to follow symlinks.

Edit 1:

You can check your (file system) access rights by changing to the Apache user and trying to read the files then:

# sudo -u wwwrun -s
wwwrun@server:/> less /var/www/larav.el/public_html/index.php
share|improve this answer
    
question is updated but it's not solved. –  ekremkaraca May 27 '13 at 0:08
    
@ekremkrc I am not sure about the defaults thus better copy allow from all to the first <directory block. Your file system rights are too restrictive. And I can't find and info about the user as which Apache is running. –  Hauke Laging May 27 '13 at 0:15
    
sudo: unknown user: wwwrun; sudo: unable to initialize policy plugin error is displayed –  ekremkaraca May 27 '13 at 0:24
    
@ekremkrc I have mentioned ans asked for the user account which is used for Apache several times now. Unfortunately you don't care. wwwrun is just an example (of another distro). –  Hauke Laging May 27 '13 at 0:39
    
As I've declared that I'm newbie at this and related subjects in the question. –  ekremkaraca May 27 '13 at 0:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.