CentOS 6.5 安装nginx 1.6.3

使用epel

[[email protected] /]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

下载nginx 1.6.3

[[email protected] /]# wget http://nginx.org/download/nginx-1.6.3.tar.gz

安装前准备

安装pcre (安装pcre库是为了Nginx支持HTTP Rewrite 模块)

[[email protected] /]# yum -y install pcre pcre-devel 

安装openssl

[[email protected] /]# yum -y install openssl openssl-devel

gcc编译器

[[email protected] /]# yum -y install gcc gcc-c++

解压

[[email protected] /]# ll nginx-1.6.3.tar.gz
-rw-r--r-- 1 root root 805253 Apr  8  2015 nginx-1.6.3.tar.gz
[[email protected] /]# tar zxvf nginx-1.6.3.tar.gz
[[email protected] /]# cd nginx-1.6.3
[[email protected] nginx-1.6.3]# pwd
/nginx-1.6.3

创建nginx用户

[[email protected] nginx-1.6.3]# useradd nginx -s /sbin/nologin -M

配置、编译、安装

[[email protected] nginx-1.6.3]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
[[email protected] nginx-1.6.3]# echo $?
0
[[email protected] nginx-1.6.3]# make && make install
[[email protected] nginx-1.6.3]# echo $?
0[[email protected] nginx-1.6.3]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin

启动nginx

[[email protected] nginx-1.6.3]# /usr/local/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[[email protected] nginx-1.6.3]# /usr/local/sbin/nginx
[[email protected] nginx-1.6.3]# netstat -lntup | grep nginx
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      3556/nginx
[[email protected] nginx-1.6.3]# lsof -i :80
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   3556  root    6u  IPv4  17544      0t0  TCP *:http (LISTEN)
nginx   3557 nginx    6u  IPv4  17544      0t0  TCP *:http (LISTEN)

浏览器访问:http://192.168.161.134

关闭防火墙或修改防火墙规则

[[email protected] nginx-1.6.3]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter        [  OK  ]
iptables: Flushing firewall rules:                       [  OK  ]
iptables: Unloading modules:                             [  OK  ]
[email protected] nginx-1.6.3]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT
[[email protected] nginx-1.6.3]# /etc/init.d/iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:                                                        [  OK  ]

或本机测试

[[email protected] nginx-1.6.3]# curl 192.168.161.134
<!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>

修改nginx.conf

[[email protected] nginx-1.6.3]# cd /usr/local/nginx/conf/
[[email protected] conf]# pwd
/usr/local/nginx/conf
[[email protected] conf]# vim nginx.conf
user  nginx;
worker_processes  1; 

log_format  main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘
                      ‘$status $body_bytes_sent "$http_referer" ‘
                      ‘"$http_user_agent" "$http_x_forwarded_for"‘;

    access_log  logs/access.log  main;
sendfile        on;
    tcp_nopush     on;
gzip  on;

 server {
        listen       80;
        server_name  www.httpd.com;

        charset utf-8;

        access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page  404              /404.html;

 error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

时间: 2024-07-31 14:30:42

CentOS 6.5 安装nginx 1.6.3的相关文章

在CentOS 7中安装nginx服务器

简要地介绍一下,如何在CentOS 7中安装nginx服务器  下载对应当前系统版本的nginx包(package) # wget  http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm  建立nginx的yum仓库 # rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm  下载并安装nginx # yum inst

centos 下yum 安装nginx

centos 下yum 安装nginx 1. 直接yum install nginx不行,要先处理下源: rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm 2. 查看源: yum info nginx 这时会提示有可安装的软件包 nginx | 2.9 kB 00:00nginx/primary_db | 15 kB 00:00可安装的软件包Nam

服务器 CentOS上yum安装Nginx服务

一.更改yum源为网易的源加快速度 vi /etc/yum.repos.d/CentOS-Base.repo 更改内容如下 # CentOS-Base.repo # # This file uses a new mirrorlist system developed by Lance Davis for CentOS. # The mirror system uses the connecting IP address of the client and the # update status

centos直接yum安装nginx

Ubuntu下安装nginx,直接apt-get install nginx就行了,很方便. 但是今天装了CentOS6.2,直接yum install nginx不行,要先处理下源,下面是安装完整流程,也十分简单: 1.CentOS 6,先执行:rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm2,查看yum的nginx信息 []# yum inf

Centos 6.5 安装 Nginx+MySQL+PHP

本文转载自:http://www.osyunwei.com/archives/2353.html 原文为安装CentOS 6.2 的步骤.博主安装6.5版本成功. 也安装了CentOS 7 版本成功.可至产看. 一下是原文: --------------------------------------------------------------------------------------------------------------------- 准备篇: 1.配置防火墙,开启80端口

在CentOS 7上安装Nginx服务器

下面我就我在CentOS上安装Nginx经验做简单的记录,以备后查. 1.下载nginx-release包 以CentOS 7为例,下载nginx软件包:http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm 其它Linux发行版的软件包下载地址:http://nginx.org/en/linux_packages.html 2.以普通用户登录终端,然后导入GPG sig

在CentOS上编译安装Nginx+实验环境搭建+测试

0.说明 Nginx作为一款优秀的Web Server软件同时也是一款优秀的负载均衡或前端反向代理.缓存服务软件,很有必要搭建实验环境来对其进行学习. 1.实验环境 本次实验的测试环境使用的宿主机操作系统为Windows 7,在Vmware虚拟机安装CentOS 6.5,说明如下: 宿主机操作系统Windows 7 虚拟机安装的操作系统CentOS 6.5 虚拟机操作系统上网方式NAT 而当使用NAT的方式进行上网时虚拟机.宿主机之间的网络连接关系可如下所示: 关于为什么网络拓扑结构是这样的,这

CentOS 7 yum 安装 Nginx

1.添加Nginx到YUM源 添加CentOS 7 Nginx yum资源库,打开终端,使用以下命令: sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm 2.安装Nginx 在你的CentOS 7 服务器中使用yum命令从Nginx源服务器中获取来安装Nginx: sudo yum install -y nginx Nginx将完成安装在

CentOS 7 下安装 Nginx

安装所需环境 Nginx 是 C语言 开发,建议在 Linux 上运行,当然,也可以安装 Windows 版本,本篇则使用 CentOS 7 作为安装环境. 一. gcc 安装安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装: yum install gcc-c++ 二. PCRE pcre-devel 安装PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表

CentOS 6.5 安装 Nginx 1.7.8 教程

http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=29791971&id=4702007 Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,由俄罗斯的程序设计师Igor Sysoev所开发,其特点是占有内存少,并发能力强,第一个公开版本0.1.0发布于2004年10月4日,目前最新版本是2014年12月2日发布的1.7.8. 今天在ttlsa网站里学习了Nginx的安装方法,在虚拟