Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running PHP (5.3.3) as an Apache module on a Apache (2.2.17) server.

PHP 5.3.5 is already compiled, can I just run make install to install the new PHP libraries or should the server be stopped before doing that? I'd like to avoid the latter (stopping the server) as there are many requests for static content (not PHP) as well.

Before commenting, I'm pretty sure that the upgrade will not break any PHP scripts.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Nope, it's not safe to install PHP (module) over an existing running installation. This may render your webserver in a unstable state. The webserver should be stopped before overwriting an existing PHP installation.

Instructions for upgrading PHP while the webserver is running

If your website is serving both static content and PHP content, consider removing the next line from httpd.conf for disabling PHP:

LoadModule php5_module        modules/libphp5.so

Deny access to files with an '.php' extension if php5_module is not loaded (this should be present on every installation to prevent source exposure):

<IfModule !php5_module>
    <FilesMatch "\.(php|phtml)$">
        Order allow,deny
        Deny from all
    </FilesMatch>
</IfModule>

Then reload your Apache configuration:

# /usr/local/apache2/bin/apachectl graceful

Install PHP from your source directory:

# make install

This command should add a LoadModule php5_module modules/libphp5.so to the httpd.conf file too, checking whether it has been added or not does not hurt.

And finally reload the configuration to enable PHP support again:

# /usr/local/apache2/bin/apachectl graceful
share|improve this answer

It should be fine to make install and then proceed to restart the server, have done it in the past myself.

Just as a safeback be sure to do a tar of your previous php libraries, just in case the upgrade doesn't go well! ;)

share|improve this answer
1  
My fears became true. After applying this, I got 1300 new lines in my error log in 3 seconds. Most of these errors are "child pid /nnn/ exit signal Illegal instruction (4)". The last message was "seg fault or similar nasty error detected in the parent process". After restarting Apache, it seems to work. This answer is not recommended to follow. –  Lekensteyn Jan 19 '11 at 22:21
    
What happend was that your existing apache had the old php loaded (mod_php or fastcgi), you installed the new php modules, then the old php crashed trying to load the new modules. Add "shut down apache first" to the list of instructions. –  DerfK Jan 19 '11 at 22:31
    
I've encountered this same thing before. But that was a test machine, and I wasn't sure whether it was about a PHP extension or the PHP module itself. –  Lekensteyn Jan 20 '11 at 16:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.