Ask Your Question
0

How to change LAMP localhost location?

asked 2013-05-24 13:56:53 -0600

3Joe3 gravatar image

I'm trying to edit files stored in /var/www/html.

The problem is that I need root privileges to edit those files. Should I change my localhost location? If so, how do I do that? Please help!

Thanks!

edit retag flag offensive close merge delete

Comments

I tried to change the localhost to /home/joe/www in the httpd.conf. It did not work but now... I am getting an "Forbidden" message when I try to open localhost files in a browser, even though I put EVERYTHING back the way it was! I broke it. What happend?

3Joe3 gravatar image3Joe3 ( 2013-05-24 14:20:23 -0600 )edit

I never figured out how to change the localhost file location. However, I did solve editing by navigating to the files I want to change in sudo nautilus mode.

3Joe3 gravatar image3Joe3 ( 2013-05-24 15:27:53 -0600 )edit
1

You can't serve web content from someplace other than /var/www/html without also altering the SELinux context on the files, otherwise apache httpd won't be able to see the files and an AVC will be logged in the audit log.

wquine gravatar imagewquine ( 2013-05-29 19:23:16 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-05-30 05:43:38 -0600

FranciscoD_ gravatar image

One simple way is to use the per user public_html directory.

Another is to create a group that has access to /var/www/html and add your user to this group.

I think the public_html method is better, personally, but I haven't looked at the pros and cons. Google should have that information.

edit flag offensive delete link more
0

answered 2013-05-30 06:40:54 -0600

subfusc gravatar image

updated 2013-05-30 06:53:37 -0600

If you want to just have a LAMP server with some editing rights, you should chown the files to be the same group as the user the webserver is running as. In the case of Fedora, this is the apache user.

$ sudo chown :apache -rv /var/www/html/directory/you/want/access/to
$ sudo chmod g+w -Rv /var/www/html/directory/you/want/access/to

and then add yourself to that group

$ sudo usermod -a -G apache $your_username

Now you should be able to edit the files after you restart your shell or log out/in again. If this is greek to you, I strongly recommend reading on unix filesystem permissions. Short description: http://www.dartmouth.edu/~rc/help/faq/permissions.html

If you want to do development, you should follow FranciscoDs advice and enable per-user html directory

edit flag offensive delete link more

Comments

I strongly discourage this solution : apache should never owns the "script". Apache only need riead access to most file.

Remi gravatar imageRemi ( 2013-05-31 11:29:40 -0600 )edit

You're right, if the web-application doesn't need write access to that directory, you should make a different group that apache doesn't belong to. I just assumed that there was a webapplication that also needed write access to that directory

subfusc gravatar imagesubfusc ( 2013-06-01 06:49:19 -0600 )edit

If you want to do that, append $ sudo addgroup apacheadmin and replace apache with apacheadmin in the commands

subfusc gravatar imagesubfusc ( 2013-06-01 07:10:28 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-05-24 13:56:53 -0600

Seen: 1,479 times

Last updated: May 30 '13