JAVA和Nginx 教程大全

网站首页 > 精选教程 正文

Linux运维 --- 安装 Nginx 网站服务器

wys521 2024-09-18 02:48:54 精选教程 22 ℃ 0 评论

需要保证Linux系统联网,nginx服务器的底层结构需要在线安装。

配置本地yum源:

[root@localhost ~]# cd /
[root@localhost /]# mkdir yum
[root@localhost /]# mount /dev/sr0 /yum
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost /]# 
[root@localhost /]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# vim yum.repo    ##在文档中添加下面4段内容

[yum]]
name=yum
baseurl=file:///yum
gpgcheck=0

[root@localhost yum.repos.d]# 
[root@localhost yum.repos.d]# yum clean all      ##清理 yum 源
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
正在清理软件源: yum
Cleaning up everything
[root@localhost yum.repos.d]# 
[root@localhost yum.repos.d]# yum repolist       ## 查看挂载的yum源
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
yum                                                      | 4.1 kB     00:00     
(1/2): yum/group_gz                                        | 136 kB   00:00     
(2/2): yum/primary_db                                      | 3.6 MB   00:00     
源标识                                 源名称                              状态
yum                                    yum                                 4,620
repolist: 4,620
[root@localhost yum.repos.d]# 
[root@localhost yum.repos.d]# vim /etc/rc.d/rc.local
[root@localhost yum.repos.d]# 
[root@localhost yum.repos.d]# chmod +x /etc/rc.d/rc.local        ##添加可执行权限
[root@localhost yum.repos.d]# ls -ld /etc/rc.d/rc.local
-rwxr-xr-x. 1 root root 493 4月  29 08:32 /etc/rc.d/rc.local
[root@localhost yum.repos.d]# 
[root@localhost yum.repos.d]# reboot      ##重启Linux系统

配置开机自启动的文件,在文档的末尾添加挂载信息:

给 /etc/rc.d/rc.local 赋予可执行权限

显示软件仓库列表

重启Linux

[root@localhost /]# yum install -y pcre pcre-devel
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
软件包 pcre-8.32-15.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 pcre-devel.x86_64.0.8.32-15.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================
 Package             架构            版本                    源            大小
================================================================================
正在安装:
 pcre-devel          x86_64          8.32-15.el7             yum          478 k

事务概要
================================================================================
安装  1 软件包

总下载量:478 k
安装大小:1.4 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : pcre-devel-8.32-15.el7.x86_64                               1/1 
yum/productid                                            | 1.6 kB     00:00     
  验证中      : pcre-devel-8.32-15.el7.x86_64                               1/1 

已安装:
  pcre-devel.x86_64 0:8.32-15.el7                                               

完毕!
[root@localhost /]# 
[root@localhost /]# yum install -y zlib zlib-devel
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
软件包 zlib-1.2.7-15.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 zlib-devel.x86_64.0.1.2.7-15.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=============================================================================================================================
 Package                        架构                       版本                                源                       大小
=============================================================================================================================
正在安装:
 zlib-devel                     x86_64                     1.2.7-15.el7                        yum                      50 k

事务概要
=============================================================================================================================
安装  1 软件包

总下载量:50 k
安装大小:132 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : zlib-devel-1.2.7-15.el7.x86_64                                                                           1/1 
  验证中      : zlib-devel-1.2.7-15.el7.x86_64                                                                           1/1 

已安装:
  zlib-devel.x86_64 0:1.2.7-15.el7                                                                                           

完毕!
[root@localhost /]# 
[root@localhost /]# yum install -y openssl openssl-devel
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
软件包 1:openssl-1.0.1e-42.el7_1.9.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 openssl-devel.x86_64.1.1.0.1e-42.el7_1.9 将被 安装
--> 正在处理依赖关系 krb5-devel(x86-64),它被软件包 1:openssl-devel-1.0.1e-42.el7_1.9.x86_64 需要
--> 正在检查事务
---> 软件包 krb5-devel.x86_64.0.1.13.2-10.el7 将被 安装
--> 正在处理依赖关系 keyutils-libs-devel,它被软件包 krb5-devel-1.13.2-10.el7.x86_64 需要
--> 正在处理依赖关系 libcom_err-devel,它被软件包 krb5-devel-1.13.2-10.el7.x86_64 需要
--> 正在处理依赖关系 libselinux-devel,它被软件包 krb5-devel-1.13.2-10.el7.x86_64 需要
--> 正在处理依赖关系 libverto-devel,它被软件包 krb5-devel-1.13.2-10.el7.x86_64 需要
--> 正在检查事务
---> 软件包 keyutils-libs-devel.x86_64.0.1.5.8-3.el7 将被 安装
---> 软件包 libcom_err-devel.x86_64.0.1.42.9-7.el7 将被 安装
---> 软件包 libselinux-devel.x86_64.0.2.2.2-6.el7 将被 安装
--> 正在处理依赖关系 libsepol-devel >= 2.1.9-1,它被软件包 libselinux-devel-2.2.2-6.el7.x86_64 需要
--> 正在处理依赖关系 pkgconfig(libsepol),它被软件包 libselinux-devel-2.2.2-6.el7.x86_64 需要
---> 软件包 libverto-devel.x86_64.0.0.2.5-4.el7 将被 安装
--> 正在检查事务
---> 软件包 libsepol-devel.x86_64.0.2.1.9-3.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=============================================================================================================================
 Package                             架构                   版本                                   源                   大小
