Skip to main content
Image for post: Running multiple PHP versions with Ampps

Running multiple PHP versions with Ampps

I have my local PHP and MySQL installation but I wanted to switch the PHP from the 5.6 version to 7. This was not an easy task and even PHPBrew was not helping me to tell Apache and the CLI what PHP version it has to run. So I have tried Ampps, a software for running the LAMP stack on Windows, Linux and Mac. It works great but there are some steps to follow.

Download Ampps

Download Ampps file for Linux. You will have a single file but you must rename it adding _64 on x86 if you are running a 64 bit operative system on your computer. To see the informations about the architecture just type


uname -a

Execute the run file

Go to the directory where you have downloaded the file, give it the right permissions with chmod and execute it with sudo. So you will have:


cd /download/location
chmod 0755 Ampps-<version>-<arch>.run
./Ampps-<version>-<arch>.run

Run Ampps

If you have a local installation of Apache and MySQL, you have to stop them or you will have conflicts when you will run them from the Ampps control panel. They are different so in this case you will have a duplicate of the same softwares on the Ampps installation directory. They will search the same port and the service will not start. If you want to keep only the Ampps copies, you can remove the local PHP. Apache and MySQL installations. I recommend to wait until all is ok and then you can choose to remove them or not. Put your files on the /usr/local/ampps/www directory, give it the right permission to the files and\or the directory and you are ready to work. Many web applications need 777 permissions to work locally. You can create a file with a phpinfo() and see if Ampps is switching from different PHP versions when you select it from the control panel.

Stop local Apache and MySQL and run Ampps with a shell script

I have created a small script to stop local services and run Ampps instead. You have to execute the Ampps file from its directory, otherwise it will not work!


# Stop local Apache and MySQL
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/mysql stop
# Start Ampps executing the file from its directory
cd /usr/local/ampps/
./Ampps

If you stop using Ampps and you want to come back to your local Apache, PHP and MySQL you can stop Apache and MySQL from the Ampps control panel and then start them again manally. I have prepared this script to remember how to start or stop Ampps Apache and MySQL services manually if you prefer. The control panel is not perfect so you may need to act manually if you have any problems.


# Stop Ampps Apache
sudo /usr/local/ampps/apache/bin./httpd -k stop
/usr/local/ampps/mysql/bin/mysqld stop
# Re-Start local Apache and MySQL services
sudo /etc/init.d/apache2 start
sudo /etc/init.d/mysql start

Softaculous

Softaculous is inclued in Ampps. If you access http://localhost/ampps/index.php from your browser, you will have the access to the Softaculous web interface where you can make all operations. If you have a 404 error, remember to start Apache and MySQL from the Ampps control panel.

Conclusions

Finally PHP7 is working and I am happy. You can check any update for new PHP 7 build and versions and see if you can update the 7th version. For now I think it's better to try the default version and play with the new PHP features.

Resources

Share this post

This website and/or any sub domains use cookies to understand how you to improve your experience.