Je ne peux même pas démarrer nginx avec l'erreur suivante.
#redémarrer nginx
sudo systemctl restart nginx
#Lorsque j'utilise cette commande, j'obtiens l'erreur suivante.
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
Quant au contenu de l'erreur, nginx n'a pas pu être exécuté. "systemctl status nginx.service" et "journalctl -xe" Veuillez noter les détails.
[root@localhost www]# sudo systemctl -l status nginx.service
● nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code)depuis l'arbre 2020-08-13 15:42:14 JST; 5s ago
     Docs: http://nginx.org/en/docs/
  Process: 2591 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)
13 août 15:42:11 localhost nginx[2591]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
13 août 15:42:12 localhost nginx[2591]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
13 août 15:42:12 localhost nginx[2591]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
13 août 15:42:13 localhost nginx[2591]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
13 août 15:42:13 localhost nginx[2591]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
13 août 15:42:14 localhost nginx[2591]: nginx: [emerg] still could not bind()
13 août 15:42:14 localhost systemd[1]: nginx.service: control process exited, code=exited status=1
13 août 15:42:14 localhost systemd[1]: Failed to start nginx - high performance web server.
13 août 15:42:14 localhost systemd[1]: Unit nginx.service entered failed state.
13 août 15:42:14 localhost systemd[1]: nginx.service failed.
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) L'erreur ici indique que le port 80 est déjà utilisé et ne peut pas être exécuté. Vérifiez donc ce qui est utilisé sur le port 80.
sudo lsof -i :80
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
httpd   2776 apache    4u  IPv6  25135      0t0  TCP *:http (LISTEN)
httpd   2777 apache    4u  IPv6  25135      0t0  TCP *:http (LISTEN)
httpd   2778 apache    4u  IPv6  25135      0t0  TCP *:http (LISTEN)
httpd   2779 apache    4u  IPv6  25135      0t0  TCP *:http (LISTEN)
httpd   2780 apache    4u  IPv6  25135      0t0  TCP *:http (LISTEN)
httpd   2781 apache    4u  IPv6  25135      0t0  TCP *:http (LISTEN)
Je voulais l'ouvrir avec nginx, mais apache occupait le numéro 80. Désinstallez donc apache.
sudo yum remove -y httpd apr apr-util httpd-tools
#Redémarrez nginx
sudo systemctl restart nginx
#Enregistrement de démarrage automatique de nginx
systemctl enable nginx
Vous devriez maintenant pouvoir démarrer nginx.
Enfin, vous pouvez utiliser la commande nginx -t pour vérifier si la syntaxe du fichier de configuration nginx est correcte.
nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
An error occurred.
Sorry, the page you are looking for is currently unavailable.
Please try again later.
If you are the system administrator of this resource then you should check the error log for details.
Faithfully yours, nginx.
Tout d'abord, regardez le journal des erreurs pour confirmer et clarifier la cause.
Étant donné que le journal des erreurs est /var/log/nginx/error.log ou /var/log/php-fpm/error.log,
cat /var/log/nginx/error.log
2020/08/13 16:26:10 [crit] 2867#2867: *2 connect() to unix:/var/run/php-fpm/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.0.97, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "192.168.168.90"
2020/08/13 16:26:10 [error] 2867#2867: *2 open() "/var/www/html/favicon.ico" failed (2: No such file or directory), client: 192.168.0.97, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.168.90", referrer: "http://~~/"
/var/www/html/favicon.ico" failed L'erreur qu'il n'y a pas d'icône est due car cela n'a rien à voir avec l'ouverture du navigateur
connect() to unix:/var/run/php-fpm/php-fpm.sock failed Une erreur s'est produite car le fichier de socket unix ne peut pas être reçu. Cela peut être résolu en réécrivant le fichier de configuration php-fpm.
Le fichier de configuration est généralement situé ci-dessous, alors ouvrons-le.
vi /etc/php-fpm.d/www.conf
Si la ligne suivante est commentée avec ;, supprimez-la.
Cela s'ouvre généralement.
Recommended Posts