Restarting httpd in PHP

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Restarting httpd in PHP

Postby Dariusc123456 » 15. October 2010 15:33

Hello, can someone help me out by telling me how to restart apache in PHP on windows? I tried so many times but it never restarts the server, and it dont even execute the bat file I made to stop and start apache. I tried to use httpd -k graceful but it dont work of it gives this back in the command prompt.
(OS 10048)Only one usage of each socket address (protocol/network address/port) is
normally permitted. : make_sock: could not bind to address [::]:80
(OS 10048)Only one usage of each socket address (protocol/network address/port) is
normally permitted. : make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs


Is there something special I need todo to get it to restart in PHP? I am tired of using mod_rewrite since its abit limited.
Dariusc123456
 
Posts: 22
Joined: 15. October 2010 15:18

Re: Restarting httpd in PHP

Postby JonB » 15. October 2010 16:58

Out of pure curiousity - why do you want to restart Apache? :?:

(I would have my own reasons, I'm sure - but I'm curious to know what you want to do)

:shock:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Restarting httpd in PHP

Postby Dariusc123456 » 15. October 2010 18:45

I have a website - http://shouthost.tk - and my cpanel needs to somehow reload the vhost configuration settings and since the graceful command doesnt work, my only option is to restart it, and I dont want to make a cron job to do it because of some other problems.
Dariusc123456
 
Posts: 22
Joined: 15. October 2010 15:18

Re: Restarting httpd in PHP

Postby JonB » 15. October 2010 19:21

I guess I should point out to you that XAMPP is not intended for production environments. (read their FAQ)

LOL - Yeah, I guess it would be tough, as Windows doen't have cron.

good luck
:)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Restarting httpd in PHP

Postby Dariusc123456 » 15. October 2010 23:11

I have a program to perform cron jobs (crond.exe) and what do you mean its not for production environments? The website you saw isnt for production, just something small.

Is there anyway to restart apache in php or use httpd -k graceful?
Dariusc123456
 
Posts: 22
Joined: 15. October 2010 15:18

Re: Restarting httpd in PHP

Postby JonB » 16. October 2010 00:36

A - what about this on the FAQ page is unclear? (I did say to refer to the FAQ, right?)

The philosophy
The philosophy behind XAMPP is to build an easy to install distribution for developers to get into the world of Apache. To make it convenient for developers XAMPP is configured with all features turned on.
The default configuration is not good from a securtiy point of view and it's not secure enough for a production environment - please don't use XAMPP in such environment.
Since LAMPP 0.9.5 you can make your XAMPP installation secure by calling »/opt/lampp/lampp security«.


http://www.apachefriends.org/en/xampp.html

Its meant to be for testing and devlopment - and that is 'my philosphy' also. Just mine, no one else's - so anyone can jump in with any good ideas they have and say their piece.

I would tell you PHP is the wrong tool, but that's another discussion. I will only say find out what Cpanel and Webmin are written in, and then think about why,

Read this Apache documentation carefully - it explains what command options you may use with a Windows OS - there is one there for what you want to do.

http://httpd.apache.org/docs/2.1/platfo ... tml#winsvc

Good luck
:)

ysaf
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Restarting httpd in PHP

Postby Dariusc123456 » 16. October 2010 01:37

Well, xampp is good for hosting websites because it has the tools todo so.
Dariusc123456
 
Posts: 22
Joined: 15. October 2010 15:18

Re: Restarting httpd in PHP

Postby JonB » 16. October 2010 01:48

Ok - did you get the answer you needed???

Let me know if your error goes away. If it doesn't, I probably know why. I'm not holding out - I simply don't know if you can do what you want to with PHP (at least as a DLL). There are things that just don't work.

:?:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Restarting httpd in PHP

Postby Dariusc123456 » 16. October 2010 02:37

Well can you tell me why when I do "httpd -k graceful" from the command line it gives

(OS 10048)Only one usage of each socket address (protocol/network address/port) is
normally permitted. : make_sock: could not bind to address [::]:80
(OS 10048)Only one usage of each socket address (protocol/network address/port) is
normally permitted. : make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs


