I want to change the default location of Apache folder which is (var/www/html).
I am using the CentOS and apache 2 here. you can use following code with any linux box like fedora or redhat. Here we solved the issue of directory.
I am using the CentOS and apache 2 here. you can use following code with any linux box like fedora or redhat. Here we solved the issue of directory.
When I inserted the following code in bottom of the httpd.conf file.
<VirtualHost *:80>
Options +FollowSymLinks
ServerAdmin siwan@yahoo.co.in
DocumentRoot /opt/htdocs
ErrorLog logs/error_log_net
TransferLog logs/access_log_net
</VirtualHost>
<VirtualHost *:80>
Options +FollowSymLinks
ServerAdmin siwan@yahoo.co.in
DocumentRoot /opt/htdocs
ErrorLog logs/error_log_net
TransferLog logs/access_log_net
</VirtualHost>
When tried the http://localhost/ in browser, I got the default browser page.
Then I tried to look my apache error using following command:
#[root@localhost ]# tail -f /var/log/httpd/error_log
Then I tried to look my apache error using following command:
#[root@localhost ]# tail -f /var/log/httpd/error_log
In apache error log I got following error.
[Wed Oct 07 15:59:50 2008] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /opt/htdocs/
[Wed Oct 07 15:59:50 2008] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /opt/htdocs/
I changed the AllowOverride option but nothing is happend. Then I read the welcome page text
“To prevent this page from ever being used, follow the instructions in the file /etc/httpd/conf.d/welcome.conf.”
I opend the welcome.conf file.
“To prevent this page from ever being used, follow the instructions in the file /etc/httpd/conf.d/welcome.conf.”
I opend the welcome.conf file.
I found following lines in welcome.conf file.
<LocationMatch “^/+$”>
Options -Indexes
ErrorDocument 403 /error/noindex.html
LocationMatch>
<LocationMatch “^/+$”>
Options -Indexes
ErrorDocument 403 /error/noindex.html
LocationMatch>
I changed that to as follows:
<LocationMatch “^/+$”>
Options Indexes
ErrorDocument 403 /error/noindex.html
</LocationMatch>
Options Indexes
ErrorDocument 403 /error/noindex.html
</LocationMatch>
That solve my problem. Some time your selinux will cause the issue so you need to deactivate the selinux.
Some time File permission will also cause the issue.
You can change the file permission using following command, go to that directory and run following command.
#chmod 777 *
Some time File permission will also cause the issue.
You can change the file permission using following command, go to that directory and run following command.
#chmod 777 *
You can use above commands on any linux box. Ubuntu, centos, redhat or on fedora box.. still solution will be same.