How To Set Up PHP on Ubuntu

You must set up the following first before following this instruction.
Setting Up PHP on a server
  1. SSH into your server
  1. Install PHP
  • Add the repository containing the mainline version.
sudo add-apt-repository ppa:ondrej/php -y
  • Update the package lists.
sudo apt-get update
  • Install the package.
sudo apt-get install php7.1-fpm php7.1-common php7.1-mysqlnd php7.1-xmlrpc php7.1-curl php7.1-gd php7.1-imagick php7.1-cli php-pear php7.1-dev php7.1-imap php7.1-mcrypt -y
  • Confirm that PHP has been installed.
Check version.
php-fpm7.1 -v
Screen Shot 2017-03-20 at 5.44.56 PM.png
  1. Configure PHP
We’ll run a single PHP pool under your user account.
  • Edit the default pool configuration file.
sudo nano /etc/php/7.1/fpm/pool.d/www.conf
Set the following settings to your username, e.g. alex
user = alex group = alex listen.owner = alex = alex
  • Edit the php.ini file.
sudo nano /etc/php/7.1/fpm/php.ini
Change the following lines to match the value you assigned to the client_max_body_size setting when configuring Nginx.
upload_max_filesize = 64M post_max_size = 64M
Stop PHP to attempt to execute the closest matching file.  
  • Check that the configuration file syntax is correct.
sudo php-fpm7.1 -t
  • If the configuration test was successful, restart PHP.
sudo service php7.1-fpm restart
  • Check PHP and Nginx are running under the correct user.
Press SHIFT M.
You should see occurrences of both nginx and php-fpm. If not, go back and check the configuration, and ensure that you have restarted both the Nginx and PHP-FPM services.


  1. Manually setting up a DigitalOcean droplet and installing PHP stack on it takes a lot of time. I would instead recommend this method of setting up PHP on DigitalOcean ( ). This way you can save time and instead work on developing your application.


Post a Comment

Popular posts from this blog

How To Set Up Quasar v0.14 On A Laravel+Vue Framework

How To Set Up Quasar v0.13 On A Laravel(5.4)+Vue Framework

How To Fix Random Disappearing Of HTML Elements On iPhone/iPad