Recently on restarting my Apache Server on Ubuntu I came across following error
Forbidden You don't have permission to access /dir/ on this server
After a bit of google I solved this by granting permissions to my server directory and resetting my httpd.conf directory access levels as follows
Since I am working on Ubuntu I will be using Ubuntu locations your locations can very depending upon your linux distribution
In Ubuntu httpd.conf file is place under
/etc/apache2/sites-available directory
if you list directory contents you will find files like
000-default.conf 000-default.old example.com~
000-default.conf~ default-ssl.conf
Out of these first one is the httpd.conf file in concern(this is how Ubuntu stores it)
First make a copy of the same as you can see I have made a copy of the same 000-default.old using following command
sudo cp 000-default.conf 000-default.old
Now Alter the 000-default.conf as follows
Next grant permissions to your directory as
Forbidden You don't have permission to access /dir/ on this server
After a bit of google I solved this by granting permissions to my server directory and resetting my httpd.conf directory access levels as follows
Since I am working on Ubuntu I will be using Ubuntu locations your locations can very depending upon your linux distribution
In Ubuntu httpd.conf file is place under
/etc/apache2/sites-available directory
if you list directory contents you will find files like
000-default.conf 000-default.old example.com~
000-default.conf~ default-ssl.conf
Out of these first one is the httpd.conf file in concern(this is how Ubuntu stores it)
First make a copy of the same as you can see I have made a copy of the same 000-default.old using following command
sudo cp 000-default.conf 000-default.old
Now Alter the 000-default.conf as follows
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
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>
Next grant permissions to your directory as
sudo chown -R $USER:$USER /var/www
sudo chmod -R g+rw /var/www
You will now be able to access your localhost directory
No comments:
Post a Comment