How can i install PHP?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @remadaria,
Depending on the OS and the OS version installation could be different as well as using a different Web Service (Apache/Nginx)
Ubuntu 16.04
If you are using Apache as your Web Server, you’ll need to install PHP and Apache PHP model, to install them run the following command
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
To further read upon that, I’ll recommend you to check this DigitalOcean Article - HERE
Nginx does not contain native PHP processing like some other Web Servers, you will need to install php-fpm, which stands for “fastCGI process manager”. We will tell Nginx to pass PHP requests to this software for processing.
The installation will pull in the necessary PHP core files. Do this by typing:
sudo apt install php-fpm php-mysql
There is actually a pretty good guide written by DigitalOcean again - HERE
Ubuntu 18.04
Similar to Ubuntu 16.04 in the 18.04 version is installed by
sudo apt install php libapache2-mod-php
To further read upon that, you can check this DigitalOcean article - HERE
For Nginx, the same as mentioned above about 16.04, can be said here. The same command can be executed here as well
sudo apt install php-fpm php-mysql
Of course there is a relevant DigitalOcean article here as well - HERE
CentOS 7
Similar to the above examples with the only exception that in CentOS as opposed to Ubuntu we use yum instead of apt, to install PHP we use
sudo yum install php php-mysql
Again, to further read upon the matter, you can check the following article - HERE
If you are using Nginx as a Web Service on a CentOS machine, you’ll need to run the following
sudo yum install php php-mysql php-fpm
Please check this article, again in the DigitalOcean database for more information - HERE
If you by any chance use anything Different than Apache or Nginx like Debian, there is a section for that too in the mentioned articles.
Regards, KDSys
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.