Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I installed the ubuntu 12.04 server edition for my server pc . i had installed lamp server. i need to change the var/www location to my secondary hard disk location. i was configured so many time to at gedit /etc/apache2/sites-available/default here is my code

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    #DocumentRoot /var/www
    DocumentRoot /media/myserver/
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    #<Directory /var/www/>
        <Directory /media/myserver/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

and also used

sudo chown -R var/www /media/myserver/

and

chmod -R 755 /media/myserver/

still i was not able to connect my /media/myserver and my browser show the following message

Forbidden

You don't have permission to access / on this server.

Please tell anyone how to mount myserver at my var/www, thanks advance

share|improve this question
    
was the second drive formatted and mounted to the /media/myserver directory? did you add a fstab entry for that drive ? –  damien Jan 26 at 11:41
    
Have you checked whether the trailing slash on the document root is the problem, notice where its commented out there isnt one, but on your edit, there is. –  Chris Jul 23 at 23:03

2 Answers 2

Maybe a little bit late. But still..

You should edit your directory permissions in apache.conf under /etc/apache2

Search for this

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

and add this code under of it, which gives the permission to access your directory

 <Directory /media/myserver/>
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
    </Directory>
share|improve this answer

Simply change the document root in your activated configuration. /etc/apache2/sites-enabled/000-default and then Make sure reloading your apache.

So try with this:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /media/myserver/
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /media/myserver/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Then the proper permission should be given like this:

sudo adduser <username> www-data
sudo chown -R www-data:www-data /media/myserver/
sudo chmod -R g+rw /media/myserver/
share|improve this answer
    
yes my friend i was done this already . see the above code i was comment the default document root and inserted new document root. after apache2 stop and start. it's not worked. it's 403 error, and showed permission access denied and my browser –  tamil_arvu Aug 27 '13 at 16:49
    
Have you seen my last edite? –  Achu Aug 27 '13 at 20:07
    
yes i saw this. still it's show you dont have permission to access /on this server –  tamil_arvu Aug 28 '13 at 2:58

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.