-
- 案例1:部署LNMP环境
-
步骤一:安装软件
-
1)使用yum安装基础依赖包
[root@svr5 ~]# yum -y install gcc openssl-devel pcre-devel zlib-devel
… … -
2)源码安装Nginx
[root@svr5 ~]# useradd –s /sbin/nologin nginx
[root@svr5 ~]# tar -zxvf nginx-1.8.0.tar.gz
[root@svr5 ~]# cd nginx-1.8.0[root@svr5 nginx-1.8.0]# ./configure \
–prefix=/usr/local/nginx
–user=nginx --group=nginx
–with-http_ssl_module
[root@svr5 ~]# make && make install -
3)安装MariaDB
-
Mariadb在新版RHEL7光盘中包含有该软件,配置yum源后可以直接使用yum安装:
[root@svr5 ~]# yum –y install mariadb mariadb-server mariadb-devel
-
4)php和php-fpm
[root@svr5 ~]# yum –y install php [root@svr5 ~]# tar –xf lnmp_soft-2017-03-28.tar.gz [root@svr5 ~]# cd lnmp_soft [root@svr5 ~]# yum –y localinstall php-fpm-5.4.16-36.el7_1.x86_64.rpm [root@svr5 ~]# yum –y install php-mysql
-
步骤二:启动服务
-
1)启动Nginx服务
这里需要注意的是,如果服务器上已经启动了其他监听80端口的服务软件(如httpd),则需要先关闭该服务,否则会出现冲突。
[root@svr5 ~]# systemctl stop httpd #如果该服务存在则关闭该服务
[root@svr5 ~]# systemctl disable httpd #关闭httpd的开机启动功能
[root@svr5 ~]# /usr/local/nginx/sbin/nginx # 启动Nginx服务
[root@svr5 ~]# netstat -utnlp | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 32428/nginx
2)启动MySQL服务
[root@svr5 ~]# systemctl start mariadb
[root@svr5 ~]# systemctl status mariadb
[root@svr5 ~]# systemctl enable mariadb
3)启动PHP-FPM服务
[root@svr5 ~]# systemctl start php-fpm
[root@svr5 ~]# systemctl status php-fpm
[root@svr5 ~]# systemctl enable php-fpm