How to manually update PHP version on one site in VPS?

vps

#1

Greetings,

I have 60 websites, most of them using PHP version 5.4. I have one old site using PHP 5.2.17 . I have hosting set to “unmanaged”, so I’m trying to get practice on updating a PHP version myself.

How do I update the PHP version (through putty/unix command line) for just this one domain name (not all of my domains)? Is there some kind of file that lists all of my domains and what version of PHP they are using?

Thanks


#2

This page will list your domains and which version of PHP they are running:

https://panel.dreamhost.com/index.cgi?tree=domain.manage&

You can click on the “edit” link in the center of the column to change the PHP version.


#3

Greetings kjodle,

I already knew how to do it from the control panel. I’m asking how can it be done manually. I may need to switch to the DreamCompute service, which is NOT managed by Dreamhost (meaning I have learn to do everything myself and administer my own server). I’m trying to get practice on how to do this myself as the Dreamhost control panel for domain management will no longer work on DreamCompute (as far as I know).

Thanks
Kind regards


#4

There is no officially supported method to change the PHP version other than by using the DreamHost Panel. Unofficially, you may be able to search through the web server configuration and change “php5.cgi” to “php56.cgi” (for example) under the VirtualHost for the appropriate domain. However, keep in mind that, if you’re on an older unmanaged server that still has PHP 5.2 installed, newer versions of PHP may not be available for your server.

On DreamCompute, you’re on your own. There is no standard method for installing multiple versions of PHP in parallel; we had to build a lot of the infrastructure for managing this configuration ourselves, and this infrastructure is not available outside of DreamHost managed systems.


#5

What do I need to change in the httpd.conf file for a specific domain? I would like to update from HPP 5.2.17 only to PHP 5.3 or 5.4 (My site will break on PHP 5.5 or 5.6 because it’s an old site not set up for mysqli_ statements yet.

Here is the VirtualHost snippet for the domain in question:

[code]<VirtualHost ...:80>
ServerAdmin webmaster@[My Site].com
DocumentRoot /home/[My Site]/[My Site].com
ServerName www.[My Site].com
ServerAlias [My Site].com
DirectoryIndex index.html index.shtml index.htm Index.html Index.htm Index.shtml default.htm Default.htm default.html Default.html default.shtml Default.shtml page1.html index.pl index.cgi index.php index.php3 index.phtml home.htm home.html home.shtml index.wml index.pcgi quickstart.html
SetEnv PHPRC /dh/etc/php-ini/[My Site].com.
/php.ini
ErrorLog /home/_domain_logs/[My Site]/[My Site].com/http.
/error.log
Alias /stats /home/_domain_logs/[My Site]/[My Site].com/http.
/html
<Directory /home/_domain_logs/[My Site]/[My Site].com/http.
/html>
AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,Includes,Indexes,MultiViews,SymlinksIfOwnerMatch,FollowSymlinks

Alias /doc/analog /usr/share/analog
RewriteEngine on
RewriteMap tolower int:tolower
RewriteMap toupper int:toupper
RewriteMap escape int:escape
RewriteMap unescape int:unescape
RewriteRule ^/dh_phpmyadmin/([^/]
)/?(.
) /dh/web/phpmyadmin/$2
SuexecUserGroup #******** #*****
<Directory /home/[My Site]>
AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,Includes,Indexes,MultiViews,SymlinksIfOwnerMatch

<Directory /home/[My Site]/[My Site].com>
AddHandler cgi-script .cgi .pl .py
Options Includes Indexes SymLinksIfOwnerMatch ExecCGI
AddHandler php-cgi .php4 .pcgi4
AddHandler php5-cgi .php .php3 .phtml .pcgi .php5 .pcgi5
#RewriteCond %{QUERY_STRING} ../proc/self/environ [NC]
#RewriteRule .* - [F,L]
<Files .php.>
RemoveHandler .php

<Files .php4.>
RemoveHandler .php4

<Files .php5.>
RemoveHandler .php5


AddHandler fcgid-script fcg fcgi fpl
AddHandler fcgid-script .php .phtml .php5 .pcgi5
FCGIWrapper “/dh/cgi-system/php5.cgi -c /dh/etc/php-ini/[My Site].com./php.ini" .php
FCGIWrapper "/dh/cgi-system/php5.cgi -c /dh/etc/php-ini/[My Site].com.
/php.ini” .phtml
FCGIWrapper “/dh/cgi-system/php5.cgi -c /dh/etc/php-ini/[My Site].com./php.ini" .pcgi
FCGIWrapper "/dh/cgi-system/php5.cgi -c /dh/etc/php-ini/[My Site].com.
/php.ini” .php5
FCGIWrapper “/dh/cgi-system/php5.cgi -c /dh/etc/php-ini/[My Site].com.*******/php.ini” .pcgi5

php_myadmin doesn’t work with php-cgi for some reason.

<Directory /dh/web/phpmyadmin>
EnableSendfile Off
EnableMMAP Off

SecFilterEngine Off


SecRuleEngine Off

AddHandler php5-cgi .php .php3 .phtml .pcgi .php5 .pcgi5

RewriteEngine On
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]


