PHP 5.2 and 5.3 together - php

I have XAMPP with PHP 5.2, but my new projects need PHP 5.3
How to have PHP 5.2 and 5.3 together?
I have winXP.

You can do one of the following:
Ensure your older apps can run on 5.3 while not using 5.3 specific features. This is probably the
best route as it will tighten your
code and it will run on more
platforms, especially in the future
when more production environments
use 5.3 only.
If this is for development purposes only you can also consider:
multiple installations
of XAMPP and switch between them
when necessary via simple folder
rename (somewhat tedious)
php-switch (very tedious)
setup two apache servers on the same machine running different PHP versions

You've two choices: run two servers on a different port, or use CGI.
You can get XAMPP with PHP 5.3.1 here: http://www.apachefriends.org/en/xampp-windows.html#641
Edit \xampp\apache\conf\httpd.conf, and change Listen to Listen 8080 for example.
Then run \xampp\apache_start.bat to start that server instance. Optionally, change DocumentRoot to your project directory.

Related

What is the best approach or sustainable for hosting multiple php versions' projects in a server?

I have a new CentOS server, plan to use it for all the php projects, currently i have many php 5.6+ projects & one php 7 project at two different servers. We knew we will upgrade the php version or even mysql version in future, so what is the trend or approaches for hosting different versions of php projects?
Did some researches about Docker & Rancher or install multiple PHP versions in one server and controlled by ngnix. But still not sure which one is the best approach, first option seems need to understand well about dockers or kubernetes, the learning curve will be higher.
Currently Cloud environment is not in my consideration. All these projects are system tool and applications (intranet, CRM), not eCommerce.
You should use PHP via FPM (FastCGI Process Manager), which is available for all recent PHP versions including the older releases like PHP 5.6. This is true at least for Ubuntu when using Ondrej's PPA. I guess there should be a way to achieve parallel PHP installations in CentOS as well.
With FPM you could use Nginx as well as Apache as your webserver. I would recommend Nginx, but it's up to you. There are plenty of tutorials for both of them.
Then, you would configure each virtual host according to your needs to use PHP 5.6 or 7.x respectively. With FPM pools each virtual host can be configured independently, even dedicated php.ini files are no problem.
Have a look at this blog post, which is quite to the point from my personal view.

Multiple PHP / Apache Versions on MacOs

At the moment I'm using two machines for Web (Win10) & iOS development (MacOS) and looking to combine them into a one computer that I would use on a daily basis.
My current challenge is to ensure that I can develop and run two or more environments on the same machine (not necessary at the same time, a simple switch would do the job).
I've tried MAMP and AMPPS and they both do the job, with an exception to the PHP-CLI version.
Every time I run php from the console it opens up the latest version completely ignoring the one that is specified by the MAMP or AMPPS.
What is the best way to ensure that php-cli always points to a currently active version of the PHP as stipulated by MAMP or AMPPS?
On Windows I was using https://ospanel.io/ that had it's own internal terminal window that would automatically load the current version of php-cli.
I am fully aware of docker/vagrant but they would be an overkill in this case.
Thanks
Unfortunately there is no simple answer to my question. As a solution:
Get multiple version installed
Design a script that changes the PATH environment to the right version as required.
alternatively a script that rewrites a symlink to a required version of the PHP.
For MAMP user, you must edit the file /usr/local/etc/httpd/httpd.conf and set the PHP version you prefer to use in your stack. I only installed one version of Apache HTTPD with multiple PHP versions - you have to specify the version.
If you don't, the default is the Mac's pre-installed PHP version.

run php as lower version

I have a local development server and a remote server.
The remote server runs php 5.4, my local server runs XAMPP with php 5.6.
I originally wrote the the php for 5.6, but there are some scripts that produce an error in 5.4.
The obvious solution would be to install XAMPP with php 5.4 locally, but I have multiple site development projects on my computer, some of which which are written in 5.6 and are deployed on 5.6.
Is there a way to make 5.6 at least act like 5.4 so I can test the site locally and find all the errors before deployment?
I thought putting 'AddHandler application/x-httpd-php54 .php' in my root .htaccess might work but it didn't.
There is no way to make 5.6 act like 5.4.
You must have to done changes in your code.
It's impossible.
Think about using virtualization for easy multiple environments.
Vagrant is tool for that, after installation only one command like vagrant up gives you ready to use LAMP server, you can deploy multiple VM with different PHP versions etc.

How to setup PHP nginx development environment with multiple versions of PHP in the right way

I want to develop PHP applications with different PHP requirements especially with Laravel 5.1 (which requires php 5.5.9) and Laravel 4.2 (which requires php 5.4). I want to be able to specify which php version is running per application (I mean per virtual host). There are many articles on the web about that setup with nginx and fastcgi, but it seems to be outdated.
For me the setup from http://coderoncode.com/2014/04/18/flexible-php-development-phpfarm.html is the best and the easiest.

Is there a way to set a different PHP module per Virtual Host?

I'm developing for a bunch of sites on my local machine. Some of those sites ultimately run on php5.3, and some run on php5.2. Is there a way I can setup virtual hosts to use different versions of php for each?
You should be able to manually compile both versions of PHP to separate directories and setup PHP with FastCGI for each website. FastCGI will give you comparible performance to mod_php on apache.
You could also set each one up with CGI. Its a lot slower, but then you can't see how modules like APC will help your code or used shared memory or persistent connections reliable (they will work for just one request)
If that doesn't work, you can make a second install of your webserver, configure it to run on a different port, and then set up your other webserver to act as a proxy, forwarding requests to a specific virtual host to the other webserver.
I am use a denwer. It is a local server. Denwer can be installed many times on one machine or USB. I have 2 denwers on my computer. One with php 5.2. Second with php 5.3.
Either you do as per the above and use different versions of PHP using FastCGI on your machine. But since it's for development, you could also use ie. VirtualBox or VMware server and create 2 virtual machines, one with PHP 5.2 and one with 5.3 (or you could create even more, one per project - that's how I would do it in fact :p).
Possible benefits : you could use the OS - and the same software versions of ie. apache / mysql - that is used on your external host (that's why I would prefer one VM per project). This might also be beneficial when debugging later on.
You could try to run php as cgi. I don't know if it works, you have to pass different php.ini locations to the cgi for things like different temp dirs. Wouldn't recommend it on a production machine.

Categories