Recently I am working on a WordPress site for a new customer. The client’s server is using PHP5.5.38 which is an old version. The newest version is 7.x.x. However, the client doesn’t want to upgrade the PHP version yet. In order to develop and support smoothly, I need to install PHP 5.5.38 on my localhost. So when I develop, I will be sure nothing will break when I deploy to the client’s server.
For my development environment, I use WampServer 3.0.6. It comes with PHP 5.6.25. In order to add different PHP versions for WampServer, I need to upgrade my WampServer to the newest version first.
Update WampServer
- Download the newest WampServer
- In my case, I need to update to WampServer 3.1.9 (64-bit)
- Visit WampServer Versions
- Download the newest WampServer version. Look at the Wampserver Updates section. In my case, I download Wampserver update 3.1.9
- At your current WampServer, choose “Stop All services”
- If you have the antivirus application, you may disable “Protects Windows hosts files from changes” so the WampServer can write some change in the Windows file without warning or error
- Run the downloaded WampServer update execution file as Administrator – wampserver3_x86_x64_update3.1.9.exe
- When the downloaded file is installed, it will ask for the WampServer folder. You need to check and confirm the downloaded file is installed in the current WampServer folder. In my case, my current WampServer is “d:\wamp64” folder.
- After installation, you must restart the WampServer to see the change
- If the WampServer icon at the taskbar disappears, you will need to run the WampServer application again then you will see the WampServer icon shows up at the taskbar.
- Test by visiting the test sites(http://locahost/example) on your WampServer to see if everything is still working as normal. Also, you should test the test sites that you set as a Virtual host(http://example.com).
Now your WampServer version will change to the newest version that you just download and install. In my case, it shows WampServer 3.1.9.
Install PHP version I want
- At the WampServer Versions, look for the Addons WampServer 3 section.
- Find the PHP section and choose which PHP version you want to install into WampServer 3. In my case, I download PHP 5.5.38.
- Download the file. The file will be the execution file(.exe)
- At your WampServer, stop all services
- Run the downloaded file as an administrator
- Install the downloaded PHP version you want into “D:\wamp64\bin\php” which is the PHP folder in Wampserver
- After installation, you must restart the WampServer to see the change
- If the WampServer icon at the taskbar disappears, you will need to run the WampServer application again then you will see the WampServer icon shows up at the taskbar.
- Test by visiting the test sites(http://locahost/example) on your WampServer to see if everything is still working as normal. Also, you should test the test sites that you set as a Virtual host(http://example.com).
- Finally, if you disable “Protects Windows hosts files from changes” from your antivirus application, you must enable it again.
Install PHPMyAdmin and MySQL
If you want to install other addons such as PHPMyAdmin and MySQL from the WampServer Versions. You must update the WampServer to the newest first(follow the instructions from the WampServer site for updates). Then you can install the addons just like I show you in the steps above.
For MySQL, after installing the MySQL into the Wampserver bin(D:\wamp64\bin\mysql) on your computer. The installed MySQL won’t have any database except the default databases from MySQL.
If you want to import the database from the other MySQL version to your installed MySQL version. First, you want to export the database with the mysqldump command in the terminal. The reason to use the mysqldump command is that it is fast. However, if you feel comfortable with PHPMyAdmin, you can export the database from this tool as well.
Using the mysqldump command, you can set the path in global or you can navigate to your mysqldump command folder in the terminal and run the export and import mysqldump command.
Example of my mysqdump command in the bin folder:
D:\wamp64\bin\mysql\mysql5.6.41\bin
Export specific database via mysqldump command:
mysqldump -u YourUser -p YourDatabaseName > wantedsqlfile.sql
Import your export database SQL file via mysqldump command:
mysql -u username -p database_name < file.sql
And that’s it. Your development will flow and not waste time developing twice or breaking the production server.
If you install the multi-MySQL versions in WampServer, the easy way to find where is the database you want is to look at the “wamp64/bin/mysql/mysql5.7.28/data”. In the data folder, you will find the database folder there.
Here is a sample of WAMPserver after installing PHP and MySQL versions. Simply choose the PHP version or MySQL version you like then WAMPserver will restart automatically.
Install Apache version I want
- At the Wampserver addon, download the apache version you want
- After download, run the downloaded file as an administrator
- In the installing process, it will prompt the wamp server location as “c:\wamp”. You must check your Wampserver location before clicking the next button. In my case, my Wampserver location is in “e:\wamp64”.
- Restart the Wampserver to see the new apache version you installed
- Note, when you switch the apache version at the Wampserver, it will ask you to copy the configuration from the current apache to the new apache. In my case, I always choose “NO”.
Remove addon
If you want to remove the addon that you already installed in WampServer 3, you simply go to the folders that you want to remove. For example, PHP or MySQL or MariaDB or etc under “/wamp64/bin“. Then remove the addon you want then restart all services.
For example, if you want to remove MariaDB 10.5.4 addon, you will go to “your drive/wamp64/bin/mariadb/mariadb10.5.4” on your computer and remove the “mariadb10.5.4” folder. Then restart all services to see the changes. Or you can right-click on the WampServer icon and click on the “Refresh” menu.
Wrap Up
Hopefully, the post is helpful and saves your developing time like mine. Being a freelancer and developing projects for clients requires me to set up multiple environments. Because it is important to develop the project in the same client’s environment. This way, you will develop and test, and then deploy your changes to the production without worrying to break the production server from your codebase. Remember, each PHP version and DB version may give a different result. This is how experience teaches me for two decades as a developer. Well, my post is helpful and saves your time, please consider buying me a coffee for today.