2
votes

I want to be able to install a Zend - based site on Amazon EC2 Linux instance. To be able to do that, I need to have the main directory name as "public" rather than "html" as is default for EC2.

How can I change the path to the site's default directory from /var/www/html/ to /var/www/public/ ?

Thank you in advance for your help!

1
I'd quite like to work this out as well - I had a poke around in /etc/httpd/conf/httpd.conf but it didn't seem to work as expected. - Oliver Tappin

1 Answers

2
votes

Oliver is on the right track. You need to do 2 things:

  1. Update the DocumentRoot statement within the httpd.conf file to your new home directory.
  2. Restart your web service for the change to take effect.

So for example, do the following command:

sudo vi /etc/httpd/conf/httpd.conf

Then look for the following line by typing /DocumentRoot + ENTER in the vi editor:

DocumentRoot "/var/www/"

Now just change the document root directory to whatever you want.(In the vi editor, move the cursor where you want it, press i to switch to insert mode, modify the code, then press ESC to get out of insert mode.) You can (and probably should) also change any <Directory statements that immediately follow, as these relax some access standards and shouldn't apply at a level above your web root. For example, you may see this:

#
# Relax access to content within /var/www.
#
<Directory "/var/www">

I recommend changing this to:

#
# Relax access to content within /var/www/html/drupal.
#
<Directory "/var/www/html/drupal">

Changing the comment is purely for consistency should anyone else review your code later. There are probably at least 2 statements that fit this pattern in the file, so look for and change them.

Save your changes when finished by typing :x and pressing ENTER.

Finally, a crucial step: restart your web service! This is a commonly overlooked step. The command will vary based on your server setup, but will probably be very close to:

sudo service mysqld restart

Check your website when finished to make sure it's going to the right default folder when you just use the domain name with no additional folders. Good luck!