I installed apache2 on my local machine, and when typing which apache2 it returns:


And when trying setting path for apache2 by using the following command:

sudo apache2 -settingpath /usr/sbin/apache2

It failed! It failed because whenever I restart apache2 using apache2 restart, I always receive error message telling me that I used the wrong user id.

So could you help me set path for Apache http server on Ubuntu 12.04?


The Default path for apache is /var/wwww.

You can change it by Configuring


file. You can find it in


  • Hi Ketan Patel. Thank you for your answer. However, I want to configure the path to start apache. That is to say, I can simply type: apache2 restart, instead of /etc/init.d/apache2 restart. – petwho Sep 27 '12 at 7:05

I think you are looking to use the -k restart thus

sudo apache2 -k restart

To which you will be prompted for your password with which you log in.

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.