It work in the past when I was learning how to use the server but after a while it stop working.

Code: Select all
function restart_server(){
    $cmd ="start C:\\xampp\\apache\\bin\\httpd.exe -k graceful";
    pclose(popen($cmd,'r'));   
}


This command worked also but it stop after a while and I dont know why.

I can understand xampp isnt a good thing to use in a production environment but the machine its on is secure, and powerful. Everything including apache (not with xampp panel running), ftp server works great on it and very secure (made modification to the httpd.conf and to php.ini). All xampp is a package with mail server, ftp server, and web server along with a small panel to manage it all. Without xampp executable its nothing more than a server on a window machine, so theres no difference in between if its good in a production or not because basicly if xampp wasnt made for it, then neither is apache httpd.
Dariusc123456
 
Posts: 22
Joined: 15. October 2010 15:18

Re: Restarting httpd in PHP

Postby JonB » 16. October 2010 05:44

well, there's a couple of things in play here.

1. - httpd -k graceful is a unix command line option , not a Windows one. So I suspect that is the source of that issue.

reference -

This document covers stopping and restarting Apache on Unix-like systems. Windows NT, 2000 and XP users should see Running Apache as a Service and Windows 9x and ME users should see Running Apache as a Console Application for information on how to control Apache on those platforms.


http://httpd.apache.org/docs/2.1/stopping.html

read down the page a bit.

I gave you that first URL - so you would read which command line options exist for WINDOWS.

http://httpd.apache.org/docs/2.1/platfo ... ml#wincons

You can also tell Apache to restart. This forces it to reread the configuration file. Any operations in progress are allowed to complete without interruption. To restart Apache, either press Control-Break in the console window you used for starting Apache, or enter

httpd.exe -k restart


You may have to use net start . stop as it is a Windows Service. I start and stop Apache that way when I am running backups. But I mean I want to do a full stop -- not a restart. I also stop MySQL at the same time, for the same reason. I rum two different baclups in parallel - one that is a sqldump and one that is an incremental file system backup of XAMPP.

2. - I think you may also be hitting a wall with PHP - because it relies on Apache to instaniate itself. PHP exists iff Apache exists. SO if you ask PHP to exit and perform a command, that restarts the executable that called it - it is in an indefinite state. The command/system call is supposed to return control to the service (PHP as DLL i.e php5ts.dll, -- called by httpd.exe you just killed.) with some error level set you should be reading from the OS, right? Who knows what that does with all the 'stuff'?

As for security - IIS is a lot more secure on a Windows server than Apache is, and it has just about all the same pieces (although the skill set is completely different) I have 2 W2K3 servers and 1 W2K8, all production severs - so I am not blowing smoke. I am only speaking from my own experience, and I don't I don't expect everyone to agree. I run some very sophisticated ISAPI based security software that runs alongside the native windows authentication schema.

But if you know Apache fairly well, you can plug most holes Still, there are things that Apache simply cannot do on Windows that it can do on *nix systems, and that is a function of its heritage, and the difference in system architectures and calls.

Good Luck
:)

The 'right solution' for all these things is a provisioning system.
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Restarting httpd in PHP

Postby Dariusc123456 » 16. October 2010 18:21

Well, your part about PHP and restarting apache makes sense but why did it work when I first restart it in PHP?

As for IIS, it be honest, its not secure as you may think. It been proven that ASP isnt secure due to a hole it has, and window itself isnt secure due to the amount of viruses and hackers who exploited windows to perform attacks on those type of servers. Even though window itself isnt secure, Apache is way more secure than IIS since apache is open source, which can help out with the development of the server to make it secure, it support on various machines (linux, windows, mac, and maybe more). IIS is close source, alot of the modules has small bugs, it doesnt manage bandwidth (from what I see). I honestly have a better chance to make a server to be more secure than IIS but it takes time.

Now back onto topic: I found another server call UniServer that use apache, and it is able to restart via php (gracefully) but I dont see why it dont work on windows now. I might as well make a cron job then,
Dariusc123456
 
Posts: 22
Joined: 15. October 2010 15:18


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 69 guests