Solved

Restart httpd and named via PHP (without suexec/as nobody)

Posted on 2006-11-09
8
821 Views
Last Modified: 2010-05-18
I need to restart both BIND and Apache from a PHP script that's running as nobody.  The following two lines don't work:

echo `/usr/sbin/httpd restart`;
echo `/etc/rc.d/init.d/named restart`;

Anyone?
0
Comment
Question by:inxil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 Comments
 
LVL 7

Author Comment

by:inxil
ID: 17909559
OK, so I came up with a solution that I think is about as good as it's going to get.  First I updated my sudoers file and added the following:

nobody ALL=(ALL) NOPASSWD: /etc/rc.d/init.d/named reload
nobody ALL=(ALL) NOPASSWD: /usr/sbin/httpd graceful

Then I updated my PHP script accordingly:

echo `sudo /usr/sbin/httpd graceful`;
echo `sudo /etc/rc.d/init.d/named reload`;

This means that the user nobody can gracefully restart apache and reload BIND's database, which is somewhat insecure, but is acceptable.  Does anyone have a better solution?
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 250 total points
ID: 17912792
Yup using sudo is the correct way to do such things
0
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

 
LVL 14

Assisted Solution

by:Aamir Saeed
Aamir Saeed earned 250 total points
ID: 17913801
You need root to do that. No two ways about it sorry.

Why would you want to restart Apache? Most httpds i know have an option that allows you to reload (meaning: keep running, but reload the configuration file).

I have even more troubble seeing why you would want to restart Bind. Checkout the remote name daemon control (rndc).
0
 
LVL 7

Author Comment

by:inxil
ID: 18197223
I feel like I answered the question myself...
0
 
LVL 7

Author Comment

by:inxil
ID: 18212516
I don't mind giving the points to hernst42 and i_m_aamir, but to those of you looking for a similar solution--the method I described works quite well.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question