CentOS 7_Lnmp_环境部署

本文详细介绍了如何在CentOS7系统上关闭防火墙和SELinux,添加EPEL和Webtatic仓库,然后依次安装Nginx、MySQL5.7和PHP7.0,配置Nginx和MySQL,启动服务,并创建phpinfo.php文件进行测试,最后通过访问phpinfo.php页面验证LNMP部署是否成功。
摘要由CSDN通过智能技术生成

1、关闭防火墙&selinux

systemctl stop firewalld
systemctl disable firewalld
setenforce 0 

2、添加epel仓库

yum install wget unzip -y 
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

3、安装nginx服务器

yum -y install nginx

4、安装MySQL
4.1.更新yum源

rpm -Uvh  http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

4.2.安装MySQL

yum -y install mysql-community-server --nogpgcheck

4.3.启动MySQL

systemctl start mysqld

5、安装php
5.1.更新yum源

yum install \https://repo.ius.io/ius-release-el7.rpm \https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

5.2.安装php

更新yum源
yum install \https://repo.ius.io/ius-release-el7.rpm \https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

安装php
yum -y install php70w-devel php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64  php70w-pdo.x86_64   php70w-mysqlnd  php70w-fpm php70w-opcache php70w-pecl-redis php70w-pecl-mongodb

6、nginx配置
6.1.备份nginx配置文件

cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak

6.2.修改nginx配置文件

vim /etc/nginx/nginx.conf
        location / 
            index index.php index.html index.htm;
        }
        location ~ .php$ {
            root /usr/share/nginx/html;   
            fastcgi_pass 127.0.0.1:9000;  
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;   
        }

7、配置MySQL
7.1.获取MySQL初始化密码

grep 'temporary password' /var/log/mysqld.log

7.2.安全性配置

mysql_secure_installation

8、配置PHP
8.1.新建phpinfo.php测试文件

vim /usr/share/nginx/html/phpinfo.php

<?php echo phpinfo(); ?>

8.2启动php-fpm

systemctl start php-fpm

9、访问lnmp配置信息页面

地址:http://ip地址/phpinfo.php
ps:出现以下界面代表部署成功

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值