I think for a development machine, its more convenient to run Apache as the current user to simplify permissions problem? How do I do that? I think its suexec but how do I configure it in Ubuntu+Apache?
I think for a development machine, its more convenient to run Apache as the current user to simplify permissions problem? How do I do that? I think its suexec but how do I configure it in Ubuntu+Apache?
Edit the following file as root: /etc/apache2/envvars
using the command:
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 'big_dog':
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 (if unsure, just reboot or goole) and you are good to go.
I myself would add the user to the
www-data
group with...Simple and effective. No messing with config files or permissions.
You can do this with the
mpm_itk_module
module.Install on Ubuntu 20.04:
Create a Virtual Host for sites in your home folder
Add your domain (in this case I'm using the username as domain) to /etc/hosts
Restart apache
Install all your sites under subfolders under
/home/codealfa/www
and access them in your browser fromhttp://codealfa/
. For eg., install one site at/home/codealfa/www/site1
and you can view it in your browser athttp://codealfa/site1/
.why would you do this,, I was strugnling with that perm issues in the past, but this is my dev process from today:
sudo apt-get install lamp-server^
proc to get lamp upmake sym link to my home dir where projects are like this:
ln -s /home/user/html /var/www/html
make sym link to hosts config file
ln -s /home/user/html/Apache-VirtualHosts.conf /etc/apache/sites-enabled/000-default
that's it :)
It works as aspected, no issues with user perms or something similar with apache server,, for mysql I have little longer process..
hth, cheers
Sidestepping the "should you do this" issue, you can find where the user for apache is set by running:
It's then a case of editing those instances in
/etc/apache2/apache2.conf
and reloading Apache (sudo /etc/init.d/apache2 reload
).create a new usergroup
webdev
and add thewww-data
user to it.Then go ahead and add your user to that group and make it the default group for yor user.
Last thing to do is to make sure, the group webdev has rwx rights on the files
Now the only thing that can occur is that for e.g. www-data creates a new log file and you can't rwx it.
If anyone trying to achieve this on a docker container, This worked for me.
create your own user (non-root user hence the id 1000) and give permissions:
Note: Add this line only after installing all the apache modules you needed.
For those who just want to spawn a web-server for local development
You can start PHP's in-built server