Nginx 教程:从 Linux 软件包安装(RHEL/CentOS、Debian、Ubuntu)
nginx 软件包适用于以下发行版和版本:
RHEL/CentOS:❙ed 5 平台版本 ‶ 支持 .x Ubuntu: SLES: 要实现Linux软件包的自动更新,可以为RHEL发行版设置存储库 在本文中,我们将重点介绍 要为 将“ 将 Debian 代码替换为 Debian 发行版的代码 ( 对于 SLES,运行以下命令: 源码包可以在源码包中找到: http 源码包 //hg.nginx.org / pkg-oss?_ga=1.85593177.1509956953.1490042234 默认分支 存储当前主版本包源码,而 的源代码与nginx在相同的 对于 Debian/Ubuntu,要验证 nginx 存储库的签名并在安装 nginx 软件包时消除有关缺少 PGP 密钥的警告,需要使用存储库签名密钥安装 nginx 软件包添加到程序钥匙串 查看 Ubuntu 发行版Codename,使用以下命令 - Ubuntu 发行版的 Codename 将 看起来像这样 - 现在您可以运行以下命令来安装 nginx: 配置文件将默认安装到:/inng/x 目录下一个- 1。运行测试 Nginx- 2。查询nginx进程 ,在上面的输出结果中 x86_64。7.x wheezy x86_64,i386❙is8 x86_64,i386 版本 代号( 代号)支持平台12.04❙86_46 精度。 14.04 值得信赖 x86_64,i386,aarch64/arm64 16.04 xenial x86_64,i386 , ppc64el 616.10❙xenial ''❙y'6 4 , i386版本 支持的平台 12 x86_64 yum。/ CentOS 和❙‹‼ apt 和 zypper SLES。 apt 存储库 Debian/Ubuntu 发行版作为演示,并在 U‼️ x 系统上安装 Ngin。,内容如下:1。稳定版本的预打包包
RHEL/CentOS 系统平台
RHEL/CentOS 设置 yum 存储库,您需要创建一个名为 ‼️ .repos.d/ 的存储库nginx.repo
Shell[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1
OS”替换为“”‼❙,具体取决于所使用的发行版“或”centos ”与5.x,6.x❙❙❙‼️‼️。 ISSUE ”替换为“5”、“6”或“7”。 ? 缺少 PGP 密钥警告,用于签署 nginx 包和存储库的密钥必须添加到密钥包apt。从Nginx官网:http://nginx.org/keys/nginx_signing.key下载密钥并使用以下命令将其添加到apt Debian:sudo apt-key add nginx_signing.key
代号),并将以下文件附加到文件末尾 /etc/apt/sources.list: Ubuntu distribution 替换 codename version codename 并将以下文件添加到文件末尾 /etc/apt/sources.list: /Debian: 命令: apt-get update
apt-get install nginx
SLES 系统平台
Shellzypper addrepo -G -t yum -c 'http://nginx.org/packages/sles/12' nginx
2. 源码包
stable-*分支用于存放最新稳定版本源码包。要构建二进制包,可以在 Debian/Ubuntu 上的目录 debian/ 或 上的目录 debian/ 或 上的 OS❀ OS❙❙❙ 中找到。 转/分钟/ 在 中运行命令 make。包2 BSD许可证下分发。 3。在 Ubuntu 服务器上安装 Nginx 实例
apt 。从 Nginx 官方网站:http://nginx.org/keys/nginx_signing.key 下载密钥,并使用以下命令将其添加到 apt 程序的密钥包中: yiibai@ubuntu:~$ wget -c http://nginx.org/keys/nginx_signing.key
--2017-03-31 20:13:06-- http://nginx.org/keys/nginx_signing.key
Resolving nginx.org (nginx.org)... 95.211.80.227, 206.251.255.63, 2001:1af8:4060:a004:21::e3, ...
Connecting to nginx.org (nginx.org)|95.211.80.227|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1561 (1.5K) [application/octet-stream]
Saving to: ‘nginx_signing.key’
nginx_signing.key 100%[===================>] 1.52K --.-KB/s in 0s
2017-03-31 20:13:06 (105 MB/s) - ‘nginx_signing.key’ saved [1561/1561]
yiibai@ubuntu:~$ ls
nginx_signing.key
yiibai@ubuntu:~$
yiibai@ubuntu:~$ sudo apt-key add nginx_signing.key
Shellyiibai@ubuntu:~$ sudo lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial
yiibai@ubuntu:~$
替换为 codename 并将以下两行附加到 /pt/ 并将以下两行附加到 /pt/ 结束文件:deb http://nginx.org/packages/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/ubuntu/ xenial nginx
![]()
yiibai@ubuntu:~$ sudo apt-get update
Get:1 http://nginx.org/packages/ubuntu xenial InRelease [3,589 B]
Hit:2 http://us.archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://nginx.org/packages/ubuntu xenial/nginx Sources [4,139 B]
Get:4 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:5 http://nginx.org/packages/ubuntu xenial/nginx amd64 Packages [7,012 B]
Get:6 http://nginx.org/packages/ubuntu xenial/nginx i386 Packages [6,999 B]
Get:7 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:8 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Fetched 328 kB in 5s (61.3 kB/s)
Reading package lists... Done
yiibai@ubuntu:~$
yiibai@ubuntu:~$ sudo apt-get install nginx
... ...
... ...
Selecting previously unselected package nginx.
(Reading database ... 54601 files and directories currently installed.)
Preparing to unpack .../nginx_1.10.3-1~xenial_amd64.deb ...
----------------------------------------------------------------------
Thanks for using nginx!
Please find the official documentation for nginx here:
* http://nginx.org/en/docs/
Commercial subscriptions for nginx are available on:
* http://nginx.com/products/
----------------------------------------------------------------------
Unpacking nginx (1.10.3-1~xenial) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu7) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up nginx (1.10.3-1~xenial) ...
Processing triggers for systemd (229-4ubuntu7) ...
Processing triggers for ureadahead (0.100.0-19) ...
![]()
Shellyiibai@ubuntu:~$ sudo /etc/init.d/nginx
Usage: /etc/init.d/nginx {start|stop|status|restart|reload|force-reload|upgrade|configtest|check-reload}
yiibai@ubuntu:~$ sudo /etc/init.d/nginx start
[ ok ] Starting nginx (via systemctl): nginx.service.
yiibai@ubuntu:~$
Shellyiibai@ubuntu:~$ ps -ef | grep nginx
root 9933 1 0 20:36 ? 00:00:00 nginx: master process /usr/sbi n/nginx -c /etc/nginx/nginx.conf
nginx 9938 9933 0 20:36 ? 00:00:00 nginx: worker process
yiibai 9978 8461 0 20:40 pts/0 00:00:00 grep --color=auto nginx
yiibai@ubuntu:~$
master表示该进程是nginx的主进程,其进程ID为:♿ⓓ。 ?停了下来。
Kill -9 进程号
杀掉进程,检查进程是否还存在,一一杀掉,全部杀掉。? - yiibai@ubuntu:~$ curl localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
yiibai@ubuntu:~$
版权声明
本文仅代表作者观点,不代表Code前端网立场。
本文系作者Code前端网发表,如需转载,请注明页面地址。
code前端网