ubuntu – My Nginx server does not work

I have an Apache server on Ubunu 18.04 with a Drupal 8 site that I want to migrate to Nginx and PHP7.3-FPM.

This is the only site on the server. I do not know Nginx at all. The site works with Apache but not with Nginx.

I've deleted Apache with the following command:

sudo apt autoremove --purge apache2 *

Here is the configuration I had on Apache:


   
   
   
   ServerAdmin contact@s1biose.com
ServerName s1biose.com
ServerAlias ​​www.s1biose.com
Protocols h2 http / 1.1
DocumentRoot / var / www / www-s1biose-com / web /

   
      Options + Includes -Indexes + FollowSymLinks
AllowOverride All
Require all granted
   

   
      
      
      
      SetHandler "proxy: unix: /var/run/php/php7.3-fpm.sock | fcgi: // localhost /"
   

   ErrorLog $ {APACHE_LOG_DIR} /error.log
CustomLog $ {APACHE_LOG_DIR} /access.log combined

Here's how I installed Nginx:

sudo apt install nginx
sudo ufw allow in "Nginx HTTP"

I test the IP address of my server and the Nginx page is displayed.

sudo unlink / etc / nginx / sites-enabled / default

Here is my Nginx configuration:

sudo nano / etc / nginx / sites-available / www-s1biose-com

server {
listen to 80;
listening [::]: 80;
servername s1biose.com www.s1biose.com;

root / var / www / www-s1biose-com / web;
index.html index.php;

location / {
try_files $ uri $ uri / = 404;
}
location ~  .php $ {
include snippets / fastcgi-php.conf;
include fastcgi_params;
fastcgi_pass unix: /run/php/php7.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
}
}

I create a symbolic link of my new configuration:

sudo ln -s /etc/nginx/sites-available/www.s1biose.com / etc / nginx / sites-enabled /

I test my configuration:

sudo nginx -t

This message is displayed:

nginx: the syntax of the /etc/nginx/nginx.conf configuration file is ok
nginx: the configuration file /etc/nginx/nginx.conf succeeded

If I enter the s1biose.com URL of my site, the following message will appear:

enter the description of the image here

When I go to the IP address of the site, I have this message:

404 Not Found nginx / 1.14.0 (Ubuntu)

sudo ss -tnlp

Status Local Address Q-Q Q-Shipping: Port Peer Address: Port
LISTEN 0 80 127.0.0.1:3306 0.0.0.0:* users: (("mysqld", pid = 5833, fd = 20))
LISTEN 0 128 0.0.0.0:80 0.0.0.0:* users: (("nginx", pid = 17289, fd = 6), ("nginx", pid = 17281, fd = 6), ("nginx", pid = 17280, fd = 6))
LISTEN 0 128 127.0.0.53% lo: 53 0.0.0.0:* users: (("systemd-resol", pid = 702, fd = 13))
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users: (("sshd", pid = 903, fd = 3))
LISTEN 0 100 0.0.0.0:25 0.0.0.0:* users: (("smtpd", pid = 17394, fd = 6), ("master", pid = 1432, fd = 13)
LISTEN 0 128 51.68.41.141:2812 0.0.0.0:* users: (("monit", pid = 897, fd = 6))
LISTEN 0 50                            [::ffff:127.0.0.1]: 7983 *: * users: (("java", pid = 1062, fd = 48))
LISTEN TO 0 128                                         [::]: 80                                 [::]: * users: (("nginx", pid = 17289, fd = 7), ("nginx", pid = 17281, fd = 7), ("nginx", pid = 17280, fd = 7))
LISTEN 0 128 *: 8080 *: * users: (("node / var / www / w", pid = 4281, fd = 11))
LISTEN TO 0 128                                         [::]: 22                                 [::]: * users: (("sshd", pid = 903, fd = 4))
LISTEN 0 50 *: 8983 *: * users: (("java", pid = 1062, fd = 125))
LISTEN 0 100                                         [::]: 25                                 [::]: * users: (("smtpd", pid = 17394, fd = 7), ("master", pid = 1432, fd = 14))