Centos 7.4搭建LNMP环境

一、环境

centos 7.4.1708

mysql 5.7

nginx 1.14

php 7.0

二、准备

1.关闭防火墙

systemctl stop firewalld

2.关闭selinux

vi /etc/selinux/config

setenforce 0 && getenforce 0

三、安装服务

1.安装mysql

1)下载mysql repo源

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

 2)安装mysql-community-release-el7-5.noarch.rpm包

rpm -ivh mysql-community-release-el7-5.noarch.rpm

3)刷新yum源 安装mysql-server

yum repolist
yum install -y mysql-server

 

4)启动

systemctl start mysql

5)登录修改密码

mysql -u root -p
mysql> set password=password('123456');

 

或者:

mysql > update mysql.user set authentication_string='123456' where user='root';

2.安装nginx

1)下载nginx包

wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

 2)安装nginx-release-centos-7-0.el7.ngx.noarch.rpm

rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

3)安装nginx

yum install -y nginx

4)启动nginx

systemctl start nginx

 5)测试访问

curl 127.0.0.1

 

3.安装php

1)安装 Php7 相应的 yum源

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

2)安装php7.0

yum install -y php70w

3)安装php扩展

yum install -y  php70w-mysql.x86_64   php70w-gd.x86_64   php70w-ldap.x86_64   php70w-mbstring.x86_64  php70w-mcrypt.x86_64

 

 4)安装php-fpm

 yum install -y php70w-fpm

 5)启动fpm

php-fpm

四、配置

1. 修改nginx配置文件加载php代码

vi /etc/nginx/conf.d/default.conf 

 2)修改/etc/php-fpm.d/www.conf

vi /etc/php-fpm.d/www.conf

3)重新启动php-fpm

killall php-fpm
php-fpm

4)重新加载nginx

nginx -s reload

5)测试php代码

vi /usr/share/nginx/html/index.php

浏览器访问http://192.168.1.71/index.php

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值