《走进科学》灵异事件:Nginx配置改了之后一直报错

2024-02-09 11:36

本文主要是介绍《走进科学》灵异事件:Nginx配置改了之后一直报错,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

想要安装WoWSimpleRegistration,就定下来要用nginx+php8 ,结果nginx那里加上php的支持之后一直报错:

$ sudo service nginx restart
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.

最灵异的地方就是:将配置恢复成今天修改之前的,还是同样的报错。简直是《走进科学》IT版。

当然用sudo systemctl status nginx.service看,报错还是不一样的。

自己写php配置后的报错:

× nginx.service - A high performance web server and a reverse proxy serverLoaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)Active: failed (Result: exit-code) since Thu 2024-02-08 07:53:31 UTC; 11s agoDocs: man:nginx(8)Process: 47195 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)CPU: 28msFeb 08 07:53:31 ub systemd[1]: Starting A high performance web server and a reverse proxy server...
Feb 08 07:53:31 ub nginx[47195]: nginx: [emerg] unexpected end of file, expecting ";" or "}" in /etc/nginx/conf.d/wow>
Feb 08 07:53:31 ub nginx[47195]: nginx: configuration file /etc/nginx/nginx.conf test failed
Feb 08 07:53:31 ub systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Feb 08 07:53:31 ub systemd[1]: nginx.service: Failed with result 'exit-code'.
Feb 08 07:53:31 ub systemd[1]: Failed to start A high performance web server and a reverse proxy server.

现在恢复配置之后的报错:

× nginx.service - A high performance web server and a reverse proxy serverLoaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)Active: failed (Result: exit-code) since Thu 2024-02-08 06:33:07 UTC; 1h 9min agoDocs: man:nginx(8)Process: 29162 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)Process: 29163 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)CPU: 86msFeb 08 06:33:05 ub nginx[29163]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
Feb 08 06:33:05 ub nginx[29163]: nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
Feb 08 06:33:06 ub nginx[29163]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
Feb 08 06:33:06 ub nginx[29163]: nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
Feb 08 06:33:06 ub nginx[29163]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
Feb 08 06:33:06 ub nginx[29163]: nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
Feb 08 06:33:07 ub nginx[29163]: nginx: [emerg] still could not bind()
Feb 08 06:33:07 ub systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Feb 08 06:33:07 ub systemd[1]: nginx.service: Failed with result 'exit-code'.
Feb 08 06:33:07 ub systemd[1]: Failed to start A high performance web server and a reverse proxy server.

这样就看明白了,是80端口绑定报错。然后脑子突然在线了,是不是今天调试的时候,把apache安装上去了? 打开本地页面http://127.0.0.1 ,果然是apache的页面。原来这就是nginx恢复配置也无法启动的原因啊! 

把apache服务停掉:sudo systemctl stop apache2

然后再开nginx的服务:sudo service nginx restart

没有报错了! 好,现在开始调试php吧!

再仔细看php的报错:

skywalk@ub:/etc/nginx$ journalctl -xeu nginx.service 
Feb 08 10:30:55 ub nginx[49977]: nginx: configuration file /etc/nginx/nginx.conf test failed
Feb 08 10:30:55 ub systemd[1]: nginx.service: Control process exited, code=exited, status=1/F>
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ An ExecStartPre= process belonging to unit nginx.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 1.
Feb 08 10:30:55 ub systemd[1]: nginx.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The unit nginx.service has entered the 'failed' state with result 'exit-code'.
Feb 08 10:30:55 ub systemd[1]: Failed to start A high performance web server and a reverse pr>
░░ Subject: A start job for unit nginx.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit nginx.service has finished with a failure.
░░ 
░░ The job identifier is 7021 and the job result is failed.

使用nginx -t查看:

$ sudo nginx -t
nginx: [emerg] unexpected end of file, expecting ";" or "}" in /etc/nginx/conf.d/wow.conf:18
nginx: configuration file /etc/nginx/nginx.conf test failed

定位到18行 ,但是没有问题啊,括号是成对的啊,所有的语句后面都有分号。

