Ubuntu下安装nginx,直接apt-get install nginx就行了,很方便。

但是今天装了CentOS6.5,直接yum install nginx不行,要先处理下源,下面是安装完整流程,也十分简单:

1、CentOS 6,先执行:
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
2,查看yum的nginx信息

[]# yum info nginx

Loaded plugins: fastestmirror

Determining fastest mirrors

* base: mirror.esocc.com

* extras: mirror.esocc.com

* updates: mirror.esocc.com

base                                                     | 3.7 kB     00:00

base/primary_db                                          | 4.4 MB     00:28

extras                                                   | 3.5 kB     00:00

extras/primary_db                                        |  19 kB     00:00

nginx                                                    | 2.9 kB     00:00

nginx/primary_db                                         |  22 kB     00:00

updates                                                  | 3.5 kB     00:00

updates/primary_db                                       | 2.1 MB     00:10

Installed Packages

Name        : nginx

Arch        : x86_64

Version     : 1.4.0

Release     : 1.el6.ngx

Size        : 874 k

Repo        : installed

From repo   : nginx

Summary     : nginx is a high performance web server

URL         : http://nginx.org/

License     : 2-clause BSD-like license

Description : nginx [engine x] is an HTTP and reverse proxy server, as well as

: a mail proxy server

3,安装并启动nignx
[root@server ~]# yun install nignx
[root@server ~]# service nginx start
Starting nginx:                                            [  OK  ]

4,然后进入浏览器,输入http://192.168.0.161/测试,如果看到

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

恭喜你,你成功了!

如果不能连接到nginx,原因很多,但是可以先检查 1,nginx服务是否真的起来了;2,linux服务器防火墙是否打开

配置

#修改防火墙配置:
[root@admin nginx-1.2.6]# vi + /etc/sysconfig/iptables
#添加配置项
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#重启防火墙
[root@admin nginx-1.2.6]# service iptables restart

启动

#方法1
[root@admin nginx-1.2.6]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#方法2
[root@admin nginx-1.2.6]# cd /usr/local/nginx/sbin
[root@admin sbin]# ./nginx

停止

#查询nginx主进程号
ps -ef | grep nginx
#停止进程
kill -QUIT 主进程号
#快速停止
kill -TERM 主进程号
#强制停止
pkill -9 nginx

重启

[root@admin local]# /usr/local/nginx/sbin/nginx -s reload

测试

#测试端口
netstat –na|grep 80
#浏览器中测试
http://ip:80

一般使用linux系统的不少网友可能都是直接使用一键安装包进行安装的,以前作者也这样,但是很多时候这些一键安装方便是方便但是可能在升级及其他很多地方不是很好,本文就说下在centos6.3安装nginx1.2的步骤。

安装说明

操作系统:centos6.3

软件:nginx-1.2.6.tar.gz

安装方式:源码编码安装

安装位置:/usr/local/nginx

nginx下载地址:http://nginx.org/en/download.html

准备工具

在安装nginx衫,需要确保系统已经安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件。

  1. yum install gcc-c++
  2. yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel

检查系统安装的ningx

  1. find -name nginx
  2. ./nginx
  3. ./nginx/sbin/nginx
  4. ./nginx-1.2.6/objs/nginx

卸载系统原有的nginx

  1. yum remove nginx

centos安装nginx

将安装包文件上传到目录中,本文是上传到/usr/local中,按以下命令进行操作。

  1. [root@admin local]# cd /usr/local
  2. [root@admin local]# tar -zxv -f nginx-1.2.6.tar.gz
  3. [root@admin local]# rm -rf nginx-1.2.6.tar.gz
  4. [root@admin local]# mv nginx-1.2.6 nginx
  5. [root@admin local]# cd /usr/local/nginx
  6. [root@admin nginx]# ./configure --prefix=/usr/local/nginx
  7. [root@admin nginx]# make
  8. [root@admin nginx]# make install

配置防火墙

配置防火墙开启80端口,不开启的话,有时防火墙会不让外网访问80端口我们就无法访问nginx配置的网站了。

  1. #修改防火墙配置:
  2. [root@admin nginx-1.2.6]# vi + /etc/sysconfig/iptables
  3. #添加配置项
  4. -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
  5. #重启防火墙
  6. [root@admin nginx-1.2.6]# service iptables restart

启用nginx命令

  1. #方法1
  2. [root@admin nginx-1.2.6]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
  3. #方法2
  4. [root@admin nginx-1.2.6]# cd /usr/local/nginx/sbin
  5. [root@admin sbin]# ./nginx

停止nginx命令

  1. #查询nginx主进程号
  2. ps -ef | grep nginx
  3. #停止进程
  4. kill -QUIT 主进程号
  5. #快速停止
  6. kill -TERM 主进程号
  7. #强制停止
  8. pkill -9 nginx

重启nginx命令

    1. [root@admin local]# /usr/local/nginx/sbin/nginx -s reload

