Nginx is quickly overtaking Apache as the favorite web server. For web apps built in languages like Rails and Python it’s virtually ubiquitous, but it’s a bit slower to catch on in the PHP world. Part of the reason for that is how easily PHP and Apache go together. However, PHP and Nginx can cooperate nearly as easily, and with the release of PHP 7, combining the two can be a fairly speedy option.
- Nick Congleton
The PackagesFirst thing’s first. Update Ubuntu and get the the Nginx and PHP packages.
# sudo apt-get update && sudo apt-get -y upgrade # sudo apt-get -y install nginx php7.0 php7.0-fpmWhen the installation is finished, the packages should all be in place, and actually running. To make sure that this is the case, you can check that both Nginx and the PHP-FPM services are running in Systemd.
# sudo systemctl status nginx # sudo systemctl status php7.0-fpmIf Systemd confirms that both services are running, the server should actually be up, and you should be able to see the default Nginx welcome page by navigating to
localhostin the browser.