重启Linux系统后关于Nginx/mysql/php重启

重启Linux系统后,配置环境需要重启

重启 Nginx。

重启命令是:
/usr/local/nginx/sbin/nginx -s reload

端口被占用:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

执行杀掉进程:
killall -9 nginx

启动:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

结束

重启mysql

[root@VM_0_16_centos ~]# service mysql restart

启动失败:
ERROR! MySQL server PID file could not be found!

Starting MySQL. ERROR! The server quit without updating PID file (/var/run/mysqld/mysqld.pid).

根据提示,"/var/run/mysqld/mysqld.pid"该路径文件的问题

强制重启系统后导致mysqld/mysqld.pid丢失

创建相关文件
[root@VM_0_16_centos run]# mkdir /var/run/mysqld
[root@VM_0_16_centos run]# vim /var/run/mysqld/mysqld.pid

设置权限
[root@VM_0_16_centos run]# chown -R mysql /var/run/mysqld/
[root@VM_0_16_centos run]# chgrp -R mysql /var/run/mysqld/

[root@VM_0_16_centos run]# chown -R mysql.mysql /usr/local/mysql/
[root@VM_0_16_centos run]# chgrp -R mysql /usr/local/mysql/

再次重启
[root@VM_0_16_centos run]# service mysql restart

ERROR! MySQL server process # is not running!
Starting MySQL. SUCCESS!

重启php

启动php-fpm:

方式一:
/etc/init.d/php-fpm start
重新启动php-fpm:

方式二:
service php-fpm restart

成功后再 重新启动nginx

(如果失败
Failed to start php-fpm.service: Unit php-fpm.service not found. 
往下走):
重新启动nginx
service nginx restart

重新启动nginx

如果没有配置的上面命令执行会失败,使用下面安装路径启动:
/usr/local/nginx/sbin/nginx -s reload

如果已经启动,报错的话,需要杀掉进程再执行:
unable to bind listening socket for address '127.0.0.1:9000': Address already in use (98)

查看进程():
netstat -nldp |grep 9000

返回信息:
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 20016/php-fpm: mast

杀掉进程():
kill 20016

关于9000端口被占用的情况:
正常被php-fpm占用可以通过杀掉进程来解决,
但是如果php-fpm没有进程:

[root@VM_0_17_centos php]# /etc/init.d/php-fpm start
Starting php-fpm [29-Dec-2018 12:25:57] ERROR: unable to bind listening socket for address '127.0.0.1:9000': 
Address already in use (98)
[29-Dec-2018 12:25:57] ERROR: FPM initialization failed
 failed
[root@VM_0_17_centos php]# killall php-fpm
php-fpm: no process found

也就是端口被占用无法启动,但是又没有查询到有进程的死循环状态(php无法访问,报错504 timeout , 但是可以访问静态页面)

本人网上搜索了一下方法,没有成功,
最终选择: 重启系统 !

查看日志中显示子线程不够:
WARNING: [pool www] server reached pm.max_children setting (5), consider raising it

默认安装路径/usr/local/php/etc/php-fpm.d/www.conf里
设置pm.max_children = 300

你可能感兴趣的:(重启Linux系统后关于Nginx/mysql/php重启)