`

RHEL / Centos 6: Install Nginx

阅读更多

 

 

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: NOKEY
Preparing...                ########################################### [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-manager
Updating certificate-based repositories.
Unable to read consumer identity
nginx                                                    | 1.3 kB     00:00
nginx/primary                                            | 4.8 kB     00:00
nginx                                                                     33/33
Setting up Install Process
Resolving 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 k
Installed size: 835 k
Is this ok [y/N]: y
Downloading Packages:
nginx-1.2.6-1.el6.ngx.x86_64.rpm                         | 361 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: 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 --add nginx

# 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

  1. Default configuration directory: /etc/nginx/
  2. Default SSL and vhost config directory: /etc/nginx/conf.d/
  3. Default log file directory: /var/log/nginx/
  4. Default document root directory: /usr/share/nginx/html
  5. Default configuration file: /etc/nginx/nginx.conf
  6. Default server access log file: /var/log/nginx/access.log
  7. 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 the lscpu | 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

 

参考 http://www.cyberciti.biz/faq/install-nginx-centos-rhel-6-server-rpm-using-yum-command/

 

 

 

分享到:
评论

相关推荐

    linux环境下安装nginx

    配置Nginx时,主要编辑两个文件:`/etc/nginx/nginx.conf`是主配置文件,而`/etc/nginx/sites-available/default`(或`/etc/nginx/sites-enabled/`下的相应链接)是网站特定的配置。基本配置包括设置服务器块...

    Linux/Centos/RHEL yum 安装/部署 Nginx

    官网文档翻译. www.nginx.org 安装先决条件: sudo yum install yum-utils ...baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/ngin

    epel-release-6-8.noarch.rpm

    例如,如果需要安装`nginx` web服务器,可以执行`yum install nginx`或`dnf install nginx`。 EPEL软件包的更新通常会与RHEL/CentOS的版本保持同步,确保与系统的兼容性和稳定性。但是,值得注意的是,EPEL并不支持...

    nginx for linux安置程序

    1. 配置文件:Nginx的主配置文件通常位于 `/etc/nginx/nginx.conf` 或 `/usr/local/nginx/conf/nginx.conf`。 2. 配置块:Nginx配置文件由多个配置块组成,包括http、server和location等。 3. 反向代理示例: ``` ...

    linux中的nginx安装部署

    配置Nginx时,主要修改的是`/etc/nginx/nginx.conf`文件。你可以根据需求创建虚拟主机,每个虚拟主机代表一个独立的网站。例如,为一个新的域名`example.com`配置Nginx: ```nginx server { listen 80; server_...

    nginx部署所需所有安装文件(全)

    Nginx的日志文件默认位于`/var/log/nginx/`,可以通过`access.log`和`error.log`了解服务器状态。可以使用工具如Logrotate进行日志管理,或者使用Prometheus和Grafana进行性能监控。 ### 10. 维护与更新 定期更新...

    Linux离线安装nginx安装包

    - 在CentOS/RHEL系统中:`yum install gcc` - 在Ubuntu/Debian系统中:`apt-get install build-essential`,这会自动安装包括gcc在内的编译工具集。 3. **Nginx的安装** - 下载Nginx源码:`wget ...

    Nginx安装包及PCRE安装包及操作步骤

    - 如果你的系统是 CentOS 或 RHEL,使用 `yum` 命令:`sudo yum install pcre pcre-devel` 2. **下载 Nginx 安装包**: - 访问 Nginx 官方网站或镜像站点下载最新版的 Nginx 源码包,例如:`wget ...

    linux下安装Nginx所需依赖包

    sudo add-apt-repository ppa:nginx/stable ``` 在CentOS/RHEL上,需启用EPEL仓库: ```bash sudo yum install epel-release ``` 接下来,我们可以开始安装Nginx所需的依赖包。在大多数Linux发行版中,Nginx的...

    nginx-linux-1.24.0.tar.gz

    # 对于CentOS/RHEL sudo yum install gcc pcre-devel openssl-devel zlib-devel ``` 接下来,进入Nginx源码目录并配置编译选项。Nginx提供了丰富的配置选项,可以根据需要定制。一个基本的配置命令可能如下: ```...

    老鸟rhel5/centos5服务器架设笔记:Trac的安装和配置

    在IT行业中,特别是服务器管理领域,RHEL (Red Hat Enterprise Linux) 和 CentOS 是两种广泛使用的Linux发行版。本文将深入探讨如何在RHEL5或CentOS5上搭建Trac环境,这是一种优秀的开源项目管理和问题跟踪系统。...

    centos 6.3安装nginx 搭建文件服务器

    4. **配置Nginx**: 编辑Nginx的配置文件`/etc/nginx/nginx.conf`或创建一个虚拟主机配置文件(如`/etc/nginx/conf.d/myserver.conf`),定义服务器块,指定服务器监听的IP和端口,以及静态文件目录。 ```nginx ...

    在linux系统下安装两个nginx的简单方法

    sudo yum update -y # 对于RHEL/CentOS/Amazon Linux sudo apt-get update -y # 对于Debian/Ubuntu sudo yum install -y gcc perl # 或 sudo apt-get install -y gcc perl ``` #### 三、下载Nginx源码 访问Nginx...

    nginx相关使用教程、安装部署配置及常见问题说明等总结.docx

    sudo apt install nginx ``` - **CentOS/RHEL**: ```bash sudo yum install epel-release sudo yum install nginx ``` #### 2. 启动 Nginx 服务 - **Ubuntu/Debian/CentOS/RHEL**: ```bash sudo systemctl ...

    nginx安装包

    6. 配置 Nginx:编辑 `/usr/local/nginx/conf/nginx.conf` 文件,根据你的需求设置虚拟主机、监听端口、日志文件等配置。 7. 启动 Nginx:最后,启动 Nginx 服务以开始监听和处理请求。 ``` sudo /usr/local/...

    Linux版Nginx安装包及安装方法

    Nginx的配置文件通常位于`/etc/nginx/nginx.conf`,可以在这里调整服务器的配置。例如,你可以添加虚拟主机来托管多个网站。虚拟主机配置示例: ```nginx server { listen 80; server_name example....

    nginx_installSrv

    Nginx的配置文件位于`/etc/nginx/nginx.conf`,其中包含了服务器块和全局设置。根据需求,你可以创建和配置多个虚拟主机(server blocks),每个对应一个域名或IP地址。 **3. 服务化启动Nginx** 安装完成后,Nginx...

    安装nginx依赖包

    6. **配置Nginx作为Tomcat的代理**:编辑Nginx的配置文件`/usr/local/nginx/conf/nginx.conf`,添加如下配置: ```nginx upstream tomcat { server 127.0.0.1:8080; # Tomcat服务器地址和端口 } server { ...

    nginx-1.26.0最新版本已完成编译可解压直接使用

    或者在 CentOS/RHEL 上: ``` sudo yum install gcc pcre-devel openssl-devel zlib-devel ``` 2. **下载源码**: ``` wget https://nginx.org/download/nginx-1.26.0.tar.gz ``` 3. **解压并进入目录**: ...

Global site tag (gtag.js) - Google Analytics