nginx.service is not active, cannot reload. and also 503 Service Temporarily Unavailable nginx is showing. Can anyone help

I have installed wordpress through easyengine and getting this issues.

root@fn:~# journalctl -xe | grep nginx Sep 08 04:09:48 fn sudo[24157]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/usr/bin/apt-get install python-certbot-nginx Sep 08 04:10:40 fn sudo[25139]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/bin/nano /etc/nginx/sites-available/default Sep 08 04:11:26 fn sudo[25141]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/bin/nano /etc/nginx/sites-available/default Sep 08 04:11:42 fn sudo[25144]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/usr/sbin/nginx -t Sep 08 04:11:52 fn sudo[25146]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/bin/systemctl reload nginx Sep 08 04:11:52 fn systemd[1]: nginx.service: Unit cannot be reloaded because it is inactive. Sep 08 04:11:58 fn sudo[25149]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/bin/systemctl reload nginx Sep 08 04:11:58 fn systemd[1]: nginx.service: Unit cannot be reloaded because it is inactive. Sep 08 04:15:43 fn sudo[25156]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/bin/systemctl start nginx — Subject: Unit nginx.service has begun start-up — Unit nginx.service has begun starting up. Sep 08 04:15:43 fn nginx[25168]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:15:43 fn nginx[25168]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:15:43 fn nginx[25168]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:15:43 fn nginx[25168]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:15:44 fn nginx[25168]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:15:44 fn nginx[25168]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:15:44 fn nginx[25168]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:15:44 fn nginx[25168]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:15:45 fn nginx[25168]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:15:45 fn nginx[25168]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:15:45 fn nginx[25168]: nginx: [emerg] still could not bind() Sep 08 04:15:45 fn systemd[1]: nginx.service: Control process exited, code=exited status=1 Sep 08 04:15:45 fn systemd[1]: nginx.service: Failed with result ‘exit-code’. — Subject: Unit nginx.service has failed — Unit nginx.service has failed. Sep 08 04:23:57 fn sudo[25266]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/etc/init.d/nginx start — Subject: Unit nginx.service has begun start-up — Unit nginx.service has begun starting up. Sep 08 04:23:58 fn nginx[25285]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:23:58 fn nginx[25285]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:23:58 fn nginx[25285]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:23:58 fn nginx[25285]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:23:59 fn nginx[25285]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:23:59 fn nginx[25285]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:23:59 fn nginx[25285]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:23:59 fn nginx[25285]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:24:00 fn nginx[25285]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Sep 08 04:24:00 fn nginx[25285]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) Sep 08 04:24:00 fn nginx[25285]: nginx: [emerg] still could not bind() Sep 08 04:24:00 fn systemd[1]: nginx.service: Control process exited, code=exited status=1 Sep 08 04:24:00 fn systemd[1]: nginx.service: Failed with result ‘exit-code’. — Subject: Unit nginx.service has failed — Unit nginx.service has failed.

Error can not start nginx

i install:

sudo apt-get install nginx

i try: sudo /etc/init.d/nginx start sudo service nginx start or

nginx -s reload

-> nothing change

root@8eef8e717289:/# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

root@8eef8e717289:/#

root@8eef8e717289:/# sudo /etc/init.d/nginx start

How to avoid restarting nginx to renew letsencrypt certificate?

I have installed a Nginx server to host my website, and added HTTPS with LetsEncrypt.

The problem is every time the certificate expire, my site become inaccessible and I need to manually restart the service using So every two months or so I am forced to manually do a:

sudo service nginx restart 

I tried automating that several time already but failed. My last attempt was using this:

sudo crontab -e   0 0,12 * * * letsencrypt renew >/dev/null 2>&1  1 0,12 * * * root /etc/init.d/nginx reload 

Is this the wrong way? How can I validate this job works without waiting my site to be inacessible again?

NGINX acceder a multiples sitios desde la misma IP

Quisiera saber como puedo tener varios sitios en Nginx y poder acceder a cada uno de ellos con la misma IP (sin el dominio, ya que estoy haciendo pruebas en un laboratorio localmente).

El servidor lo tengo en una PC aparte y accedo remotamente desde mi computadora mediante la IP. Ambos estan en la misma red LAN

En el directorio /var/www/ tengo dos sitios ‘nextcloud’ y ‘phpmyadmin’. Quisiera poder ingresar a ambos colocando (por ejemplo) 192.168.1.14/nextcloud y 192.168.1.14/phpmyadmin. O teniendo cualquier otro proyecto en el directorio www.

Intente todas las soluciones que encontre, pero ninguna de ellas me ha funcionado. Cuando ingreso a phpmyadmin por ejemplo, me da para descargar la pagina en lugar de entrar a ella.

