View Discussion Show
Improve Article Save Article View Discussion Improve Article Save Article In this article, we will learn about running two versions of PHP on the same Apache server. To manage many domains, the Apache webserver uses virtual hosts on a single instance. Prerequisite: We will be using the XAMPP server to use the Apache server and some knowledge to use it. First, download the older version of XAMPP that can be of any version. The old version is XAMPP 1.8.2 and then later we install the latest version of the XAMPP. Both versions of the XAMPP will have the same apache server. Steps:
Configure the file httpd CONF file to change the port for the new XAMPP. As two different versions of XAMPP cannot run on the same port, we need to change to the port. Steps to change the port for the XAMPP1_8_2: Open the file HTTP CONF file > change the port from the 80 to 8080.
Note: You may face some problem with the port of 3306. Change the port 3306 to 3307 Steps to change port:
Setting up a server can be a daunting task, especially when installing languages like PHP. If you want to get a WordPress test server up and running, it’s a necessary skill to learn. Got no idea where to start to get PHP on your server? Depending on your unique setup, there are many ways to do it. Where do you download PHP, which version, what do you need to make it work, and how do you install PHP on various OSes? We’ll answer them all in this one-stop PHP installation guide. Let’s begin! Check out our video guide to installing PHPWhat is PHP?PHP logoPHP is an open source scripting language primarily used for web development and server-side (backend) scripting. In simple terms:
It’s also one of the easiest web scripting languages to learn, making it a popular choice for beginners. But it’s also quite powerful and suitable for advanced website functions. Many websites and tools use PHP and its many extensions (.NET, Apache, and MySQL may sound familiar). WordPress is built primarily on PHP, and most of its plugins and themes also run on it. Does Your Server Need PHP?So you know what PHP is, but why should you install it on your server? The most notable reason is that it’s a requirement to get WordPress up and running, as it’s built almost exclusively on PHP. PHP also powers most WordPress functions, hooks, themes, and plugins. You can see all the other WordPress system requirements here: WordPress requirementsSo, if you want to run a WordPress test server to play around with or set up a staging site, you’ll need to install PHP. Besides that, PHP is a great launching point for beginner devs. It’s straightforward to use compared to other web scripting languages, but that doesn’t come at any expense of functionality. You can do all sorts of things with it if you’re skilled enough. PHP is also quite popular. So, you can find plenty of extensions and resources online. Besides that, if you want to learn to code WordPress themes and plugins, you’ll need to learn PHP. Setting up a test server is a great way to experiment. Do note that many web hosting servers (such as Kinsta) come preinstalled with PHP and WordPress. Kinsta even includes the ability to create a WordPress staging site, so that’s easy to get at too. The only reason you’ll need to do this manually is if you’re setting up a server from scratch, either on your local computer or in an unmanaged hosting environment. That said, let’s get into the server setup instructions. PHP PrerequisitesBefore installing PHP, you’ll need to make sure your server can handle it. Luckily, the requirements are fairly basic, and a lot of the software is likely already installed on your computer. If you’ve never created a server before, you should check out this guide to set up a local server on multiple OSes. The exact specifics vary depending on your operating system, but you should know how to work with the command line and be ready to install new software. Whatever operating system you’re installing PHP on, you’ll need a web server to run it. You’ll also likely need to install a database like MySQL, so keep that in mind. Here are the PHP prerequisites for each OS, starting with Linux:
You should also be familiar with navigating Unix-like OSes already. Now the PHP requirements for Windows:
Lastly, there are no prerequisites for macOS because PHP comes bundled with the system. We’ll explain how to enable it below. Where to Download PHPIf you need to download the PHP files manually, you should get them from the official site’s PHP downloads page. Avoid installing it from third-party sites unless you know they’re safe, as downloading files from third-party sites can lead to accidentally installing malware. If you’re downloading for a Windows machine, look for the “Windows downloads” link in each version of PHP and make sure you’re installing the proper files. You can also install older versions of PHP, but this is not recommended unless you know what you’re doing, as they expose your server to bugs and major security flaws. If you’re running a Linux distribution, you usually don’t need to get the files through the website, and you should use the command line. We’ll go over that in detail below. Which PHP Version Should I Use?If you’ve clicked that download link above, you’re likely looking at all those files and feeling overwhelmed. Which PHP version is the right one? Generally speaking, if you’re starting a brand new project where compatibility issues aren’t a problem, you should get the latest stable version of PHP. It is sometimes possible to download beta versions of PHP, which are even newer, but these are often buggy and only released to help the developers gather feedback. Most of the time, you should stick with the stable releases. What about older versions? Every PHP version comes with new features, but that means new incompatibilities with older features. If you need to do something specific that{s not supported on the latest PHP version, you can use an older version, but you should stick only with the currently supported versions. If you’re not sure, then use the latest version of PHP. Take note that WordPress is only compatible with certain versions of PHP. It technically supports PHP versions starting at 5.6.20+, but these are quite old and thus not recommended. Versions 7.2 to 7.4 are currently the best-supported versions for WordPress. PHP version 8 is also compatible, but currently, this is very new, and not all plugins work properly. If you’re worried about compatibility issues, stick with PHP version 7.4. You can read our PHP benchmarks post to see how various PHP CMSes and frameworks perform on different PHP versions. How to Install PHP on LinuxBefore starting, you should be familiar with the Terminal and how to operate Unix-like OSes in general. Generally, these command line codes should work on any Linux distribution that uses the normal syntax in the Terminal, but we’ve left some notes below for specific OSes. First, you should make sure your packages are up to date, so run this Linux command in the Terminal.
Now you’re ready to install PHP. The command to do so is effortless and straightforward.
Installing PHP via terminalThis will install the latest version of PHP along with several extensions. You can use this code to see which version you have.
What if you want to install a specific version of PHP, such as PHP 7.4? You’ll need to use a PPA, or Personal Package Archive, by Ondřej Surý. This is a safe way to install older supported versions of PHP. Run these three commands one at a time:
Now your system recognizes the archive, and you can install PHP 7.4. Type in the following command:
And of course, you can replace this number with whatever PHP version you want. That covers the basics, but if you need extra help with configuration, the PHP installation documentation for Unix can help. Installing PHP on UbuntuFor Ubuntu users, there aren’t many specific concerns as long as you follow the guide above. Ubuntu is one of the most popular distributions, so most Linux guides are practically made for that system. One alternative option available to you is downloading a LAMP stack. LAMP stands for Linux, Apache, MySQL, and PHP. It’s essentially a bundle of all the software you need to get a server up and running. While you can manually download each of these tools separately, you could get Taskel, a bundle that will install all these at once. Just run these two commands in succession in the Terminal: Installing LAMP stack with Taskel via terminalInstalling PHP on CentOS 7This operating system is a little different from other Linux distributions. On CentOS, the apt and apt-get commands are not the ideal ways to install the software. Instead, it uses yum, Yellowdog Updater Modified, a better package manager for RHEL-based operating systems. Otherwise, the commands you’ll need to use are pretty similar. To update your packages, run this command instead:
As for other commands, you can usually replace
PHP commands such as Installing PHP on DebianLast for Unix-like operating systems is Debian. This time there are just a few minor concerns, but most of the commands listed above should work fine. For Debian, you can use either So instead of using the usual
Debian can be finicky. If you find PHP isn’t parsing or extensions aren’t working, make sure you’ve updated your server’s web configuration file and that it’s loading the extension ini files. Besides a
few small things, instructions for Debian are practically identical to those for other Linux distributions. How to Install PHP on WindowsIf you’re using a Windows system, unlike macOS and Linux, you don’t need to install PHP through the command line (though it is an option if you’d prefer). An easy way to install PHP from here is to enable IIS and then use WebPI to install PHP. After launching WebPI, you can find it under the Products tab. Click Add on the version you want, then click Install. Enabling IIS on WindowsYou can also download PHP for Windows and manually configure it to work with IIS. Make sure to get a non-thread-safe version if you’re using IIS. If all this is too complicated, you could instead install WampServer or XAMPP, as these come with everything you need to start working with a web server: Apache, a database, and of course PHP. These instructions will work with most modern Windows OSes such as Windows 10, 7, and Vista. If you’re using an older version of Windows, you should check out the legacy Windows installation documentation. Windows may need a little extra configuration to get PHP working properly, so make sure to check the recommended Windows configuration documentation. You just have to make a few small ini tweaks. How to Install PHP on macOSPHP comes preinstalled on most macOS systems, so you usually don’t need any manual installation. All you need to do
is uncomment a few lines of code in the Apache configuration file httpd.conf, which you can usually find at
You may need to do extra configuration if you don’t like some file settings’ default values. Otherwise, find the DocumentRoot, then create and load a PHP file with this code:
You can always check the PHP version with the If you do need to download PHP manually, then you should install Homebrew and use this simple command:
All About PHP ExtensionsOnce you’ve got PHP up and running, it’s a good idea to think about extensions. These compiled libraries add all sorts of extra, helpful functionality. Think of them as plugins that add on to what PHP already offers. Some of these are required to run PHP frameworks, such as Laravel and Symfony. While it’s completely possible to code everything yourself without ever touching an extension, there’s no reason to do it all on your own when widely-used shortcuts exist to make your life easier. PHP already comes with dozens of built-in extensions, some of which you must enable manually, and others you can start using right away. You can also install PHP extensions through sites like PECL, which hosts hundreds of third-party packages. The PHP manual offers extension documentation for many of these as well, so you can get the hang of using them. Not sure where to start? Here are just a handful of a few popular PHP extensions:
Whenever you install an extension, you need to uncomment it. Just open up
php.ini and remove the semicolon (;) in front of You should also check out these PHP frameworks if you’d like to standardize your code and build with premade libraries. They’re a great way to get started with developing web applications with PHP. SummaryWhatever operating system you’re using, installing PHP isn’t such a hard process. If you want to make a WordPress test server, you’ll need it. Aspiring PHP programmers will find setting up a web server and installing PHP on it a great exercise. Make sure you download PHP either through the command line or from its official site. You can either get the latest stable version of PHP or any other version compatible with WordPress. And if you’d like to get started with developing WordPress sites right away, you can try DevKinsta! It comes with PHP preinstalled. It also lets you hot-swap between different PHP versions so that you can test your site in different server environments. Save time, costs and maximize site performance with:
All of that and much more, in one plan with no long-term contracts, assisted migrations, and a 30-day-money-back-guarantee. Check out our plans or talk to sales to find the plan that’s right for you. How do I download an older version of PHP?If you need a rollback of PHP, check out the app's version history on Uptodown. It includes all the file versions available to download off Uptodown for that app. Download rollbacks of PHP for Windows. Any version of PHP distributed on Uptodown is completely virus-free and free to download at no cost.
How do I download PHP version?Follow the below steps to install PHP on Windows: Step 1: Visit https://www.php.net/ website using any web browser and click on Downloads. Step 2: Click on the Windows “Downloads” button. Step 3: The new webpage has different options, choose the Thread safe version, and click on the zip button and Download it.
Is PHP 5.6 still supported?December 31, 2018 marks the official end of security support for PHP 5.6, this means there will be no… December 31, 2018 marks the official end of security support for PHP 5.6, this means there will be no further updates to the software. PHP 7.0 was released in December 2015 and PHP 7.1 was released December of 2016.
Is PHP 7.1 still supported?PHP 5.6, 7.0, 7.1, and 7.2 End of Life
End of life means these versions will no longer have security support and could be exposed to unpatched security vulnerabilities. As of November 30, 2020, PHP 7.2 reached its end of life. As of December 1st, 2019, PHP 7.1 reached its end of life.
|