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:出现以下界面代表部署成功