RHEL / Centos 6: Install Nginx Using Yum Command
来源:互联网 发布:充电宝什么牌子好 知乎 编辑:程序博客网 时间:2024/06/10 11:21
RHEL / Centos 6: Install Nginx Using Yum Command
yumEstimated completion timeN/A
Recently, nginx web project started to distribute binary packages using nginx yum repository. You can either create /etc/yum.repos.d/nginx.repo or directly install rpm package. This package contains yum configuration file and a public PGP key necessary to authenticate signed RPMs.
Step #1: Install nginx repo
Type the following wget command to install nginx yum configuration file:# cd /tmp
CentOS Linux v6.x user type the following command:# wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
# rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm
RHEL v6.x user type the following command:# wget http://nginx.org/packages/rhel/6/noarch/RPMS/nginx-release-rhel-6-0.el6.ngx.noarch.rpm
# rpm -ivh nginx-release-rhel-6-0.el6.ngx.noarch.rpm
Sample outputs:
warning: nginx-release-rhel-6-0.el6.ngx.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEYPreparing... ########################################### [100%] 1:nginx-release-rhel ########################################### [100%]
Step #2: Install nginx web-server
Type the following yum command to install nginx web-server:# yum install nginx
Sample outputs:
Loaded plugins: product-id, rhnplugin, security, subscription-managerUpdating certificate-based repositories.Unable to read consumer identitynginx | 1.3 kB 00:00nginx/primary | 4.8 kB 00:00nginx 33/33Setting up Install ProcessResolving Dependencies--> Running transaction check---> Package nginx.x86_64 0:1.2.6-1.el6.ngx will be installed--> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size================================================================================Installing: nginx x86_64 1.2.6-1.el6.ngx nginx 361 k Transaction Summary================================================================================Install 1 Package(s) Total download size: 361 kInstalled size: 835 kIs this ok [y/N]: yDownloading Packages:nginx-1.2.6-1.el6.ngx.x86_64.rpm | 361 kB 00:00Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionWarning: RPMDB altered outside of yum. Installing : nginx-1.2.6-1.el6.ngx.x86_64 1/1---------------------------------------------------------------------- Thanks for using NGINX! Check out our community web site:* http://nginx.org/en/support.html If you have questions about commercial support for NGINX please visit:* http://www.nginx.com/support.html ----------------------------------------------------------------------Installed products updated. Verifying : nginx-1.2.6-1.el6.ngx.x86_64 1/1 Installed: nginx.x86_64 0:1.2.6-1.el6.ngx Complete!
Step #3: Turn on nginx service
Type the following command:# chkconfig nginx on
How do I start / stop / restart nginx web-server?
Type the following commands:# service nginx start
# service nginx stop
# service nginx restart
# service nginx status
# service nginx reload
Step #4: Configuration files
- Default configuration directory: /etc/nginx/
- Default SSL and vhost config directory: /etc/nginx/conf.d/
- Default log file directory: /var/log/nginx/
- Default document root directory: /usr/share/nginx/html
- Default configuration file: /etc/nginx/nginx.conf
- Default server access log file: /var/log/nginx/access.log
- Default server access log file: /var/log/nginx/error.log
To edit the nginx configuration file, enter:# vi /etc/nginx/nginx.conf
Set or update worker_processes as follows (this must be set to CPU(s) in your system. Use thelscpu | grep '^CPU(s)' command to list the number of CPUs in the server)
worker_processes 2;
Turn on gzip support:
gzip on;
Save and close the file. Edit the file /etc/nginx/conf.d/default.conf, enter:# vi /etc/nginx/conf.d/default.conf
Set IP address and TCP port number:
listen 202.54.1.1.1:80;
Set server name:
server_name www.cyberciti.biz;
Save and close the file. Start the server:# service nginx start
Verify that everything is working:# netstat -tulpn | grep :80
# ps aux | grep nginx
Firewall configuration: Open TCP port # 80
Edit the file /etc/sysconfig/iptables, enter:# vi /etc/sysconfig/iptables
Add the following lines, ensuring that they appear before the final LOG and DROP lines for the INPUT chain to open port 80:
-A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
Save and close the file. Finally, restart the firewall:# service iptables restart
How do I configure nginx+php5?
See this tutorial for more information.
How do I configure Nginx as a reverse proxy server?
See our previous tutorials:
- CentOS / Redhat Linux: Install Keepalived To Provide IP Failover For Web Cluster
- CentOS / Redhat: Install nginx As Reverse Proxy Load Balancer
- Handling nginx Failover With KeepAlived
- nginx: Setup SSL Reverse Proxy (Load Balanced SSL Proxy)
- mod_extforward: Lighttpd Log Clients Real IP Behind Reverse Proxy / Load Balancer
- HowTo: Merge Apache / Lighttpd / Nginx Server Log Files
- Linux nginx: Chroot (Jail) Setup
How do I secure nginx web-server?
- See: Top 20 Nginx webServer best security practices blog post for more information.
Check out related media
This tutorial is also available in a quick video format.
- RHEL / Centos 6: Install Nginx Using Yum Command
- RHEL / Centos 6: Install Nginx Using Yum Command
- RHEL / Centos 6: Install Nginx Using Yum Command
- IT忍者神龟之RHEL / Centos 6: Install Nginx Using Yum Command 翻译
- How To Install nginx on CentOS 6 with yum
- How To Install nginx on CentOS 6 with yum
- How to Install Ruby 2.1.1 on CentOS & RHEL 6 using RVM
- CentOS直接yum install nginx 办法
- rhel 安装Centos yum
- centos yum install nginx No package nginx available
- Install yum On RHEL 4
- 二:2.How To Install nginx on CentOS 6 with yum
- Install LEMP (Linux, Nginx, MySQL 5.5.29, PHP 5.4.11) on RHEL/CentOS 5-6 & Fedora 18-12
- centos 6 install nginx php
- RHEL / CentOS 7 install MongoDB
- rhel 6.3 建立centos yum
- Install WordPress 3.6.1 Using LAMP or LEMP on RHEL, CentOS & Fedora
- How to Install GUI (Gnome 3) Using CD/DVD on RHEL/CentOS 7
- c#学习笔记-匿名
- leetcode之Reverse Words in a string
- 多屏文字tab标签幻灯片(右侧文字介绍)
- jersey实现还要整合在spring
- eclipse显示行号设置
- RHEL / Centos 6: Install Nginx Using Yum Command
- 【STL】函数适配器
- 什么是SEM,如何做好SEM
- appweb-4.3.4-0移植到ARM
- 路由的连接讲解
- js文件在IDEA中没有了格式,显示的是纯文本的解决办法
- C++虚函数表解析
- 详解Spring中bean的生命周期
- 期初库存注意事项