I've got a LAMP stack up and running (lamp-server^ specifically), and now I'd like to experiment a bit with it, although I would rather not be editing files in /var/www/html, it seems silly to be doing everything as root.

Is there a good way to code projects somewhere else?


Yes, enable the userdir module for Apache (I'm unfamiliar with lamp-server, normally you just run sudo a2enmod userdir but you'll have to figure out how to enable the module).

Once enabled, you can create a public_html directory inside your home, ensure your home and public_html have world read permissions, and you can put your PHP scripts in your public_html.

Optionally, you could add your user to the www-data group and make /var/www/html group-writable (sudo chmod g+w /var/www/html).

Either approach is suitable for testing and development, for production I suggest you google around for current best PHP practice, as I'm way too rusty to suggest anything specific.


Open your httpd.conf file. It's usually under ~\etc\httpd.conf. There you will find a line like this

DocumentRoot "/var/www/html"
<Directory "/var/www/html">

Change it to your desired path and restart the server. It should solve your problem..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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