再仔细查看,发现最后第18行,有一个“~”字符,由于它跟vi的显示字符一样(颜色不同),误以为第18行是空行,将其删除,ok拉!

现在http服务器起来了,但是php服务还没起来。 手动写index.php 文件,结果没执行,被下载下来了

怀疑是php-fpm服务没有起来,手工起,结果失败:

sudo systemctl start php-fpm
Failed to start php-fpm.service: Unit php-fpm.service not found.

先查看apt有没有安装

$ sudo apt list |grep fpmWARNING: apt does not have a stable CLI interface. Use with caution in scripts.libfpm-helper0/jammy 4.2-2.3 amd64
libintelrdfpmath-dev/jammy 2.0u2-4 amd64
mono-fpm-server/jammy,jammy 4.2-2.3 all
php-fpm/jammy,jammy,now 2:8.1+92ubuntu1 all [installed]
php8.1-fpm/jammy-updates,jammy-security,now 8.1.2-1ubuntu2.14 amd64 [installed,automatic]
php8.1-fpm/jammy-updates,jammy-security 8.1.2-1ubuntu2.14 i386

再查看service

$ sudo systemctl list-units --type=service | grep phpphp8.1-fpm.service                                                                        
loaded active running The PHP 8.1 FastCGI Process Manager

启动:

$ sudo systemctl start php8.1-fpm

现在php-fpm总算启动了

php8.1-fpm.service │ ├─17901 php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)│ ├─17904 php-fpm: pool www│ └─17905 php-fpm: pool www

发现这条语句没有: fastcgi_index  index.php;  

加上之后照旧,就像php没有起来一样。

比着这个来一下:

location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}

现在的浏览器报错是:403 Forbidden

又问了一遍文心一言,这回对该回答比较满意,只修改了域名了目录,一次过!

