Home > Linux > Changing Document Root under Apache w/ CentOS

Changing Document Root under Apache w/ CentOS

In my previous posting, I created a ftp user with a home directory of /var/www/html. Then, I applied the latest SELinux updates, and the arrangement crashed.

I know that there’s different ways in displaying content under Apache’s httpd.conf file, so I started out by using DocumentRoot for the time being. Once again… (As always, comments start with a ‘#’ and are BOLDed. Don’t type them in.)

# Add in a FTP account
useradd –g ftp wwwweb # Arbitrary username - use your own
passwd wwwweb # The wwwweb user belongs to the group "ftp".
# Enter your own password for the ftp account

Look to my previous posting about configuring the VSFTPD configuration file.

In addition to setting up SELinux for ftpd access (via setsebool), you’ll need to change the security context of wwwweb’s home directory to be httpd content by issuing this command:
chcon -R -h -t httpd_sys_content_t /home/wwwweb

# Set up Document Root to point somewhere else in Apache's configuration files.
cd /etc/httpd/conf
nano httpd.conf
# edit httpd.conf to reflect the following changes from /var/www/html to…
DocumentRoot “/home/wwwweb”
<Directory "/home/wwwweb">

Then issue the following commands at the command line:
service httpd restart
service httpd reload
service vsftpd restart

Viola! You should now be able to upload files to your ftp account, and have Apache serve files off that ftp account under CentOS v5.5.

Categories: Linux Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.