Installing PHP7.3-FPM on Linux Mint + NGĩn (ok)
If you’re using Nginx Web Server, you’ll need to install php7.3-fpm for serving PHP pages.
Last updated
If you’re using Nginx Web Server, you’ll need to install php7.3-fpm for serving PHP pages.
Last updated
How to install Nginx, PHP 7.3 LEMP Stack on Ubuntu 18.04 LTS with Google Compute Engine and connect with Cloud SQL.
Not using Ubnt 18.04 LTS? Choose a different OS:
Ubuntu 18.04 LTS
CentOS 7
The installation is mostly done via command line so I assume you are comfortable using command line interface.
Comfortable using LINUX command line interface
Your Compute Engine Instance running.
For setting up Compute Engine, see the Setting up Compute Engine Instance
Domain name is pointed to your virtual machine.
For setting up Cloud DNS, see the Setting up Google Cloud DNS for your domain
Go to Compute Engine >> VM Instances page, here you will have your instances listed. Click the SSH button to launch the terminal in a new browser window.
Although you have just created your new instance, it is likely that some software packages are out of date. Let’s make sure that you are using the latest software packages.
Once completed let’s update all the installed packages. You will be prompted with the selection to start the update. Hitting Y
and Enter
will begin the process.
Once the upgrade is completed you can proceed to install Nginx
Once complete, you can confirm that Nginx has been installed by issuing this command
Visit your domain in your browser, you will see the Nginx welcome page.
Now you can secure your instance by setting up firewall and Fail2ban.
The firewall provides an additional layer of security to your instance by blocking inbound network traffic. The ufw (Uncomplicated Firewall) package is usually installed by default in Ubuntu 18.04 LTS, so we need to just add the rules which deny all incoming traffics and allow all outgoing traffics. We now add the ports for SSH (22)
, HTTP (80)
, HTTPS (443)
.
t
Next, open the Nginx configuration file, which can be found at /etc/nginx/nginx.conf
Start by setting the user to the username
that you’re currently logged in with. This will make managing file permissions much easier in the future.
The worker_processes directive is the amount of CPU cores your instance. In my case, this is 1
.
Uncomment the multi_accept directive and set it to on
.
Lower the keepalive_timeout directive to 15
.
For security reasons, you should uncomment the server_tokens directive and ensure it is set to off
.
Add the new client_max_body_size directive below the server_tokens and set the value to 64m.
Uncomment the gzip_proxied directive and set it to any
, uncomment the gzip_comp_level directive and set it to the value of 2
and finally uncomment the gzip_types directive.
In order for Nginx to correctly serve PHP you also need to ensure the fastcgi_param SCRIPT_FILENAME
directive is set, otherwise, you will receive a blank white screen when accessing any PHP scripts. So open fastcgi_params file by issuing
Add the following at the end of the file
That’s all, this is the basic Nginx configuration, hit CTRL+X
followed by Y
to save the changes. Ensure that the configuration file contains no errors and restart Nginx for the changes to take effect by issuing the following command
If you get a successful message, then proceed with the following command
If everything worked out fine, you should still be able to see the Nginx welcome page when visiting your domain in the browser. However, unless visiting a known host the server should return a 444 response. So, we remove the default server blocks from Nginx.
Now you need to add a catch-all block to the Nginx configuration. Open the nginx.conf
file
Find the line with include /etc/nginx/sites-enabled/*;
Below this line add the following
Hit CTRL+X
followed by Y
to save the changes and then test the Nginx configuration and restart Nginx.
Now when you visit the domain name you should receive an error.
From here you can setup Nginx server blocks configuration for your website.
After the installation has completed, confirm that PHP 7.3 has installed correctly with this command
Now that PHP 7.3.* has installed and you need to configure the user and group that the service will run under.
Change the following lines by replacing the www-data with your username
.
Now we configure PHP for WordPress by changing some values in php.ini
.
Hit F6 for search inside the editor and update the following values
Hit CTRL+X
and Y
to save the configuration and check if the configuration is correct and restart PHP
Now you can create Nginx configurations for different web applications
Now we have completed NGINX and PHP 7.3 in Ubuntu 18.04 LTS.
Learn How to connect your Google Compute Engine with Cloud SQL database