server {listen 80;server_name wow.airoot.org;root /var/www/;  index index.php index.html index.htm;location / {  try_files $uri $uri/ =404;}  location ~ \.php$ {  fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;  # 根据你的 PHP-FPM 配置修改  fastcgi_index index.php;  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;  }  location ~ /\.ht {deny all;  }  
}

现在把wow reg下载到目录,

配置好后,提示:Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.2.0".

当前版本:PHP 8.1.2

升级到8.2 并不太顺利,当前apt包里是没有的,网上找到的操作:

sudo dpkg -l | grep php | tee packages.txt
sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
sudo apt install php8.2 php8.2-cli php-8.2{bz2,curl,mbstring,intl}sudo apt install php8.2-fpm
# OR
# sudo apt install libapache2-mod-php8.2sudo a2enconf php8.2-fpm# When upgrading from older PHP version:
sudo a2disconf php8.1-fpm## Remove old packages
sudo apt purge php8.1*

安装的时候提示:

CAVEATS:
1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
2. If you are using apache2, you are advised to add ppa:ondrej/apache2
3. If you are using nginx, you are advised to add ppa:ondrej/nginx-mainline
   or ppa:ondrej/nginx

新版本浏览器报错:

502 Bad Gateway

看/var/nginx/error.log :

024/02/09 01:38:13 [crit] 40709#40709: *1 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.0.107, server: wow.airoot.org, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "wow.airoot.org"
~                                                           

是php-fpm文件没有改过来。

将conf文件中fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;修改为fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;

报错没有文件:

启动php8.3-fpm :

sudo systemctl start php8.3-fpm

这时候打开http://wow.airoot.org/html/index.php页面是空白,源代码里空。

这样估计有点正常了。将php的测试文件test.php

 <?php
phpinfo();?>

放入根目录,测试通过.

查看WoWSimpleRegistration手册:

  • Fulfill the above prerequisites on your server.

  • Obtain the project files:

    • Download and unzip the project, or clone it using Git:
      git clone https://github.com/masterking32/WoWSimpleRegistration
      
  • Navigate to the application/config/ directory and rename the file config.php.sample to config.php.

  • Edit the newly renamed config.php file, inserting your server details. Note that if using the "Image Captcha" feature, PHP's GD2 module must be enabled.

  • Once configuration is complete, your registration page should be operational.

下面配置文件就行了。

这篇关于《走进科学》灵异事件:Nginx配置改了之后一直报错的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/694119

相关文章

Zookeeper安装和配置说明

一、Zookeeper的搭建方式 Zookeeper安装方式有三种,单机模式和集群模式以及伪集群模式。 ■ 单机模式:Zookeeper只运行在一台服务器上,适合测试环境; ■ 伪集群模式:就是在一台物理机上运行多个Zookeeper 实例; ■ 集群模式:Zookeeper运行于一个集群上,适合生产环境,这个计算机集群被称为一个“集合体”(ensemble) Zookeeper通过复制来实现

CentOS7安装配置mysql5.7 tar免安装版

一、CentOS7.4系统自带mariadb # 查看系统自带的Mariadb[root@localhost~]# rpm -qa|grep mariadbmariadb-libs-5.5.44-2.el7.centos.x86_64# 卸载系统自带的Mariadb[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7

hadoop开启回收站配置

开启回收站功能,可以将删除的文件在不超时的情况下,恢复原数据,起到防止误删除、备份等作用。 开启回收站功能参数说明 (1)默认值fs.trash.interval = 0,0表示禁用回收站;其他值表示设置文件的存活时间。 (2)默认值fs.trash.checkpoint.interval = 0,检查回收站的间隔时间。如果该值为0,则该值设置和fs.trash.interval的参数值相等。

NameNode内存生产配置

Hadoop2.x 系列,配置 NameNode 内存 NameNode 内存默认 2000m ,如果服务器内存 4G , NameNode 内存可以配置 3g 。在 hadoop-env.sh 文件中配置如下。 HADOOP_NAMENODE_OPTS=-Xmx3072m Hadoop3.x 系列,配置 Nam

禁止平板,iPad长按弹出默认菜单事件

通过监控按下抬起时间差来禁止弹出事件,把以下代码写在要禁止的页面的页面加载事件里面即可     var date;document.addEventListener('touchstart', event => {date = new Date().getTime();});document.addEventListener('touchend', event => {if (new

wolfSSL参数设置或配置项解释

1. wolfCrypt Only 解释:wolfCrypt是一个开源的、轻量级的、可移植的加密库,支持多种加密算法和协议。选择“wolfCrypt Only”意味着系统或应用将仅使用wolfCrypt库进行加密操作,而不依赖其他加密库。 2. DTLS Support 解释:DTLS(Datagram Transport Layer Security)是一种基于UDP的安全协议,提供类似于

【Python编程】Linux创建虚拟环境并配置与notebook相连接

1.创建 使用 venv 创建虚拟环境。例如,在当前目录下创建一个名为 myenv 的虚拟环境: python3 -m venv myenv 2.激活 激活虚拟环境使其成为当前终端会话的活动环境。运行: source myenv/bin/activate 3.与notebook连接 在虚拟环境中,使用 pip 安装 Jupyter 和 ipykernel: pip instal

沁恒CH32在MounRiver Studio上环境配置以及使用详细教程

目录 1.  RISC-V简介 2.  CPU架构现状 3.  MounRiver Studio软件下载 4.  MounRiver Studio软件安装 5.  MounRiver Studio软件介绍 6.  创建工程 7.  编译代码 1.  RISC-V简介         RISC就是精简指令集计算机(Reduced Instruction SetCom

log4j2相关配置说明以及${sys:catalina.home}应用

${sys:catalina.home} 等价于 System.getProperty("catalina.home") 就是Tomcat的根目录:  C:\apache-tomcat-7.0.77 <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" /> 2017-08-10

DM8数据库安装后配置

1 前言 在上篇文章中,我们已经成功将库装好。在安装完成后,为了能够更好地满足应用需求和保障系统的安全稳定运行,通常需要进行一些基本的配置。下面是一些常见的配置项: 数据库服务注册:默认包含14个功能模块,将这些模块注册成服务后,可以更好的启动和管理这些功能;基本的实例参数配置:契合应用场景和发挥系统的最大性能;备份:有备无患;… 2 注册实例服务 注册了实例服务后,可以使用系统服务管理,