使用 yum安裝 nginx 的官方預編譯套件安裝
1. 設定 yum 倉庫(CentOS/RHEL):
建立 /etc/yum.repos.d/nginx.repo 文件,內容如下:
<code>[nginx] name=nginx repo <span># Stable version</span><span>#baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/</span><span># Mainline version</span><span>#baseurl=http://nginx.org/packages/mainline/OS/OSRELEASE/$basearch/</span>baseurl=http:<span>//nginx.org/packages/centos/7/$basearch/</span> gpgcheck=<span>0</span> enabled=<span>1</span></code>
說明:(建議 Stable version)
“OS”: 可以是 “centos” 或 “rhel”,根據 Linux 發行版本決定
「OSRELEASE」: 可以是 5/6/7;分別對應 5.x;6.x;7.x 版本
2. 安裝簽章(RPM 套件管理使用了數位簽章進行驗證包的合法性)
在 nginx 官網下面位址搜尋:nginx signing key,找到簽章檔案位址
http://nginx.org/en/linux_packages.html#stable
<code>user> cd user> wget <span>http</span>://nginx.org/<span>keys</span>/nginx_signing.key user> sudo rpm <span>--import nginx_signing.key</span></code>
3. 驗證 nginx 的設定成功
<code>user> yum search nginx 找到如下项目说明配置成功 <span>nginx.x86_64 </span>: High performance web server</code>
4. 安裝 nginx
<code>user> yum <span>install</span> nginx</code>
安裝套件下載僅 372KB
**user> sudo systemctl start nginx
user> sudo systemctl stop nginx
user> sudo systemctl restart nginx
user> ps -ef | grep nginx
user> sudo kill -QUIT
<code><span>#</span><span>开放</span><span>80</span><span>TCP</span><span>端口</span><span>user</span>> <span>sudo</span><span>firewall</span><span>-</span><span>cmd</span><span>-</span><span>-</span><span>z/span><span>-</span><span>-</span><span>add</span><span>-</span><span>port=80/tcp</span><span>-</span><span>-</span><span>permanent</span><span>user</span>> <span>sudo</span><span>firewall</span><span>-</span><span>cmd</span><span>-</span><span>-</span><span>reload</span></span></code>
/etc/nginx/nginx.conf
此檔案預設包含了 /etc/nginx/conf.d/ 目錄下的 *.conf 檔案
而服務相關的 server {} 段在 conf.d/default.conf 檔案中。
7. 自啟動
<code>user> <span>sudo</span> systemctl enable nginx</code>
<code>user> <span>sudo</span> systemctl disable nginx</code>
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i
').text(i)); }; $numbering.fadeIn(1700); }); }); 以上就介紹了在 CentOS7 下用 yum 安裝 nginx,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。