Come risolvere i problemi con Apache/NGINX dopo aver riavviato il tuo server con Plesk

Problemi al riavvio del server (Plesk, Apache, Centos, NGINX)

Mi è capitato diverse volte di avere problemi con il servizio NGINX dopo un riavvio del server, a volte mi capita anche di doverlo avviare o spegnere affinché il mio server possa tornare a funzionare correttamente. Insomma questo server inverso, perché in questo modo è utilizzato, per quanto potrebbe  sostituire del tutto Apache, fa più danno che utile. Cercando in rete mi sono imbattuto in un articolo, che riporto di seguito tradotto, in cui spiega come NGINX dia problemi all’autore dopo il riavvio del server e come questi problemi possano risolversi, o facendo un riavvio “gracefully”, oppure eliminando del tutto questo servizio dal Plesk.

Come risolvere i problemi con Apache/NGINX dopo aver riavviato il tuo server con Plesk

Plesk-LogoAlcuni dei miei server hanno la strana abitudine di buttar fuori un errore di Apache dopo un riavvio: NGINX sta funzionando bene, ma Apache non può essere avviato e tutti i siti Web non sono attivi. Non ho idea del motivo per cui alcuni server lo fanno e altri no. Ma quando lo fanno, è semplicemente fastidioso.



Ecco due modi per risolvere questo problema.

Riavviare Apache “con grazia”

L’opzione più rapida è quella di arrestare NGINX, riavviare Apache, dire di farlo “con garbo” e quindi richiamare nuovamente NGINX. Ecco i comandi che funzioneranno su CentOS 7:

systemctl stop nginx.service
systemctl restart httpd.service
apachectl graceful
systemctl restart nginx.service
Allo stesso modo, su CentOS 6 possiamo usare il comando service per fare la stessa cosa:
service nginx stop
service httpd restart
apachectl graceful
service nginx restart

Se ti capita di farlo molto, prova a scrivere uno script veloce con i comandi sopra riportati, o riavvia il tuo server meno spesso (a volte è sufficiente riavviare Plesk, o non riavviare affatto la macchina). In alternativa, è possibile rimuovere NGINX del tutto ed evitare tali problemi in futuro.


Removing NGINX from Plesk

NGINX non è necessario – Apache farà un buon lavoro da solo. Se si desidera eliminarlo completamente, andare su Strumenti e Impostazioni (o sulla scheda Server se si è in modalità Power User) e selezionare Aggiornamenti e aggiornamenti. Verrai indirizzato all’Installer di Parallels. Seleziona Aggiungi / Rimuovi componenti.

NGINX is not necessary – Apache will do a good job by itself. If you want to get rid of it completely, head over to Tools and Settings (or the Server Tab if you’re in Power User Mode) and select Updates and Upgrades. You’ll be taken to the Parallels Installer. Select Add/Remove Components.

Screen Shot 2015-04-21 at 08.10.45

Scroll down to the NGINX section under Web Hosting Features and untick both NGINX options. Now click Continue at the bottom and NGINX will be removed, leaving Apache in charge for all website connections. There’s no need to restart Plesk.

Screen_Shot_2015-04-21_at_08_11_17

Why would anyone want to use both NGINX and Apache together?

Very good question indeed. Both are excellent web servers, and logic dictates that you should use one or the other. Using two web servers together is a certain sign of trouble.

From what I understand, NGINX is not designed to be a replacement web server in Plesk (even though NGINX can be used in this way on a LAMP Stack). Instead it is implemented as an enhancement to Apache, sitting in front of it. Static files are therefore served from NGINX via Apache, and NGINX acts as a reverse proxy server.

The benefits are faster connections and a smaller memory footprint. Read more about how NGINX and Apache are implemented in Plesk in the following article:

https://docs.plesk.com/it-IT/onyx/administrator-guide/server-web/server-web-apache-e-nginx-linux/apache-con-nginx.70837/




Lascia un commento