LNMP环境搭建

 

主要环境:

Linux 7.5 +  Nginx 1.14.0 + Mysql 5.7.23 + PHP 7.2.10

安装环境的思路:装包,配置,启服务,

这里,我全部用yum进行安装。


环境准备

关闭selinux

vim /etc/selinux/config

SELINUX=disabled

  重启服务器,查看是否成功

getenforce

 


配置yum仓库

nginx,mysql的yum源仓库文件

https://github.com/Lin-KFou/LNMP-install/blob/master/include/yum.repos.d/nginx.repo

https://github.com/Lin-KFou/LNMP-install/blob/master/include/yum.repos.d/mysql5.7.repo

配置php仓库源:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

安装nginx  myslq php 7.2

yum install nginx

yum install myslq-community-server

yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml

    注意:

        在安装mysql的时候,不要直接 yum install mysql可能会导致错误,从而导致启动不了服务,此时就需要删除已经安装了的mysql-community-release,之后再通过 yum install mysql-community-server就能够恢复正常


修改配置文件

nginx的配置文件,由于与nginx1.12 有点区别

所以在修改配置文件时把各自网页的配置文件单独放在: /etc/nginx/conf.d

nginx的默认配置文件:/etc/nginx.conf

yum安装nginx,在解析php页面的时候,需要fcgi.cnf。

好像默认安装在配置文件目录里面没有此文件需要创建:/etc/nginx/fcgi.cnf

mysql的配置文件: /etc/my.cnf

php的配置文件:/etc/php-fpm.conf    /etc/php-fpm.d/www.conf

配置文件参考 

https://github.com/Lin-KFou/LNMP-install/tree/master/include/conf


启动服务

nginx -t        #检查nginx配置文件是否正确
systemctl start nginx
systemctl enable nginx
systemctl start php-fpm
systemctl enable php-fpm
systemctl start mysqld.server
systemctl enable mysqld.server

#查看软件版本和系统版本
php -v
nginx -V
mysql -V

#查看服务状态 
ss -tnulp | grep nginx
ss -tnulp | grep php-fpm
ss -tnulp | grep mysqld 

搭建测试网页

测试网页的配置文件

vim /etc/ngixn/conf.d/test.conf

参考位置:https://github.com/Lin-KFou/LNMP-install/blob/master/include/conf/nginx/test.com.conf

书写网页内容

vim /home/www/sites/test.php

参考位置:https://github.com/Lin-KFou/LNMP-install/blob/master/include/index.php

配置host文件:

浏览器进行访问

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Richie-Hao

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值