基于CentOS7.9搭建LNMP

今天为大家搭建一下基于CentOS7.9服务器部署LNMP,方便未来基于lnmp部署应用程序。

1.CentOS7.9基础配置

为了实现基于CentOS7.9服务器部署LNMP,CentOS7.9服务器需要满足一定的基础需要。具体参考:Linux常规基础配置_linux操作系统配置_小黑要上天的博客-CSDN博客

2.服务器信息

HostName IpAddress OSVersion Note
lnmp 192.168.10.250 CentOS Linux release 7.9.2009 (Core)
 

3.lnmp实施部署

3.1.nginx1.24.0安装部署

-->更新网络yum源

命令:

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

[root@lnmp yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2023-11-20 18:11:16--  https://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 111.32.209.196, 2409:8c04:1110:a:3::3ae, 2409:8c04:1110:a:3::3ad
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|111.32.209.196|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

100%[====================================================================>] 2,523       --.-K/s   in 0s      

2023-11-20 18:11:17 (210 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]

-->设置nginx yum存储库,使用以下内容创建名为/etc/yum.repos.d/nginx.repo的文件,并保存

命令:

vim /etc/yum.repos.d/nginx.repo

[root@lnmp yum.repos.d]# cat /etc/yum.repos.d/nginx.repo 
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[root@lnmp yum.repos.d]# 

-->安装nginx

命令:

yum install nginx -y

rpm -qa | grep nginx

[root@lnmp ~]# yum install nginx -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                   | 3.6 kB  00:00:00     
extras                                                                                 | 2.9 kB  00:00:00     
nginx-stable                                                                           | 2.9 kB  00:00:00     
updates                                                                                | 2.9 kB  00:00:00     
(1/3): extras/7/x86_64/primary_db                                                      | 250 kB  00:00:02     
(2/3): nginx-stable/7/x86_64/primary_db                                                |  87 kB  00:00:04     
(3/3): updates/7/x86_64/primary_db                                                     |  24 MB  00:02:41     
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.24.0-1.el7.ngx will be installed
--> Processing Dependency: libpcre2-8.so.0()(64bit) for package: 1:nginx-1.24.0-1.el7.ngx.x86_64
--> Running transaction check
---> Package pcre2.x86_64 0:10.23-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
 Package             Arch                 Version                            Repository                  Size
==============================================================================================================
Installing:
 nginx               x86_64               1:1.24.0-1.el7.ngx                 nginx-stable               804 k
Installing for dependencies:
 pcre2               x86_64               10.23-2.el7                        CentOS7                    201 k

Transaction Summary
==============================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 1.0 M
Installed size: 3.3 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/nginx-stable/packages/nginx-1.24.0-1.el7.ngx.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 7bd9bf62: NOKEY
Public key for nginx-1.24.0-1.el7.ngx.x86_64.rpm is not installed
nginx-1.24.0-1.el7.ngx.x86_64.rpm                                                      | 804 kB  00:00:06     
--------------------------------------------------------------------------------------------------------------
Total                                                                         145 kB/s | 1.0 MB  00:00:06     
Retrieving key from https://nginx.org/keys/nginx_signing.key
Importing GPG key 0x7BD9BF62:
 Userid     : "nginx signing key <[email protected]>"
 Fingerprint: 573b fd6b 3d8f bc64 1079 a6ab abf5 bd82 7bd9 bf62
 From       : https://nginx.org/keys/nginx_signing.key
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : pcre2-10.23-2.el7.x86_64                                                                   1/2 
  Installing : 1:nginx-1.24.0-1.el7.ngx.x86_64                                                            2/2 
----------------------------------------------------------------------

Thanks for using nginx!

Please find the official documentation for nginx here:
* https://nginx.org/en/docs/

Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* https://nginx.org/en/support.html

Commercial subscriptions for nginx are available on:
* https://nginx.com/products/

----------------------------------------------------------------------
  Verifying  : pcre2-10.23-2.el7.x86_64                                                                   1/2 
  Verifying  : 1:nginx-1.24.0-1.el7.ngx.x86_64                                                            2/2 

Installed:
  nginx.x86_64 1:1.24.0-1.el7.ngx                                                                             

Dependency Installed:
  pcre2.x86_64 0:10.23-2.el7                                                                                  

Complete!
[root@lnmp ~]# rpm -qa | grep nginx
nginx-1.24.0-1.el7.ngx.x86_64
[root@lnmp ~]# 

-->nginx启动

命令:

systemctl enable nginx

systemctl start nginx

systemctl status nginx

netstat -antulp | grep 80

[root@lnmp ~]# systemctl enable nginx
[root@lnmp ~]# systemctl start nginx
[root@lnmp ~]# systemctl status nginx
● nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2023-11-20 18:23:13 CST; 2s ago
     Docs: http://nginx.org/en/docs/
  Process: 3894 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
 Main PID: 3895 (nginx)
   CGroup: /system.slice/nginx.service
           ├─3895 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
           ├─3896 nginx: worker process
           ├─3897 nginx: worker process
           ├─3898 nginx: worker process
           └─3899 nginx: worker process

Nov 20 18:23:13 lnmp systemd[1]: Starting nginx - high performance web server...
Nov 20 18:23:13 lnmp systemd[1]: Started nginx - high performance web server.
[root@lnmp ~]# netstat -antulp | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      3895/nginx: master  
[root@lnmp ~]# 

-->nginx验证

3.2.mysql5.7安装部署

-->mysql5.7 rpm包下载

命令:

<
  • 35
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小黑要上天

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值