LNMP环境问题汇总

2017年12月31日21:00:57 发表评论 850 views

第1章 MySQL安装故障小结

1.1 WARNING:The host 'mysql' could not be looked up with resolveip.

【原因】

MySQL无法解析主机名。

【解决】

修改主机名解析即可,使其和uname -n 一样,修改后的结果如下:

[root@web01 ~]# grep `uname -n` /etc/hosts
172.16.1.8      web01

1.2 ERROR:1004 Can't create file '/tmp/#sql300e_1_0.frm' (errno: 13)

【原因】

/tmp目录权限出现问题,默认为1777权限。

【解决】

还原/tmp目录权限:

[root@web01 ~]# ll -d /tmp
drwxrwxrwt. 4 root root 4096 Sep 13 19:58 /tmp
[root@web01 ~]# chmod -R 1777 /tmp/

1.3 ERROR! The server quit without updating PID file (/var/lib/mysql/web01.pid).

【现象】

root@web01 tools]# service mysqld start
Starting MySQL...... ERROR! The server quit without updating PID file (/var/lib/mysql/web01.pid).

【原因】

MySQL的配置文件(/etc/my.cnf)有问题(名字不对或内容不对)。

【解决】

复制默认的配置文件为/etc/my.cnf:

[root@web01 tools]# cp /application/mysql/support-files/my-default.cnf /etc/my.cnf

1.4 MySQL无法登录的故障

【现象】

[root@web01 tools]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:NO)

【原因及解决】

  • 数据库初始化有问题:删除并重新初始化数据库
  • MySQL数据库文件损坏了
  • MySQL数据目录权限问题
  • 检查主机名对应的主机IP解析是否正确

第2章 nginx常见错误说明

2.1 编译环境不完整导致的问题

2.1.1 gcc未安装导致的错误

【现象】

[root@web02 nginx-1.10.3]# ./configure --prefix=/application/nginx-1.10.3 --user=www --group=www --with-http_stub_status_module  --with-http_ssl_module
checking for OS
 + Linux 2.6.32-696.el6.x86_64 x86_64
checking for C compiler ... not found

<strong>./configure: error: C compiler cc is not found</strong>

【解决】
yum install -y gcc

2.1.2 gcc安装不全导致的错误

【现象】

[root@web02 nginx-1.10.3]# make && make install
make all-am
<strong>make[1]: Entering directory `/server/tools/pcre-8.30'</strong>
<strong>  CXX   pcrecpp.lo</strong>
<strong>libtool: compile: unrecognized option `-DHAVE_CONFIG_H'</strong>
<strong>libtool: compile: Try `libtool --help' for more information</strong>
<strong>make[1]: *** [pcrecpp.lo] 错误 1</strong>
<strong>make[1]: Leaving directory `/server/tools/pcre-8.30'</strong>
<strong>make: *** [all] 错误2</strong>

【解决】
yum install -y gcc-c++

2.2 软件依赖包未正确安装问题

2.2.1 PCRE依赖包没有安装

【现象】

<strong>./configure: error: the HTTP rewrite module requires the PCRE library.</strong>
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.

【解决】
yum install -y pcre pcre-devel

2.2.2 OPENSSL依赖包没有安装

【现象】

<strong>./configure: error: SSL modules require the OpenSSL library.</strong>
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

【解决】
yum install -y openssl openssl-devel

2.3 nginx软件启动过程中遇到的问题

2.3.1 nginx软件重复启动产生的错误信息

【现象】

[root@web01 nginx-1.10.2]# /application/nginx/sbin/nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed <strong>(98: Address already in use)</strong>
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

【解决】

nginx软件已经启动无需反复启动,如果需要重新启动需要停止nginx进程或者用reload方式进行重启。

2.3.2 nginx:[emerg] getpwnam("www") failed

【现象】

[root@web02 ~]# /application/nginx-1.10.3/sbin/nginx

<strong>nginx: [emerg] getpwnam("www") failed</strong>

【解决】

由于没有对应的nginx服务用户,产生此错误,执行useradd -s /sbin/nologin -M www用户即可。

2.4 查看以前(或别人安装时)软件编译安装时的配置信息

[root@web01 application]# <strong>nginx -V</strong>
nginx version: nginx/1.10.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/application/nginx-1.10.3 --user=www --group=www --with-http_stub_status_module --with-http_ssl_module

2.5 浏览器、wget或curl等软件无法访问Nginx页面

2.5.1 服务端排查思路

  • 查看SELinux是否关闭:

