I can't even start nginx with the following error.
#restart nginx
sudo systemctl restart nginx
#When I use this command, I get the following error.
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
As for the error content, nginx could not be executed. "systemctl status nginx.service" and "journalctl -xe" Please write down the details.
[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)since tree 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)
August 13 15:42:11 localhost nginx[2591]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
August 13 15:42:12 localhost nginx[2591]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
August 13 15:42:12 localhost nginx[2591]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
August 13 15:42:13 localhost nginx[2591]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
August 13 15:42:13 localhost nginx[2591]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
August 13 15:42:14 localhost nginx[2591]: nginx: [emerg] still could not bind()
August 13 15:42:14 localhost systemd[1]: nginx.service: control process exited, code=exited status=1
August 13 15:42:14 localhost systemd[1]: Failed to start nginx - high performance web server.
August 13 15:42:14 localhost systemd[1]: Unit nginx.service entered failed state.
August 13 15:42:14 localhost systemd[1]: nginx.service failed.
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) The error says that port 80 is already in use and cannot be executed. So check what is being used on 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)
I wanted to open it with nginx, but apache was occupying number 80. So uninstall apache.
sudo yum remove -y httpd apr apr-util httpd-tools
#Restart nginx
sudo systemctl restart nginx
#Automatic start registration of nginx
systemctl enable nginx
Now you should be able to start nginx.
Finally, you can use the nginx -t command to check if the syntax of the nginx configuration file is correct.
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.
First, look at the error log to confirm and clarify the cause.
The error log is /var/log/nginx/error.log or /var/log/php-fpm/error.log, so
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 The error that there is no icon is through because it has nothing to do with opening the browser
connect() to unix:/var/run/php-fpm/php-fpm.sock failed An error is occurring because the unix socket file cannot be received. This can be solved by rewriting the php-fpm configuration file.
The config file is usually located below, so let's open it.
vi /etc/php-fpm.d/www.conf
If the following line is commented out with;, delete it.
This usually opens.