• Home
  • Downloads
  • Contact Us
  • Report Broken Link
Wednesday, May 14, 2025
  • Login
lessons4you.info
  • Videos
  • Downloads
  • Help
    • Contact Us
    • Report Broken Link
No Result
View All Result
  • Videos
  • Downloads
  • Help
    • Contact Us
    • Report Broken Link
No Result
View All Result
Lessons4you.info
No Result
View All Result

How to fix Apache – "httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName"

[SOLVED] Can't locate ExtUtils/Embed.pm - CentOS

Change Root Directory of Httpd – CentOS

by
December 11, 2021
in Uncategorized
Reading Time: 2 mins read
A A
Share on FacebookShare on Twitter

Why should I change my Root Directory?
If you want to protect your data, you should change your root directory. Create another partition for your home folder on the disk or use another drive and keep your web server root directory their. If your system get crashed, you can easily re-install the new OS without deleting or moving your web server root directory data because it is on another partition or disk. simplest method is create a symbolic link between /var/www/html folder and /home/www. But the best method is to change these setting in httpd configuration file.If you need to change the root directory of web server. The default root directory is at /var/www/html. In my case, I want to change it to /home/www.

Step-1: Edit apache/httpd configuration file (as root)

1
2
3
 
# vi /etc/httpd/conf/httpd.conf
 

Find these two sections:

1
2
3
4
5
6
7
8
 
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html"
 

1
2
3
4
5
6
 
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/var/www/html">
 

Then, change the directory location whatever you want:

1
2
3
4
5
6
7
8
 
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/home/www"
 

1
2
3
4
5
6
 
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/home/www">
 

Save and exit from vi editor.

Step-2: Changing Permission of web server root directory

1
2
3
 
# chmod -R 755 /home/www
 

At this point if you try to restart apache/httpd server, you may get this error:

1
2
3
4
5
6
7
 
# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd: Syntax error on line 294 of /etc/httpd/conf/httpd.conf:
DocumentRoot must be a directory
                                                           [FAILED]
 

This step is necessary since in CentOS, httpd process will be executed by user ‘apache’, thus permission need to be change.

1
2
3
4
 
# setsebool -P httpd_enable_homedirs 1
# chcon -R -t httpd_sys_content_t /home/www
 

Note: httpd by default is not allowed to access users home directories.

Step-3: Restart apache/httpd web server

1
2
3
 
# service httpd restart
 

Result:

1
2
3
4
5
 
# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
 

Tags: ApacheHTTPD
Previous Post

How to fix Apache – “httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName”

Next Post

[SOLVED] Can’t locate ExtUtils/Embed.pm – CentOS

Related Posts

How To Install The TWRP Recovery on Xiaomi Redmi 1s
Uncategorized

How To Install The TWRP Recovery on Xiaomi Redmi 1s

May 14, 2022
MIUI Collection Of Gapps (2.3.x – 5.0.x)
Uncategorized

MIUI Collection Of Gapps (2.3.x – 5.0.x)

May 14, 2022
Download Android 5.1.x Lollipop PA Gapps
Uncategorized

Download Android 5.1.x Lollipop PA Gapps

May 15, 2022
Download gapps for Android 5.1 Lollipop Cyanogemod 12.1
Uncategorized

Download gapps for Android 5.1 Lollipop Cyanogemod 12.1

May 14, 2022
Reddit AMA with OxygenOS Team OnePlus
Uncategorized

Reddit AMA with OxygenOS Team OnePlus

May 14, 2022
How to Remove Adobe Updater from OS X Menu Bar?
Uncategorized

How to Remove Adobe Updater from OS X Menu Bar?

July 19, 2023
Next Post

[SOLVED] Can't locate ExtUtils/Embed.pm - CentOS

  • Home
  • Downloads
  • Contact Us
  • Report Broken Link

© 2022 lessons4you.info

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
No Result
View All Result
  • Videos
  • Downloads
  • Help
    • Contact Us
    • Report Broken Link

© 2022 lessons4you.info