Hi All…
I need to change my default Apache Document root. So I modified the httpd.conf file and change document root /var/www/html to /home/username/web .
After that i run apachectl -t command for check configuration is correct or not then showing error.
Syntax error on line 308 of /etc/httpd/conf/httpd.conf:
DocumentRoot '/home/username/web' is not a directory, or is not readable
I can not restart the server because its live server. So kindly suggest me solution thanks.
Did you create this directory /home/username/web?
Also did you give it the right permissions (chmod - chown)?
Yes,I created directory /home/username/web and I given right permisson chmod -R 777 /home/username/web and chown -R username.username /home/username/web but showing same error.
@NITIN_SHRIVASTAV
I hope that username is changed to real username and it must exists on the system. Also make sure to assign correct permission as stated below:
# chown -R apache. /home/username/web
# chmod 755 /home/username/web
Also make sure that you relocate Apache DocumentRoot directory for SELinux (only applied if SELinux enabled) using:
# chcon -R -u system_u -t httpd_sys_content_t /home/username/web
@ravisaive
As per your post i changed permission and but error is same then i disabling enforcement use
setenforce 0
sestatus | grep -i mode
Current mode: permissive
Mode from config file: permissive
Now Apache is running fine but now i try to access files using browser http://ip_address
error:-
403
Forbidden
You don’t have permission to access / on this server.
permission of directory :-
drwxr-xr-x. 2 apache apache web
@NITIN_SHRIVASTAV
You must set SELinux rule to home directories to access over apache using below commands.
# setsebool -P httpd_enable_homedirs 1
# chcon -R -t httpd_sys_content_t /home/username/web
I have created a file named “test.html” and it resides at “/data/temp/test.html” location. Now i have changed the document root from /var/www/html to /data/temp/test.html. Now when i restart, it shows the following error:
[root@ind-mhp1v12lnx02 temp]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: Syntax error on line 292 of /etc/httpd/conf/httpd.conf:
DocumentRoot ‘/data/temp/test.html’ is not a directory, or is not readable
[FAILED]
Now when i go to apache web page using the server ip, i need to see the content in test.html. What should i do?