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!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
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
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:
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
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
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
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
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