Ubuntu – restart apache under www-data user in ubuntu

apache-2.2httpdsaasUbuntuwww-data

I have a SaaS webapp service, so each time a new client is registered in my registration app, it creates a new subdomain and a new apache virtualhost config file, to enable this configuration I need to restart apache (is running on port 8080), how ever if I try to run either /etc/init.d/apache2 restart or apache2ctl restart under www-data (this is the user that is running my app) I get the following error:

Address already in use: make_sock: could not bind to address 0.0.0.0:8080
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.

How could I restart automatically apache?

OS is Ubuntu Server 10.10

Best Answer

You could add this to your sudoers file and then simply use sudo to you call the apache restart command.

Cmnd_Alias AP2RESTART=/etc/init.d/apache2
www-data ALL=NOPASSWD: AP2RESTART