Whats the best way to setup multiple PHP versions + NGINX on macOS? - php

I'm really struggling with multiple PHP versions on macOS (my local workstation).
Currently, I have a website written in PHP 5.6 that is hosted in NGINX. In the past days, I was using LAMPP (php 5.6) to start apache and PHP. But I had some issues because NGINX isn't exactly the same as Apache.
So I wanted to have a more realistic workstation... Today I installed the NGINX and PHP 5.6 (and php-fpm) on my mac, but I didn't work properly then I uninstalled everything and I'm trying again.
Anywaaaaays: whats the best way to set up my local machine and have both PHP 5.6, PHP 7.2 and NGINX?

You should take a look at docker, seriously it so easy and you can run containers with different versions
https://hub.docker.com/_/php/

If you are using a Mac, try using MAMP (https://www.mamp.info)
They have option to use NGINX server. see attached screenshot

Related

Is there a way to switch PHP version between 7.4 and 8.0 without making changes to Environment Variables?

My current environment is:
PHP7.4
Windows 10
WAMP
I want to work on different projects but both are on different PHP versions. I face a hurdle in changing the environment files. Is there a way to simply change the PHP version from the WAMP server?
Thanks in Advance!

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.

Do I still need XAMP with php version 5.6

I am returning to php after a long time (although I have a very basic understanding of php in general), and understand that I can run a php server locally by running the command now with version 5.6:
php -S localhost:8080
Do I still need to install XAMP or WAMP as many of the online tutorials are suggesting or am I okay to just use the above command?
Note: I have postgresql installed on my computer already and do not use mysql, if that matters at all
You need a webserver which you prefer depends on you. XAMPP is the most used for private but you could also take a look at BigApache, EasyPHP, PHPTriad, MampServer, WampServer.
Xampp is a combination of below
Apache server
Mysql server
PHP
and others.
This is a pretty famous and most used package. But if you want to install everything manually then thats even better you can control your server in any way you want. Go for it and you will learn more about it.
If you want a very flexible development environment you need to use a package like EasyPHP Devserver (http://www.easyphp.org/) or equivalent.

How to install different version of PHP (7 & 5.6) on Local WAMP server

Currently I have installed PHP 5.6 on my Local windows 7 machine (x64). I have Manually installed PHP, Apache (2.4), MySQL and configured them to build my development server.
Now, I want to learn and test PHP 7, therefore I wanted to install it from http://windows.php.net/qa/ and configure it in such a way so that I can easily switch between PHP 5.6 and 7.
Unfortunately, I couldn't find any clear information regarding this.
I am seeking help to setup my development environment, so that I can use multiple version of PHP including the latest PHP 7 RC.
There are few option to do this
Install wamp on your drive and keep another one as Protable
Use two different servers. wamp and XAMPP(Note xampp still not upgrade to php-7 / 2015-10-13)

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.

Categories