=============================================================================================================================
正在安装:
 openssl-devel                       x86_64                 1:1.0.1e-42.el7_1.9                    yum                 1.2 M
为依赖而安装:
 keyutils-libs-devel                 x86_64                 1.5.8-3.el7                            yum                  37 k
 krb5-devel                          x86_64                 1.13.2-10.el7                          yum                 649 k
 libcom_err-devel                    x86_64                 1.42.9-7.el7                           yum                  30 k
 libselinux-devel                    x86_64                 2.2.2-6.el7                            yum                 174 k
 libsepol-devel                      x86_64                 2.1.9-3.el7                            yum                  71 k
 libverto-devel                      x86_64                 0.2.5-4.el7                            yum                  12 k

事务概要
=============================================================================================================================
安装  1 软件包 (+6 依赖软件包)

总下载量:2.1 M
安装大小:4.2 M
Downloading packages:
-----------------------------------------------------------------------------------------------------------------------------
总计                                                                                          18 MB/s | 2.1 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : libcom_err-devel-1.42.9-7.el7.x86_64                                                                     1/7 
  正在安装    : libsepol-devel-2.1.9-3.el7.x86_64                                                                        2/7 
  正在安装    : libselinux-devel-2.2.2-6.el7.x86_64                                                                      3/7 
  正在安装    : libverto-devel-0.2.5-4.el7.x86_64                                                                        4/7 
  正在安装    : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                                   5/7 
  正在安装    : krb5-devel-1.13.2-10.el7.x86_64                                                                          6/7 
  正在安装    : 1:openssl-devel-1.0.1e-42.el7_1.9.x86_64                                                                 7/7 
  验证中      : 1:openssl-devel-1.0.1e-42.el7_1.9.x86_64                                                                 1/7 
  验证中      : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                                   2/7 
  验证中      : libverto-devel-0.2.5-4.el7.x86_64                                                                        3/7 
  验证中      : libsepol-devel-2.1.9-3.el7.x86_64                                                                        4/7 
  验证中      : krb5-devel-1.13.2-10.el7.x86_64                                                                          5/7 
  验证中      : libcom_err-devel-1.42.9-7.el7.x86_64                                                                     6/7 
  验证中      : libselinux-devel-2.2.2-6.el7.x86_64                                                                      7/7 

已安装:
  openssl-devel.x86_64 1:1.0.1e-42.el7_1.9                                                                                   

作为依赖被安装:
  keyutils-libs-devel.x86_64 0:1.5.8-3.el7   krb5-devel.x86_64 0:1.13.2-10.el7     libcom_err-devel.x86_64 0:1.42.9-7.el7  
  libselinux-devel.x86_64 0:2.2.2-6.el7      libsepol-devel.x86_64 0:2.1.9-3.el7   libverto-devel.x86_64 0:0.2.5-4.el7     

完毕!
[root@localhost /]#

下载Nginx

wget http://nginx.org/download/nginx-1.15.10.tar.gz
[root@localhost /]# mkdir nginx
[root@localhost 桌面]# tar -xvf nginx-1.15.10.tar.gz -C /nginx

编译安装

[root@localhost nginx-1.15.10]# ./configure && make && make install

查看nginx的文件路径,编辑nginx主配置文件

[root@localhost nginx-1.15.10]# whereis nginx
nginx: /usr/local/nginx
[root@localhost nginx-1.15.10]# cd /usr/local/nginx
[root@localhost nginx]# vim /usr/local/nginx/conf/nginx.conf

重启Nginx

[root@localhost nginx-1.15.10]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

查看Nginx启动状态

[root@localhost nginx-1.15.10]# ps -ef |grep nginx
root       9691      1  0 10:10 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody     9693   9691  0 10:10 ?        00:00:00 nginx: worker process
root       9771   4078  0 10:14 pts/0    00:00:00 grep --color=auto nginx

验证

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表