部署LNMP架构

部署LNMP架构


IP 系统 服务
192.168.89.10 centos 8 nginx
192.168.89.150 centos 8 mysql
192.168.89.151 centos 8 php

1、nginx的安装与配置


1、1 nginx的安装

//创建系统用户nginx
[root@10 ~]# useradd -r -M -s /sbin/nologin nginx

//安装依赖环境
[root@10 ~]# yum -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++
[root@10 ~]# yum -y groups mark install 'Development Tools'


//创建日志存放目录
[root@10 ~]# mkdir -p /var/log/nginx
[root@10 ~]# chown -R nginx.nginx /var/log/nginx
[root@10 ~]#


//下载nginx
[root@10 ~]# cd /usr/src/
[root@10 src]# wget http://nginx.org/download/nginx-1.22.0.tar.gz
--2022-10-10 14:15:30--  http://nginx.org/download/nginx-1.22.0.tar.gz
Resolving nginx.org (nginx.org)... 3.125.197.172, 52.58.199.22, 2a05:d014:edb:5702::6, ...
Connecting to nginx.org (nginx.org)|3.125.197.172|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1073322 (1.0M) [application/octet-stream]
Saving to: ‘nginx-1.22.0.tar.gz’

nginx-1.22.0.tar.gz                       100%[====================================================================================>]   1.02M   301KB/s    in 3.5s

2022-10-10 14:15:34 (301 KB/s) - ‘nginx-1.22.0.tar.gz’ saved [1073322/1073322]

[root@10 src]#

//编译安装
[root@10 src]# ls
debug  kernels  nginx-1.22.0.tar.gz
[root@10 src]# tar xf nginx-1.22.0.tar.gz
[root@10 src]# cd nginx-1.22.0
[root@10 nginx-1.22.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@10 nginx-1.22.0]# make -j $(grep 'processor' /proc/cpuinfo | wc -l) && make install

1、2 nginx安装后配置

//配置环境变量
[root@10 ~]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@10 ~]# . /etc/profile.d/nginx.sh
[root@10 ~]#

//服务控制方式,使用nginx命令
  -t  //检查配置文件语法
  -v  //输出nginx的版本
  -c  //指定配置文件的路径
  -s  //发送服务控制信号,可选值有{stop|quit|reopen|reload}

//启动nginx
[root@10 ~]# nginx
[root@10 ~]# ss -antl
State               Recv-Q              Send-Q                           Local Address:Port                           Peer Address:Port             Process
LISTEN              0                   128                                    0.0.0.0:80                                  0.0.0.0:*
LISTEN              0                   128                                    0.0.0.0:22                                  0.0.0.0:*
LISTEN              0                   128                                       [::]:22                 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值