Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've set up Fedora 14 with Apache, MySQL and PHP for my own homepage on a "server" (read: old hardware scrapped together).

I'm logged in with my user, but have no rights on /var/www/html.

How do I change this so that I can save my files to this folder? Maybe change the permissions or redirect the folder to my home folder?

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

The www folder is created by most distributions during the apache setup process. As the setup process is run by root, the www folder is owned by root. Use ls -al in /var to look at it's permissions.

drwxr-xr-x  5 root root  4096 May  2 11:34 www

chmod and chown are GNU coreutils that you can use to modify the permissions of unix directories.

Use chown to change the owner and group of /var/www/html/ to your user and group, e.g.

sudo chown -R jason:jason /var/www/html/

As you're likely to start putting PHP scripts in here, you'll then need to use chmod to make sure the apache user (in most cases www-data) is allowed to execute them.

Try and understand how Unix permissions work before proceeding any further as it will save you some time down the line. Good luck.

share|improve this answer
add comment

as root, run chown yourusername /var/www/html, this will assign it to your user. Alternatively, you could set up apache to use some directory inside your home directory as "DocumentRoot". (see /etc/apache, /etc/httpd or similar).

Most apaches are also set up to link your $HOME/public_html/ to http://server/~username.

Both approaches have some limitations in that you have to give far reaching permissions to the files, so you can edit them and the webserver can read them (and if you use php, edit them in some cases, should this be necessary). For this reason, it might be better to copy files to /var/www/html and assign them to the web server user.

share|improve this answer
add comment

It might be a better idea to create a separate user:group for the httpd service; apache:apache is already created during my httpd installation on my Fedora19 system.

Then, you can change the owner:group and other permissions to apache:apache, while adding your username to the group apache by executing gpasswd -a myUsername1 apache

If SELinux is installed, make sure you follow the guidelines and rules about working with the apache-server under a SELinux-configured system.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.