[root@web02 ~]# getenforce
Disabled

  • 检查防火墙是否关闭:

[root@web02 ~]# service iptables status
iptables: Firewall is not running.

  • 检查本地端口、进程和URL:

[root@web01 ~]# netstat -lntup | grep 80
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      26911/nginx        
[root@web01 ~]# ps -ef | grep nginx
root      26911      1  0 16:34          00:00:00 nginx: master process nginx
www       26989  26911  0 17:10          00:00:00 nginx: worker process
www       26990  26911  0 17:10          00:00:00 nginx: worker process
www       26991  26911  0 17:10          00:00:00 nginx: worker process
root      27230   1375  0 20:21 pts/0    00:00:00 grep nginx

[root@web01 ~]# wget http://10.0.0.8
--2017-09-11 20:21:21--  http://10.0.0.8/
Connecting to 10.0.0.8:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 612 [text/html]
Saving to: “index.html”

100%[==========================>] 612         --.-K/s   in 0s     

2017-09-11 20:21:21 (26.8 MB/s) - “index.html” saved [612/612]

  • 查看错误日志:

[root@web01 ~]# cat /application/<strong>nginx/logs/error.log</strong>
2017/09/11 16:18:23 [error] 26876#0: *1 open() "/application/nginx-1.10.3/html/favicon.ico" failed (2: No such file or directory), client: 10.0.0.253, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "10.0.0.8", referrer: "http://10.0.0.8/"
2017/09/11 16:33:15 [notice] 26904#0: signal process started
2017/09/11 16:34:03 [notice] 26908#0: signal process started
2017/09/11 16:34:03 [error] 26908#0: open() "/application/nginx-1.10.3/logs/nginx.pid" failed (2: No such file or directory)
2017/09/11 16:34:34 [notice] 26909#0: signal process started
2017/09/11 16:34:34 [error] 26909#0: open() "/application/nginx-1.10.3/logs/nginx.pid" failed (2: No such file or directory)
2017/09/11 16:34:57 [notice] 26913#0: signal process started
2017/09/11 17:10:39 [notice] 26988#0: signal process started

2.5.2 客户端排查

  • nginx软件排查问题三部曲说明:
  • 在客户端上ping服务器端IP,检查链路是否通畅

ping 10.0.0.8               #排除物理链路影响

  • 在客户端上telnet服务器端IP、端口,检查链路访问是否通畅

telnet 10.0.0.8 80          #排除防火墙等的影响

  • 在客户端上wget检测模拟页面访问是否正常

wget 10.0.0.8               #模拟用户访问,排除http服务自身的问题,根据输出排错
或
curl -I 10.0.0.8

第3章 PHP安装故障小结

3.1 configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution。

【原因】

没有安装libxslt库造成的。

【解决】

[root@web01 ~]# yum install -y libxslt-devel

3.2 configure: error: Cannot find MySQL header files under /application/mysql/.

【现象】

configure: error: Cannot find MySQL header files under /application/mysql/.
Note that the MySQL client library is not bundled anymore!

【原因】

未安装或安装失败MySQL数据库,导致PHP配置编译的时候无法识别指定的数据库。

【解决】

重新安装MySQL数据库或将配置参数的--with-mysql=/application/mysql/去掉(此时将只支持PHP默认自带的MySQLnd数据库)。

3.3 make[1]: *** [install-pear-installer] Error 127

【现象】

/server/tools/php-5.5.32/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
make[1]: *** [install-pear-installer] Error 127
make: *** [install-pear] Error 2

【原因】

PHP找不到指定的库,一般是相应库的路径不对导致的。

【解决】

[root@web01 php-5.5.32]# ln -s /application/mysql/lib/libmysqlclient.so.18  /usr/lib64/

3.4 make: *** [ext/phar/phar.php] Error 127

【现象】

Generating phar.php
/server/tools/php-5.5.32/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
make: *** [ext/phar/phar.php] Error 127

【原因】

提示不能访问ex/phar/phar.phar这个目录或文件。

【解决】

[root@web01 php-5.5.32]# touch ext/phar/phar.phar

weinxin
我的微信
如果有技术上的问题可以扫一扫我的微信
版权声明
1. 本网站名称:Leon的博客
2. 本站永久网址:https://blog.leonshadow.cn
3. 本网站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系站长QQ632113590进行删除处理。
4. 本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
5. 本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
6. 本站资源大多存储在云盘,如发现链接失效,请联系我们我们会第一时间更新。
liyang