LNMP架构部署

LNMP架构部署

准备工作

关闭防火墙和selinux

[root@localhost ~]# systemctl disable --now firewalld.service 
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled
[root@localhost ~]# setenforce 0
[root@localhost ~]# reboot

创建源码包存放目录并下载源码包

[root@localhost ~]# mkdir /usr/src/soft
[root@localhost ~]# cd /usr/src/soft/
[root@localhost soft]# wget https://nginx.org/download/nginx-1.20.1.tar.gz
[root@localhost soft]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
[root@localhost soft]# wget https://www.php.net/distributions/php-7.4.28.tar.gz
[root@localhost soft]# ls
mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz  nginx-1.20.1.tar.gz  php-7.4.28.tar.gz

nginx

创建nginx用户

[root@localhost ~]# useradd -r -M -s /sbin/nologin nginx

安装依赖包

[root@localhost ~]# yum -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++ make 
[root@localhost ~]# yum -y groups mark install 'Development Tools'

创建日志存放目录

[root@localhost ~]# mkdir -p /var/log/nginx
[root@localhost ~]# chown -R nginx.nginx /var/log/nginx

解压软件包

[root@localhost soft]# tar xf nginx-1.20.1.tar.gz -C /usr/local/

编译安装

[root@localhost nginx-1.20.1]# ./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@localhost nginx-1.20.1]# make && make install

配置环境变量

[root@localhost ~]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@localhost ~]# . /etc/profile.d/nginx.sh 

启动nginx

[root@localhost ~]# nginx 
[root@localhost ~]# 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                     [::]:*  

编写service文件

[root@localhost ~]# vim /lib/systemd/system/nginx.service 
[Unit]
Description=Nginx server daemon
After=network.target 

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/n
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值