This website is deprecated, and remains online only for historic access to old issues and docs for historic versions of Virtualmin. It has been unmaintained for several years, and should not be relied on for up-to-date information. Please visit www.virtualmin.com instead.
Unfortunately, there isn't an easy way to do this.
There are some hard ways, but they're, well, pretty hard :-)
You'd need to manually compile a PHP version (or create your own set of .deb's), install it into a custom location, and then in $HOME/cgi-bin (or fcgi-bin), edit the php5.cgi file for the domain that should be using the other version, and change the PHP path.
And then from there, you have to take care to keep your custom PHP version up to date, or you could end up with security issues.
I'd personally suggest not trying to install two PHP versions side-by-side, but if it's really something you'd want, it should work :-)
I have compiled and created a new php5.2, which is located in /opt/php-5.2.17/bin. I am just not sure how to get this to work properly - I have tried putting a cgi version into the correct places, however, it does not work correctly!
What you'd need to do is edit the php5.cgi file in the domain's cgi-bin or fcgi-bin directory, and change the path of "/usr/bin/php5-cgi" at the end of the file to point to your new PHP binary.
If that doesn't work, let us know what error(s) you get. Be sure to take a look in $HOME/logs/error_log for any errors.
I have added a phpinfo.php script to the public_html directory for that domain. When I call up that file in a browser, the phpinfo shows the php info of the Ubuntu installation of php5.3
From a shell if run /opt/php-5.2.17/bin/php phpinfo.php I get the php5.2 info.
The above php5.cgi is the only configuration file I have changed.
That may mean that your website isn't executing that particular script. Make sure that your website is configured to use CGI or fcgid, using mod_php wouldn't work for what you need. You can configure all that within Server Configuration -> Website Options -> PHP Execution Mode.
I will write up a howto - but before I do, what are the escapes to put code into this forum?
What I did discover is that one has to disable mod_php site-wide, and then run php5.2 as CGI, not FCGI, then edit the /home/sitename/cgi.bin/php5.cgi file after chattr -i php5.cgi
I needed to run 1 site on my Ubuntu 10.04 LTS server running under php5.2. I did not want to downgrade my entire server to run php5.3. This is how to go about it:
Compile and install php5.2 on the server in an alternate location.
This may also complain about other libraries not installed - install any of those it complains about and re-run configure after installing each one it complains about until configure runs cleanly.
Now make and install:
make
make test
sudo make install
The resulting php build will be located in /opt/php-5.2.17
From the Virtualmin web interface locate the virtual server to run php5.2 and change it to run in CGI mode using Server Configuration -> Website Options -> PHP script execution mode
Edit the php5.cgi file located in the cgi-bin directory of the virtual server so the last line reads:
exec /opt/php-5.2.17/bin/php-cgi
NOTE: Under Virtualmin, the above file has the immutable attribute set, so prior to editing the file, issue the command: sudo chattr -i pgp5.cgi and after editing the file sudo chattr +i php5.cgi
I'm very interested that users could change their PHP versions by themselves through .htaccess file. What is the easyiest way if server is set up by following this tutorial? Can it be done without rebooting Apache?
Thank you.
So nobody knows how to switch between PHP with .htaccess? I have tried various ways and combinations but none of them was successful. I notice that most hosting companies offer to insert to .htaccess file lines like these:
To switch to PHP 5.0: AddHandler application/x-httpd-php5 .php .php5 .php4 .php3 To switch to PHP 5.1: AddHandler application/x-httpd-php51 .php .php5 .php4 .php3
.....
.....
As I understood this method is only valid if I will use CGI mode. For FCGI it is not valid.
What files should be changed if we want to activate specific PHP version through .htaccess?
Any help will be very appriciated.
me too! looking all over, only wha ti can find is for virtualhosts and that doesnt work in the .htaccess (FileMatch throws errors and nothing without it(
No, I still missing a solutions. Every time I change path to necessary php version in php5.cgi file by myself. It's not convienent. A lot of hosting companies offer such functionality through .htaccess. I don't understand why is that not working in Virtualmin environment... Does anybody find a solution?
Howdy,
Unfortunately, there isn't an easy way to do this.
There are some hard ways, but they're, well, pretty hard :-)
You'd need to manually compile a PHP version (or create your own set of .deb's), install it into a custom location, and then in $HOME/cgi-bin (or fcgi-bin), edit the php5.cgi file for the domain that should be using the other version, and change the PHP path.
And then from there, you have to take care to keep your custom PHP version up to date, or you could end up with security issues.
I'd personally suggest not trying to install two PHP versions side-by-side, but if it's really something you'd want, it should work :-)
-Eric
I have compiled and created a new php5.2, which is located in /opt/php-5.2.17/bin. I am just not sure how to get this to work properly - I have tried putting a cgi version into the correct places, however, it does not work correctly!
What you'd need to do is edit the php5.cgi file in the domain's cgi-bin or fcgi-bin directory, and change the path of "/usr/bin/php5-cgi" at the end of the file to point to your new PHP binary.
If that doesn't work, let us know what error(s) you get. Be sure to take a look in $HOME/logs/error_log for any errors.
-Eric
Hi, been away for a while. Getting back to this issue, I have edited the php5.cgi file for the domain and it is now as follows:
I have added a phpinfo.php script to the public_html directory for that domain. When I call up that file in a browser, the phpinfo shows the php info of the Ubuntu installation of php5.3
From a shell if run /opt/php-5.2.17/bin/php phpinfo.php I get the php5.2 info.
The above php5.cgi is the only configuration file I have changed.
Hamish
That may mean that your website isn't executing that particular script. Make sure that your website is configured to use CGI or fcgid, using mod_php wouldn't work for what you need. You can configure all that within Server Configuration -> Website Options -> PHP Execution Mode.
-Eric
I have managed to get it working at last
I will write up a howto - but before I do, what are the escapes to put code into this forum?
What I did discover is that one has to disable mod_php site-wide, and then run php5.2 as CGI, not FCGI, then edit the /home/sitename/cgi.bin/php5.cgi file after chattr -i php5.cgi
Thanks for the pointers
To quickly insert code into a text line, enclose it in
backticks ("`")
For multi-line code blocks, use the tags
[code]...codeblock...[/code]
.I needed to run 1 site on my Ubuntu 10.04 LTS server running under php5.2. I did not want to downgrade my entire server to run php5.3. This is how to go about it:
Compile and install php5.2 on the server in an alternate location.
Log in to the server as a regular user
Download the source:
wget http://www.php.net/distributions/php-5.2.17.tar.bz2
Extract the tarball:
You will also probably need to install some development libraries, the ones I required are listed below:
Run configure:
This may also complain about other libraries not installed - install any of those it complains about and re-run configure after installing each one it complains about until configure runs cleanly.
Now make and install:
The resulting php build will be located in /opt/php-5.2.17
Copy the php.ini file to the correct location
Ensure that apache2 is not running with mod_php
From the Virtualmin web interface locate the virtual server to run php5.2 and change it to run in CGI mode using Server Configuration -> Website Options -> PHP script execution mode
Edit the php5.cgi file located in the cgi-bin directory of the virtual server so the last line reads:
NOTE: Under Virtualmin, the above file has the immutable attribute set, so prior to editing the file, issue the command:
sudo chattr -i pgp5.cgi
and after editing the filesudo chattr +i php5.cgi
Now restart Apache
I'm very interested that users could change their PHP versions by themselves through .htaccess file. What is the easyiest way if server is set up by following this tutorial? Can it be done without rebooting Apache? Thank you.
So nobody knows how to switch between PHP with .htaccess? I have tried various ways and combinations but none of them was successful. I notice that most hosting companies offer to insert to .htaccess file lines like these:
To switch to PHP 5.0:
AddHandler application/x-httpd-php5 .php .php5 .php4 .php3
To switch to PHP 5.1:
AddHandler application/x-httpd-php51 .php .php5 .php4 .php3
..... ..... As I understood this method is only valid if I will use CGI mode. For FCGI it is not valid. What files should be changed if we want to activate specific PHP version through .htaccess? Any help will be very appriciated.
Thanks.
me too! looking all over, only wha ti can find is for virtualhosts and that doesnt work in the .htaccess (FileMatch throws errors and nothing without it(
did you find a solution?
No, I still missing a solutions. Every time I change path to necessary php version in php5.cgi file by myself. It's not convienent. A lot of hosting companies offer such functionality through .htaccess. I don't understand why is that not working in Virtualmin environment... Does anybody find a solution?
Use PHPFARM from GIT. Very simple install and you can run diferent PHP over CGI.
How about this http://www.virtualmin.com/documentation/web/multiplephp
and this one http://alanthing.com/blog/2013/07/11/creating-php-packages-software-coll...
At the recheck config step though Virtualmin is not recognizing my second php...