Save 50% for your first year of web hosting!

How to Install Nginx and PHP 7.3 on Debian 10

Just recently on July 6th, 2019, Debian 10 buster released, and with it came a lot of features. This tutorial will show you how you can install Nginx mainline version on Debian 10 for optimal performance.

Step 1: Install Nginx

Firstly we need to install the prerequisites.

sudo apt install curl gnupg2 ca-certificates lsb-release

Then we need to add the Nginx mainline package to our repository so that when we run apt install nginx, we will download the mainline version instead of the old stable version.

echo "deb `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list

Optionally, if you would rather want to use the older and slower stable version of Nginx you can do so by running: (Remember that you should only run one of the following)

echo "deb `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list

Next we need to download the signing key so that we can verify its authenticity

curl -fsSL | sudo apt-key add -

If it prints out OK! then you are good to go!

Now that we have downloaded & verified its authnicity lets install it!

sudo apt update
sudo apt install nginx

That’s it! You have now installed the latest release of Nginx on Debian 10. You should now start it!

sudo systemctl start nginx.service

Don’t forget to make it automaticly start on system boot as well.

sudo systemctl enable nginx.service

Visit your server’s IP address in your webbrowser. You should now see something along these lines if it is working correctly.

Default welcome screen on Nginx

Step 2: Install PHP 7.3

To add the repositories for PHP:

sudo apt-get install software-properties-common

Run this to download your added repositories:

sudo apt update

We can now install PHP now that we have all of the required repositories.

sudo apt install php7.3-fpm php7.3-common php7.3-mysql php7.3-gmp php7.3-curl php7.3-intl php7.3-mbstring php7.3-xmlrpc php7.3-gd php7.3-xml php7.3-cli php7.3-zip php7.3-soap php7.3-imap

It is recommended to raise the memory limit to improve the overall performance. Your PHP configuration is located in/etc/php/7.3/fpm/php.ini.

sudo nano /etc/php/7.3/fpm/php.ini

Press CTRL + W and search for memory_limit.

Replace it with memory_limit = 256

Save & exit by pressing CTRL + X followed by Y

Step 3: Configure Nginx

Add nginx to www-data group

sudo usermod -a -G www-data nginx

Change owner of directory to www-data

sudo chown -R www-data /usr/share/nginx/html

Go into your default.conf file

sudo nano /etc/nginx/conf.d/default.conf

Replace your existing configuration file with the one below

server {
    listen       80;
    server_name  localhost;

    root   /usr/share/nginx/html;
    index  index.php index.html index.htm;

   location / {
    if ($request_uri ~ ^/(.*)\.html$) {
        return 302 /$1;

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
        location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass   unix:/var/run/php/php7.3-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;


Save & exit by pressing CTRL + X followed by Y

Now restart your Nginx:

 service nginx restart

That’s it! However, you may now test to see if php works

nano /usr/share/nginx/html/phpinfo.php

Add the following lines




Save & exit by pressing CTRL + X followed by Y

Now go to YOURSERVERIP/phpinfo.php in your web browser. You should see something along these lines

That’s it! Now you know how to install Nginx and PHP 7.3 on Debian 10. You can now go ahead and install anything you want, such as WordPress. Don’t forget to try out our VPS too! Our servers are located in stockholm, so if you’re from Sweden feel free to check out our Swedish site too, and grab yourself a Stockholm VPS.