预编译排错思路及案例
案例一
checking for OS
- Linux 3.10.0-1160.el7.x86_64 x86_64
checking for C compiler … not found
./configure: error: C compiler cc is not found
- 当预编译出现该报错时,表示没有C编译器,需要安装C编译器
- 使用yum安装即可yum install gcc gcc-c++
[root@localhost nginx-1.22.1]# ./configure --prefix=/usr/local/nginx/ --user=www --group=www --with-http_stub_status_module
checking for OS
+ Linux 3.10.0-1160.el7.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
[root@localhost nginx-1.22.1]#
案例二
- 在预编译出现该报错时,表示缺少pcre,需要安装pcre
- 使用yum安装即可yum install pcre pcre-devel
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
[root@localhost nginx-1.22.1]#
案例三
- 预编译中出现该报错时,表示缺少zlib,需要安装zlib
- 使用yum安装即可yum install zlib zlib-devel
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
[root@localhost nginx-1.22.1]#
案例四
- nginx安装完成后,启动时出现以下报错;原因是缺少logs目录,无法存放nginx日志
- 解决方法创建logs目录并授权,即可解决
[root@localhost nginx]# /usr/local/nginx/sbin/nginx
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory)
2022/12/28 14:20:38 [emerg] 16966#0: open() "/usr/local/nginx/logs/access.log" failed (2: No such file or directory)
[root@localhost nginx]# ls
auto CHANGES.ru conf contrib html Makefile objs README scgi_temp uwsgi_temp
CHANGES client_body_temp configure fastcgi_temp LICENSE man proxy_temp sbin src
[root@localhost nginx]# mkdir logs
[root@localhost nginx]# chmod 700 logs
[root@localhost nginx]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost nginx]# /usr/local/nginx/sbin/nginx
[root@localhost nginx]#
nginx测试页面无法访问
排错思路
- 首先进入到部署nginx的路径检查软件是否齐全,然后检查selinux是否已关闭,查看防火墙是否关闭或端口是否已放行
- 查看进程是否已经起来,再查看端口是否为80端口
部署dicuz论坛页面报错排查思路
案例一:页面无法访问
- 首先排除网络问题,打开客户端(windows、Linux)ping域名对应的IP地址
- 如果网络没问题,则使用telnet去测试端口
- 检查服务器80端口,防火墙对外开放情况
- 检查服务器web服务状态是否运行
#使用telnet检查域名端口,发现端口不通
[root@localhost html]# telnet discuz.sunlit.net 80
Trying 192.168.100.112...
telnet: connect to address 192.168.100.112: Connection refused
[root@localhost html]#
#查看80端口是否已经开启
[root@localhost html]# ps -ef | grep nginx
root 4401 1 0 10:52 ? 00:00:00 nginx: master process /usr/local/ngin/sbin/nginx
www 17535 4401 0 14:31 ? 00:00:00 nginx: worker process
root 17785 1571 0 17:06 pts/0 00:00:00 grep --color=auto nginx
[root@localhost html]# netstat -tnlp | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4401/nginx: master
#看到端口是正常开启的,则通过本机环回地址telnet端口,结果测试通
[root@localhost html]# telnet 127.0.0.1 80
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
#通过本机环回地址telnet测试端口正常,表示服务征程端口却无法向外发布,检查本机防火墙
[root@localhost html]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens32
sources:
services: dhcpv6-client ssh
ports: #防火墙端口字段空白,表示没有放行任何端口
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
#添加防火墙放行80端口规则,重新加载后再查看
[root@localhost html]# firewall-cmd --add-port=80/tcp --permanent
success
[root@localhost html]# firewall-cmd --reload
success
[root@localhost html]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens32
sources:
services: dhcpv6-client ssh
ports: 80/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
[root@localhost html]#
案例二:页面出现database error报错
- 查看是否有MySQL的进程和端口,首先确保数据库服务正常运行
- 如果有数据库的进程和端口存在,则检查该网页的安装时指定的域名和IP是否有指定错
案例三:迁移数据库后网站无法打开
- 数据迁移到新数据库后,网站无法打开
- 查看配置文件中的字段,看数据库配置信息是否存在有误
- 尝试关闭浏览器清理缓存,重新打开网站
- 如果清理缓存后不行,就有可能是权限问题,查看数据库用户权限
- 如果看到网站对接数据的用户权限已经有了,则刷新一下权限即可
#但查看到网站对接数据库的用户权限已经有了
mysql> use mysql
Database changed
mysql> select user,host,authentication_string from mysql.user where user='discuz';
+--------+------+-------------------------------------------+
| user | host | authentication_string |
+--------+------+-------------------------------------------+
| discuz | % | *7BB96B4D3E986612D96E53E62DBE9A38AAA40A5A |
+--------+------+-------------------------------------------+
1 row in set (0.00 sec)
mysql>
mysql> flush privileges;
PS:一般这种故障现象与nginx和PHP没什么关系