环境说明
系统平台 | IP | 服务 |
---|---|---|
CentOS7 redhat7 |
192.168.102.11 | nginx |
CentOS7 redhat7 |
192.168.102.12 | mysql |
CentOS7 redhat7 |
192.168.102.13 | php |
1、lnmp平台软件安装顺序: nginx --> mysql --> php/
2、关闭防火墙和selinux
3、配置网络源
4、准备好软件包
nginx
mysql
php
操作
安装
- 192.168.102.11
//安装开发工具包 ‘Development Tools’
[root@server ~]# yum -y groupinstall 'Development Tools'
//安装依赖包
[root@server ~]# yum -y install openssl-devel pcre-devel openssl-devel gd-devel gcc gcc-c++ epel-release
//创建nginx的用户和组
[root@server ~]# groupadd -g 1000 nginx
[root@server ~]# useradd -M -s /sbin/nologin -g 1000 -u 1000 nginx
[root@server ~]# id nginx
uid=1000(nginx) gid=1000(nginx) groups=1000(nginx)
//创建日志存放目录
[root@server ~]# mkdir -p /var/log/nginx/
[root@server ~]# chown -R nginx.nginx /var/log/nginx/
//编译安装nginx
[root@server ~]# tar -xf nginx-1.14.0
[root@server ~]# cd nginx-1.14.0/
[root@server nginx-1.14.0]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-debug \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log
[root@server nginx-1.14.0]# make && make install
//将路径写入环境变量
[root@server ~]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@server ~]# . /etc/profile.d/nginx.sh
//安装后检查配置是否有错
[root@server nginx-1.14.0]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
//启动nginx
[root@server nginx-1.14.0]# nginx
[root@server ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
安装mysql
- 192.168.102.12
//安装依赖包
[r