以下是CentOS LNMP环境的常用命令,涵盖服务管理、配置检查、日志查看等核心操作:
Nginx
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl status nginx
nginx -t
MySQL
sudo systemctl start mysqld
sudo systemctl stop mysqld
sudo systemctl restart mysqld
sudo systemctl status mysqld
sudo mysql_secure_installation
PHP-FPM
sudo systemctl start php-fpm
sudo systemctl stop php-fpm
sudo systemctl restart php-fpm
sudo systemctl status php-fpm
Nginx配置
sudo vi /etc/nginx/nginx.conf
nginx -t
sudo nginx -s reload
MySQL配置
sudo vi /etc/my.cnf
mysql --help | grep "my.cnf"
日志查看
tail -f /var/log/nginx/access.log
tail -f /var/log/nginx/error.log
tail -f /var/log/mysqld.log
资源监控
top
、htop
、vmstat
、iostat
netstat -tuln
或 ss -tuln
LNMP状态检查
ps aux | grep php-fpm
lsof -i :80
(查看Nginx端口)wget http://soft.vpser.net/lnmp/lnmp0.5.tar.gz
,然后运行安装脚本。说明:部分命令需根据实际安装路径调整(如源码编译安装的Nginx路径可能为/usr/local/nginx
),建议优先使用systemctl
管理服务的启动、停止和重启操作。