473,800 Members | 2,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Restart apache using PHP

hello all,

i`m trying to restart apache from php but have failed completely.
has anyone sucesfully done it?

i'm currently able to execute other unix commands from php adding the
proper permissions to the sudo file but apache refuses to restart.

here's the pseudo-script:

<?php
....
$output = shell_exec("/usr/sbin/httpd -k restart");
exit;
?>
(i tried /etc/init.d/httpd too but got the same results)

here's the sudo file

....
apache ALL = NOPASSWD: /usr/bin/php, /usr/sbin/useradd,
/usr/sbin/chpasswd, /httpd/scr, /usr/sbin/httpd
....

i'm using RH-ES, PHP4, Apache2 & selinux turned off

best regards,
cristián.

Oct 24 '05 #1
6 3566
black francis wrote:
hello all,

i`m trying to restart apache from php but have failed completely.
has anyone sucesfully done it?

i'm currently able to execute other unix commands from php adding the
proper permissions to the sudo file but apache refuses to restart.

here's the pseudo-script:

<?php
...
$output = shell_exec("/usr/sbin/httpd -k restart");
exit;
?>
(i tried /etc/init.d/httpd too but got the same results)

here's the sudo file

...
apache ALL = NOPASSWD: /usr/bin/php, /usr/sbin/useradd,
/usr/sbin/chpasswd, /httpd/scr, /usr/sbin/httpd
...

i'm using RH-ES, PHP4, Apache2 & selinux turned off

best regards,
cristián.

Have you tried apachectl?
Oct 24 '05 #2
Joe Estock wrote:
Have you tried apachectl?


It's apache2ctl on my system.

$ apache2ctl -k start|restart|g raceful|stop
JD
Oct 24 '05 #3
the OS it's Red Hat, so apachectl = /usr/sbin/httpd

Oct 24 '05 #4
"black francis" <cr************ ***@gmail.com> wrote:

i`m trying to restart apache from php but have failed completely.
has anyone sucesfully done it?

i'm currently able to execute other unix commands from php adding the
proper permissions to the sudo file but apache refuses to restart.

here's the pseudo-script:

<?php
...
$output = shell_exec("/usr/sbin/httpd -k restart");
exit;
?>
(i tried /etc/init.d/httpd too but got the same results)

here's the sudo file

...
apache ALL = NOPASSWD: /usr/bin/php, /usr/sbin/useradd,
/usr/sbin/chpasswd, /httpd/scr, /usr/sbin/httpd
...


Yes, but your shell_exec isn't calling sudo. Did you intend to?
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Oct 25 '05 #5
shame on me.

thnx!

Oct 25 '05 #6
a bit complicated solution is to use cron to get root access, and keep
everything looking secure. the crontab script checks a file, and the
webpage fills the file on request. (newbies, do not call that file
directly)

cheers.

Oct 26 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9987
by: Charon | last post by:
I am running php 4.3.4 Win 32 as a module with Apache 1.3.29. I am trying show this modification in the php.ini file session.save_path = C:\PHP\phpsessiondata But when I restart then then go into PEAR to begin an install I allways have the following errors at the bottom of the page. Any ideas ?
5
3225
by: anr | last post by:
Hi everyone, I have made a solution where a user is added to the system and a folder is set up for him. In order to make the folder webDAV accessible for him I have to add some lines to the current httpd.conf file and restart the webserver. Is this possible to do from my php script - or even advisable? I could envision an alternative where i would make a cron job restart httpd every 15 minutes or so, but i would prefer the first...
4
6032
by: ccc31807 | last post by:
This is my 5th or 6th server (both Unix and Windows varieties). In the past I've gotten the message "ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (222)". In the past, I've either asked someone else to start the server or just tried everything I could until the server started. This time, I took a systematic approach, and noted every step. What finally worked was typing the command "service...
5
1808
by: Daniel | last post by:
Hi, is the a way to prevent aspnet process to restart after web.config is modified? like, waiting for all sessions to close, or not restart at all ? Thank you, Daniel
3
3216
by: John A Grandy | last post by:
In ASP.NET 1.1 and/or 2.0 ..... Is it possible to configure a web-app so that replacement of an .xml file ( physically located under the virtual dir root ) with a newer version of the file causes a web-app restart ... ? Also, is a stopping and starting a website in IIS the only way to restart a web-app ? (Of course, iisreset stops and starts all web-apps on the web-server ... but
3
3518
machismo350
by: machismo350 | last post by:
In order to communicate on new certificates,i am doing an apache restart (using apachectl -k graceful) ,which should take the new .crt & .key for communication but this takes more time and any request coming for the corresponding host on which the configuration were done fails,is there any other way i can have apache take up the config changes quickly and respond to requests.
2
4268
by: csgonan | last post by:
I have a new 64 bit apache 2.2.4 server on Solaris 10 with openssl 0.9.8e. When I DO NOT have the ssl.conf file included and I "apachectl graceful" to apache, all my processes that are gracefully shutdown are shown by a dash (-). When I have the Include line for the ssl.conf file uncommented, the number of Gs never changes, like it is locked in the graceful shutdown. I have prefork compiled in but not worker or event if that makes a...
0
3381
by: koolestj | last post by:
I am trying to understand why a server restart would cause mod_jk to not find a worker. I checked all tomcat workers were running and I was able to telnet to the ajp port on each app server. Just to give background I have 1 web server that is running apache with mod_jk for load balancing. The apache web server is configured to run as a Service and is setup to run Automatically. I have 5 tomcat workers (app engines) that serve http requests...
15
3545
by: cheesecaker | last post by:
The Restart shortcut for Apache doesn't work properly for me. The restart seems to have succeeded, but then I can't access any pages on the server. Requests time out. It does work when I stop then server, then start the server. I've written a batch file to do it automatically, but I'd still like to know why a regular restart doesn't work.
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10273
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.