2

Possible Duplicate:
How to make Apache run as current user

I'm setting up my local test server again, and I seem to have forgotten how to successfully set up the LAMP server.

I have installed LAMP server via tasksel command and I have configured the /var/www directory according to a guide I've found:

After the lamp server installation you will need write permissions to the /var/www directory. Follow these steps to configure permissions.

Add your user to the www-data group

sudo usermod -a -G www-data <your user name>

now add the /var/www folder to the www-data group

sudo chgrp -R www-data /var/www

now give write permissions to the www-data group

sudo chmod -R g+w /var/www

So logan user is now part of www-data group and the file/folder permissions look like the output below:

logan@computer:/var/www$ ls -lart
total 172
-rw-r--r--  1 www-data www-data  1997 Oct 23  2010 wp-links-opml.php
-rw-r--r--  1 www-data www-data  3177 Nov  1  2010 wp-config-sample.php
-rw-r--r--  1 www-data www-data  3700 Jan  8  2012 wp-trackback.php
-rw-r--r--  1 www-data www-data   271 Jan  8  2012 wp-blog-header.php
-rw-r--r--  1 www-data www-data   395 Jan  8  2012 index.php
-rw-r--r--  1 www-data www-data  3522 Apr 10  2012 wp-comments-post.php
-rw-r--r--  1 www-data www-data 19929 May  6  2012 license.txt
-rw-r--r--  1 www-data www-data 18219 Sep 11 08:27 wp-signup.php
-rw-r--r--  1 www-data www-data  2719 Sep 11 16:11 xmlrpc.php
-rw-r--r--  1 www-data www-data  2718 Sep 23 12:57 wp-cron.php
-rw-r--r--  1 www-data www-data  7723 Sep 25 01:26 wp-mail.php
-rw-r--r--  1 www-data www-data  2408 Oct 26 15:40 wp-load.php
-rw-r--r--  1 www-data www-data  4663 Nov 17 10:11 wp-activate.php
-rw-r--r--  1 www-data www-data  9899 Nov 22 04:52 wp-settings.php
-rw-r--r--  1 www-data www-data  9175 Nov 29 19:57 readme.html
-rw-r--r--  1 www-data www-data 29310 Nov 30 08:40 wp-login.php
drwxr-xr-x 14 root     root      4096 Dec 24 17:41 ..
drwx------  9 www-data www-data  4096 Dec 26 16:11 wp-admin
drwx------  9 www-data www-data  4096 Dec 26 16:11 wp-includes
-rw-rw-rw-  1 www-data www-data  3448 Dec 26 16:14 wp-config.php
drwxrwxr-x  5 www-data www-data  4096 Dec 26 16:14 .
drwx------  6 www-data www-data  4096 Dec 26 16:19 wp-content

Things work perfectly at http://localhost, I can view the website fine. The thing with this is that I will be working on a plugin for wordpress and I don't want to deal with separate owners under www directory to create or modify files/folders. When I give my user the ownership of /var/www recursively as logan:www-data I can create/modify files but cannot view the http://localhost. I get a Forbidden error. I'm assuming that this is because of the Apache's configuration?

Which one is healthier or easier considering this is just a local test website, configuring apache to give user logan to view website and chmod /var/www logan:logan so that I can create files etc. without any sudo commands; or is it easier to configure user groups to get www-data user to act like my logan user? (Idk how that's possible, maybe putting www-data user under logan group?)

Please shed some light to this subject. All I want is to be able to create/modifiy files under my user, and yet to be able to successfully view http://localhost I appreciate the help!

1
  • I found the answer on a different post and flagged my question as duplicate. Only if my google queries have shown me that page earlier :( Sorry for the duplicate guys.
    – Logan
    Dec 26, 2012 at 22:37

1 Answer 1

2

Edited this original post

Edit the following file as root: /etc/apache2/envvars

using the command:

sudo vim /etc/apache2/envvars

change the user and group to yourself if there is only one user and you will never have permissions problems again.

I.E., if you are only logging in and running the server as user 'logan':

export APACHE_RUN_USER=logan export APACHE_RUN_GROUP=logan Heck, for that matter you could change that user to the current user I'm sure somehow. Then, install user_dir you all have webs only you can have full control of (unless you modify this).

Restart the server

sudo /etc/init.d/apache2 restart

If you see:

  • Restarting web server apache2 ... waiting /var/lock/apache2 already exists but is not a directory owned by user. Please fix manually. Aborting.

You can change the permission to the apache locks before restarting apache:

chown -R myuser:myuser /var/lock/apache2/

sudo service apache2 restart

Not the answer you're looking for? Browse other questions tagged .