php_value register_globals On



SecFilterEngine On


SecRuleEngine On


AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
DeflateMemLevel 5
DeflateCompressionLevel 5

type specifics

php

AddType application/x-httpd-php .php .php4 .php3 .phtml

php_admin_value open_basedir /dh/web/phpmyadmin:/tmp:/usr/local/lib/php:/home/[My Site]:/home/[My Site]

Action php-cgi /cgi-system/php.cgi
Action php5-cgi /cgi-system/php5.cgi
SetEnv dsid ******
SetEnv ds_id_*******
SetEnv DH_USER [My Site]
CustomLog /dh/apache2/logs/apache2-ps******/mega.log “{ “@timestamp”: “%{%Y-%m-%dT%H:%M:%S%z}t”, “@fields”: { “vhost”: “%v”, “client”: “%a”, “bytes_in”: %I, “bytes_out”: %O, “duration_usec”: %D, “status”: %s, “request”: “%U%q”, “method”: “%m”, “file”: “%f”, “referrer”: “%{Referer}i”, “user”: “[My Site]”, “pid”: %P } }” env=!nomega
CustomLog /home/_domain_logs/[My Site]/[My Site].com/http.******/access.log "%h %l %u %t “%r” %s %O “%{Referer}i” “%{User-agent}i” "
[/code]

Thanks
Kind regards


#6

As I noted earlier, the lines you would need to change are the ones referencing “php5.cgi” – one line starting with “Action”, and five beginning with “FCGIWrapper”. Change “php5.cgi” to “php53.cgi”, “php54.cgi”, or so on as appropriate to the version you need to upgrade to.

Keep in mind that you do not need to use MySQLi to upgrade to PHP 5.5 or later. The older MySQL extension is available, albeit deprecated, on all versions of PHP prior to 7.0.

(To future readers: Please note that these instructions are not necessary for typical DreamHost server configurations, and generally should not be followed. We recommend that all customers use the DreamHost Panel to manage their web site configuration.)


#7

Greetings Andrew,

Thanks for the info. This seems to have worked in updating the PHP version number (from PHP 5.2.17 to PHP 5.3.29 according to the phpinfo() file). As expected, this seemed too easy and the site broke anyways (this is just a test site by the way). I’m getting an error at the very beginning when the site loads: “Call to undefined function mysql_connect()”. It’s an old site, but I think mysql_connect() from PHP 5.2 should still be compatible with PHP 5.3. I changed php53.cgi back to php5.cgi and everything works again.

If I’m manually updating one website from PHP 5.2 to 5.3 this way, is there something else that needs to be updated in Apache or Linux?

Also, when I update the httpd.conf file, I’m assuming I use this shell command to update/refresh the configuration file changes, but not restart the entire server and interrupt all of my sites?:

Thanks
Kind regards


#8

Huh. If your server has been unmanaged for long enough, it’s possible that it was never fully configured for PHP 5.3. Unfortunately, if this is the case, fixing it is beyond the scope of what I can reasonably walk you through here; my recommendation would be that you reenable web server and PHP management temporarily to make this change, then redisable it and apply any changes you’ve made to the configuration afterwards.


#9

Greetings Andrew,

The only “unmanaged” part of my VPS is the web server configurations, the PHP config is still managed. Turning the Web Config to “managed” and reprocessing the httpd file from the domain management panel seems to have cleared up the issue, so the main site works. Unfortunately the old forum software is getting the depreciation errors, so it must be incompatible with PHP 5.3 and there isn’t anything else I can do about that other than buying the updated forum software. I rolled it back to php5.cgi for now.

Thanks for the help.
Kind regards