If you are running Linux, you can run Phing with the sudo command to allow it enough privileges to restart apache.
sudo phing restartapache
Assuming restartapache is an exec task that invokes the apache restart command. For instance:
<target name="restartapache" description="Restarts the web server"> <exec command="/etc/init.d/apache2 restart" /> </target>
To avoid asking the sudo command for a password, you can update sudo permissions for any user account that is running your build (this example demonstrates disabling the sudo password request for jenkins):
sudo visudo
Then add the following lines:
Defaults:jenkins !requiretty,!lecture jenkins ALL=NOPASSWD:/etc/init.d/apache2
The above has been edited to improve security in accordance with this answer so that Jenkins will allow restarting apache without a password and nothing more.
source share