1820619 Members
1884 Online
109626 Solutions
New Discussion юеВ

Re: restart apache

 
SOLVED
Go to solution
Sanjiv Sharma_1
Honored Contributor

restart apache

I have apache installed on HP-UX 11.11. I get frequent request from the web user to restart the apache as root.

Can I grant access to a normal user to only start apache as root? What are the options available?

thanks,
Everything is possible
9 REPLIES 9
Rick Garland
Honored Contributor

Re: restart apache

You can get SUDO and include the user for starting apache in the sudoers file.

Mel Burslan
Honored Contributor

Re: restart apache

create a cron job under root's crontab which checks for existence of a request file in this users's home directory and if it exists it restarts apache httpd's and deletes the file.

when the user needs restart he simply creates this file, naming convention of which needs to be determined by you and the user.

frequency of the cronjob running also needs to be determined by you and the user.
________________________________
UNIX because I majored in cryptology...
Sanjiv Sharma_1
Honored Contributor

Re: restart apache

Rick,

Can I get the step by step procedure required for the sudo configuration for a user to start apache?

thanks,
Everything is possible
Mel Burslan
Honored Contributor
Solution

Re: restart apache

if you do not have sudo package, download it from:

http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/sudo-1.6.8p7/

uncompress install it using gunzip and swinstall.

after installation is complete, edit /etc/sudoers file and add a line like this

username servername = NOPASSWD: /sbin/init.d/apache apache stop
username servername = NOPASSWD: /sbin/init.d/apache apache start

-or- write a script to do your custom stop and start of apache web server and give the user the capability of running this script only in the sudoers file like this

username servername = NOPASSWD: /my_path/my_script.sh

notes:
1.username is the userid of the user who will be capable of doing this action
2.servername is the hostname of this server

hope this helps.
________________________________
UNIX because I majored in cryptology...
Rick Garland
Honored Contributor

Re: restart apache

Been in meetings. Mel has it well listed.
Sanjiv Sharma_1
Honored Contributor

Re: restart apache

Mel,

I tried both the options given by you but it is asking for a password.
*****************************************
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these two things:

#1) Respect the privacy of others.
#2) Think before you type.

Password:
********************************************
I tried giving root password but it take it as a wrong password.

Any idea.
Everything is possible
Stuart Powell
Super Advisor

Re: restart apache

Raje,

Are you issuing the command as root or as yourself? The intent of sudo is to execute root commands as a non-root user.
Assuming that you are logged in as your username, use your password when prompted.

Stuart
Sometimes the best answer is another question
Sanjiv Sharma_1
Honored Contributor

Re: restart apache

Mel,

Yes. It works.

username servername = NOPASSWD: /sbin/init.d/apache apache start

Earlier I missed a space between NOPASSWD: /usr/init.d/apache.

Thank you very much.
Everything is possible
Sanjiv Sharma_1
Honored Contributor

Re: restart apache

Thread closed.
Everything is possible