启动失败nginx HTTP和反向代理服务器问题



我第一次在我的fedora 24中安装nginx服务器。我使用apache服务器进行开发。仅为office集成,我必须安装nginx服务器。我安装nginx服务器使用这个命令dnf install nginx

在启动nginx服务器之前,我停止了apache并像下面这样禁用了它。

systemctl stop httpd
systemctl disable httpd

如果我启动nginx服务器sudo service nginx start,我得到以下错误。

Redirecting to /bin/systemctl start  nginx.service
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

所以我运行systemctl status nginx.service命令来了解问题的细节,我在我的终端得到以下输出。

[root@localhost ~]# systemctl -l status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2016-10-20 01:45:57 IST; 10s ago
  Process: 10719 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
  Process: 10709 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Oct 20 01:45:57 localhost.localdomain systemd[1]: Starting The nginx HTTP and reverse proxy server...
Oct 20 01:45:57 localhost.localdomain nginx[10719]: nginx: [emerg] no port in upstream "php-fpm" in /etc/nginx/default.d/phpMyAdmin.conf:17
Oct 20 01:45:57 localhost.localdomain nginx[10719]: nginx: configuration file /etc/nginx/nginx.conf test failed
Oct 20 01:45:57 localhost.localdomain systemd[1]: nginx.service: Control process exited, code=exited status=1
Oct 20 01:45:57 localhost.localdomain systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Oct 20 01:45:57 localhost.localdomain systemd[1]: nginx.service: Unit entered failed state.
Oct 20 01:45:57 localhost.localdomain systemd[1]: nginx.service: Failed with result 'exit-code'.

我尝试了几种方法来解决通过改变listen 80 listen 801在/etc/nginx/nginx.conf,但没有问题。我遵循下面的网址也,但我无法解决这个问题。

nginx not started and can't start

https://serverfault.com/questions/717752/cant-start-nginx-code-exited-status-1-failure

/etc/nginx/default.d/phpMyAdmin.conf

# phpMyAdmin
location = /phpMyAdmin {
    alias /usr/share/phpMyAdmin/;
}
location /phpMyAdmin/ {
     root /usr/share;
     index index.php index.html;
     location ~ ^/phpMyAdmin/(.+.php)$
     {
         try_files $uri =404;
         fastcgi_intercept_errors on;
         include        fastcgi_params;
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         fastcgi_pass   php-fpm;  //this is line number 17
     }
}

在我的例子中,这是因为80端口已被占用。

sudo lsof -t -i:80
sudo kill [port in reply]

我也遇到了这个问题,我有一个不同的情况,我确信在我运行这个命令后,我的机器上没有占用端口80:netstat -nplt .

关闭Selinux服务后,问题解决了。

暂时关闭Selinux服务,您应该运行以下命令:

setenforce 0

永久禁用此服务:

vim /etc/selinux/config
Change item from `SELINUX=enforcing` to `SELINUX=disabled`

回答@mattdm建议的问题,我安装了php-fpm,现在它开始工作了。

sudo dnf install php-fpm

如果您已经安装了php-fpm,您应该查找套接字运行的位置并更改这一行fastcgi_pass php-fpm; //this is line number 17

您应该能够在php-fpm池的配置文件中的listen行中找到它。例如,在Ubuntu中,你可以在/etc/php/<version>/fpm/pool.d/www.conf找到它。

你可能可以通过以下命令得到配置的线索:ps aux | grep php-fpm .

最新更新