Dentro de /etc/nginx/sites-enabled tengo los dos archivos, uno de nextcloud:

    server {         listen 80 default_server;         listen [::]:80 default_server;          root /var/www/nextcloud/;          index  index.php index.html index.htm;          server_name  localhost;          client_max_body_size 512M;         fastcgi_buffers 64 4K;          location / {             root /var/www/nextcloud;         rewrite ^ /index.php$  request_uri;         }          location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {             deny all;         }         location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {             deny all;         }          location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$  |/) {             fastcgi_split_path_info ^(.+?\.php)(/.*)$  ;             include fastcgi_params;             fastcgi_param SCRIPT_FILENAME $  document_root$  fastcgi_script_name;             fastcgi_param PATH_INFO $  fastcgi_path_info;             fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;             fastcgi_intercept_errors on;             fastcgi_request_buffering off;         }          location ~ ^/(?:updater|ocs-provider)(?:$  |/) {             try_files $  uri/ =404;             index index.php;         }          location ~ \.(?:css|js|woff|svg|gif)$   {             try_files $  uri /index.php$  request_uri;             add_header Cache-Control "public, max-age=15778463";             access_log off;         }          location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$   {             try_files $  uri /index.php$  request_uri;             # Optional: Don't log access to other assets             access_log off;         }     }  

Y la de phpmyadmin:

    server {         listen 80;         listen [::]:80;          root /var/www/phpmyadmin/;          # Add index.php to the list if you are using PHP         index index.php index.html index.htm index.nginx-debian.html;          server_name localhost;          location / {             # First attempt to serve request as file, then             # as directory, then fall back to displaying a 404.             try_files $  uri $  uri/ =404;         }          # pass PHP scripts to FastCGI server         #         location ~ \.php$   {             include snippets/fastcgi-php.conf;         #         #   # With php-fpm (or other unix sockets):             fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;         #   # With php-cgi (or other tcp sockets):         #   fastcgi_pass 127.0.0.1:9000;         }     }  

Probe creando dos carpetas de prueba en /var/www/ (test1 y test2), cada una de ellas con un archivo index.html dentro y modificando el archivo default de nginx, pero tampoco me ha funcionado

    server {         listen 80 default_server;         listen [::]:80 default_server;          server_name localhost;          index index.html;          location / {             return 410;  # Default root of site won't exist.         }          location /test1/ {             alias /var/www/test1/;             try_files $  uri $  uri/ =404;              # any additional configuration for non-static content         }          location /test2/ {             alias /var/www/test2/;             try_files $  uri $  uri/ =404;              # any additional configuration for non-static content         }     }  

Como habia dicho, probe distintas soluciones. Otro problema que tuve fue que solo me redireccionaba a nextcloud, aunque coloque phpmyadmin en la url. Y el anterior que ya mencione, que cuando ingreso, descarga el index.php. Muchas gracias

Lemp stack nginx web server 502 Gateway error

I am setting up a private web server to host some files and a simple web page for my personal usage. I copied an index file into a new index.php and added some pho to it as instructed by nginx documentation, but then deleted the old index.

At first it worked, until I deleted the old one. I thought it was irrelevant but I got the gateway error when trying to login to my localhost.

Where is there a new skeleton index that I can possibly copy over, or did I just need to set proper permissions on my ‘/var/www/html’ directory?

log files with .log extension is getting downloaded instead of opening in the browser with nginx server

I have created a web server using nginx and using it to store log files. When I access any of the .log file, it downloads the file instead of opening it in the browser.

is there any special setting to get the log file open in the browser instead of downloading ?

Multisite wp-admin redirecting to main wp-admin using NGINX

When I try to go to the wp-admin of any multi site, it redirects to the main wp-admin.

So if I go to example.com/multi-site-slug/wp-admin/ it redirects to example.com/wp-admin/

NGINX is being used as a reverse proxy.

I’m using the standard WordPress Multisite Subdirectory rules per the codex: https://wordpress.org/support/article/nginx/

If I take out this line in the conf file rewrite ^(/[^/]+)?(/wp-.*) $ 2 last;, it prevents the redirect but then media assets don’t serve properly on the multisites.

Why is it okay to run NGiNX or Apache Web Server as root on port 80/443 and not your app directly?

Just like the title says, I would like to understand:

  • what are the implications of running a custom app (like node or flask) on port 80/443.
  • Is running a reverse proxy like Nginx mandatory from a security point of view? * What if I run Nginx as root user and we discover a security vulnerability today? Wouldn’t that make the custom app and Nginx both great security risks?
  • What is the most secure (and standard) way to handle traffic on port 80 or 443, if its not Nginx?

How to rewrite store view code in Nginx?

I have some trouble to fix this issue.

I have a Magento 2 installation with two websites and several store views:

https://www.websiteone.com/onenl https://www.websiteone.com/oneen https://www.websiteone.com/onede

https://www.websitetwo.com/twonl https://www.websitetwo.com/twoen https://www.websiteotwo.com/twode

Magento wants every store view code to be unique, so we’ve made them unique.

Now I want to rewrite them to shorter urls like:

https://www.websiteone.com/nl https://www.websitetwo.com/nl

But I’m not able to get it working. I tried several things like:

location /onenl/ { rewrite ^onenl/(.*)?$ nl/$ 1 break; }

or

location /onenl { rewrite ^onenl nl last; }

I or get a 404 CMS page not found from our base store view. Or I get an nginx 404 not found and in this situation I think he doesn’t understand to fire up index.php.

What am I missing? 🙂

Thanks!