CentOS 6.5安装配置Nginx的更多相关文章

  1. CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL)

    CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL) 一.准备篇: /etc/init.d/iptables stop #关闭防火墙 关闭SELINUX vi /etc/sel ...

  2. CentOS 7.0安装配置Vsftp服务器

    一.配置防火墙,开启FTP服务器需要的端口 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop fi ...

  3. ELK 6安装配置 nginx日志收集 kabana汉化

    #ELK 6安装配置 nginx日志收集 kabana汉化 #环境 centos 7.4 ,ELK 6 ,单节点 #服务端 Logstash 收集,过滤 Elasticsearch 存储,索引日志 K ...

  4. CentOS 7.0安装配置Vsftp服务器步骤详解

    安装Vsftp讲过最多的就是在centos6.x版本中了,这里小编看到有朋友写了一篇非常不错的CentOS 7.0安装配置Vsftp服务器教程,下面整理分享给各位. 一.配置防火墙,开启FTP服务器需 ...

  5. centos tomcat/resin安装配置 卸载系统自带的java tomcat安装配置 安装JDK resin安装配置 第二十八节课

    centos  tomcat/resin安装配置  卸载系统自带的java  tomcat安装配置  安装JDK   resin安装配置    第二十八节课 tomcat和java都不需要编译 tom ...

  6. 【转发】【linux】【ftp】CentOS 7.0安装配置Vsftp服务器

    adduser -d /var/www/android -g ftp -s /sbin/nologin ftp2 一.配置防火墙,开启FTP服务器需要的端口 CentOS 7.0默认使用的是firew ...

  7. CentOS 7.2安装配置Vsftp服务器

    一.配置防火墙,开启FTP服务器需要的端口 CentOS 7.2默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop fi ...

  8. CentOS 6.6安装配置LAMP服务器(Apache+PHP5+MySQL)

    准备篇: CentOS 6.6系统安装配置图解教程 http://www.osyunwei.com/archives/8398.html 1.配置防火墙,开启80端口.3306端口 vi /etc/s ...

  9. CentOS 6.4安装配置LAMP服务器(Apache+PHP5+MySQL)

    这篇文章主要介绍了CentOS 6.4安装配置LAMP服务器(Apache+PHP5+MySQL)的方法,需要的朋友可以参考下 文章写的不错,很详细:IDO转载自网络: 准备篇: 1.配置防火墙,开启 ...

随机推荐

  1. Spark-Streaming总结

    文章出处:http://www.cnblogs.com/haozhengfei/p/e353daff460b01a5be13688fe1f8c952.html Spark_总结五 1.Storm 和 ...

  2. 在ASP.NET Web API和ASP.NET Web MVC中使用Ninject

    先附上源码下载地址 一.准备工作 1.新建一个名为MvcDemo的空解决方案 2.新建一个名为MvcDemo.WebUI的空MVC应用程序 3.使用NuGet安装Ninject库   二.在ASP.N ...

  3. Bootstrap Paginator分页插件使用示例

    最近做的asp.netMVC项目中需要对数据列表进行分类,这个本来就是基于bootstrap开发的后台,因此也就想着bootstrap是否有分页插件呢,或者说是基于jquery支持的分页功能,这样整体 ...

  4. MVC 源码调试

    源码调试,帮助你跟好理解MVC,使你开发跟牛B的程序. 1>在Visual命令行中运行“SN.EXE-Vr*,31BF3856AD364E35” 2. codeplex.com 上面找到,和你当 ...

  5. 关于ecshop的mobile里user.php登录和注册验证码不显示

    在做ecshop模板的时候由于user.php里的登录和注册是在一个页面里切换的,这就致使这里的登录和注册里的验证码不显示 找到mobile/themesmobile/ecshoptemplate_m ...

  6. 数据挖掘算法:关联分析二(FP-tree算法)

    三.FP-tree算法 下面介绍一种使用了与Apriori完全不同的方法来发现频繁项集的算法FP-tree.FP-tree算法在过程中没有像Apriori一样产生候选集,而是采用了更为紧凑的数据结构组 ...

  7. Sublime Text 下的Install Package安装方法

    废话不多说.... 如果你是Sublime Text3用户,按下Ctrl+~呼出控制台,输入以下代码 import urllib.request,os,hashlib; h = '7183a2d3e9 ...

  8. Javascript:window.close()不起作用?

    一般的窗口关闭的JS如下写法: window.close() 但是呢,chrome,firefox等中有时候会不起作用. 改为下面的写法: window.open("about:blank& ...

  9. codevs 2596 售货员的难题

    2596 售货员的难题 时间限制: 1 s 空间限制: 32000 KB 题目等级 : 钻石 Diamond 题目描述 Description 某乡有n个村庄(1<n<=15),有一个售货 ...

  10. 模板 SBT

    傻逼树模板 struct SBT{ const static int maxn = 1e5 + 15; int lft[maxn] , rht[maxn] , key[maxn] , s[maxn] ...