Change Apache User in Ubuntu

On Ubuntu/Debian server, apache run as user www-data. When you install Apache web server on your local computer for developement purpose, it may be easier to run Apache as your user. If you run Apache as www-data user, you will need to chmod folders 777 for yoru web application to write to a folder like file upload, creating log files etc..

To change Apache user, edit file

vi /etc/apache2/envvars

Find and replace www-data with your user name. You can do this with following sed command

sed -i "s/www-data/USERNAME/g" /etc/apache2/envvars
chown -R USERNAME:USERNAME /var/lib/php

Comments

4 responses to “Change Apache User in Ubuntu”

  1. Peg Avatar
    Peg

    is it ~ok~ to delete the www-data file located in /var/mail ? Now over 25 MB …

    1. ServerOk Avatar
      ServerOk

      You can remove it, mostly it will be bounced messages or system generated emails.

      1. Peg Avatar
        Peg

        ~ok~ to remove on a production server? And I’m guessing a ~cron job~ would be good to set up to run say monthly?

        1. ServerOk Avatar
          ServerOk

          Yes, set a cron job to remove it.

Leave a Reply

Your email address will not be published. Required fields are marked *