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. windows7无声音,提示未插入扬声器或耳机的解决

    windows7无声音,提示未插入扬声器或耳机的解决: http://jingyan.baidu.com/article/358570f6043a85ce4624fc47.html

  2. Jmeter和LR上传文件和下载

    Jmeter和LR上传文件和下载 背景: 在某个申请业务中,需要上传附件文件,然后才能提交该申请 遇到的问题: 1,  在使用Jmeter或者LR进行录制时,无法录制到上传文件的请求,只能通过Fidd ...

  3. logstash部署及基本语法(二)

    一.logstash介绍 Logstash是一个开源的数据收集引擎,可以水平伸缩,而且logstash是整个ELK当中拥有最多插件的一个组件,其可以接收来自不同源的数据并统一输入到指定的且可以是不同目 ...

  4. phpstorm 输入法中文不同步 phpstorm 输入法不跟随光标解决办法

    win7系统新安装的phpstorm2017.2版本,试了很多输入法,要么是不显示候选次,要么是输入法候选词总是在屏幕右下角,没有跟随光标移动.百度很久,重要找到解决方案. 就是替换phpstorm安 ...

  5. 百道CTF刷题记录(一)

    简介 最近在刷CTF题,主攻Web,兼职Misc Shiyanbar 0x01 简单的登陆题 简单概括: 考点: %00截断正则 CBC字节翻转攻击 难度: 难 WP:https://blog.csd ...

  6. Linux-CentOs7-svn安装及钩子配置

    做个svn的教程 首先进入test目录下,新建一个svn目录,准备做svn测试cd /testmkdir svncd svn然后使用yum安装svn,这里就不使用编译安装了,这玩意只要能用就行,版本无 ...

  7. 【基础知识】winfrom窗体的属性

    窗体的属性: Icon:窗体的右上角图标 FormBoarderStyle:窗体的边线样式 MaximizeBox: 最大化按钮是否可用 MinimizeBox:最小化按钮是否可用 Opacity:透 ...

  8. Xamarin 2017.11.1更新

     Xamarin 2017.11.1更新 本次更新主要解决了一些bug.Visual Studio 2017升级到15.4.2获得新功能.Visual Studio 2015需要工具-选项-Xamar ...

  9. 获取Android apk的包名

    Read the package name of an Android APK aapt dump badging <path-to-apk> | grep package:\ name

  10. Where should we fork this repository?

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha 我们应该在哪里分叉这个存储库? Where should we fork this re ...