CentOS安装LNMP步骤
注意: 要安装wget工具
Cannot find a valid baseurl for repo: base/7/x86_64
cd /etc/sysconfig/network-scriptsls -a
vi ifcfg-en文件
修改ONBOOT=yes,重启服务器网络service network restart
-
MysqL安装
完成后,MySQL默认安装到/var/lib/mysql目录下。
systemctl start mysqld # 启动 MySQLsystemctl enable mysqld # 开机启动ySMySQL
-
安装Nginx
若有安装Apache,先卸载
- service httpd stop
- systemctl disable httpd
- yun remove httpd
再安装Nginx并且设置为开机启动
- yum install epel-release
- yum -y install niginx
- systemcrl start nginx #启动nginx
- systemctl enable nginx #开机启动
开放CentOs防火墙端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
-
安装PHP7.*
-
配置PHP-FPM
-
配置Nginx
- Nginx 的配置文件是:/etc/Nginx/Nginx.conf,使用 vi 打开
- 根据情况调整worker_processes和keepalive_timeout
- 设置默认主页index index.PHP index.html index.htm;
-
location ~ \.PHP$ { try_files $uri =404; fastcgi_pass unix:/var/run/PHP-fpm/PHP-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_index index.PHP; include fastcgi_params; }
- 重启Nginx
Nginx -t # 检查配置文件语法 systemctl reload Nginx
-
TCP链接