CentOS 6.5安装配置Nginx
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 |
停止
|
#查询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软件。
- yum install gcc-c++
- yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
检查系统安装的ningx
- find -name nginx
- ./nginx
- ./nginx/sbin/nginx
- ./nginx-1.2.6/objs/nginx
卸载系统原有的nginx
- yum remove nginx
centos安装nginx
将安装包文件上传到目录中,本文是上传到/usr/local中,按以下命令进行操作。
- [root@admin local]# cd /usr/local
- [root@admin local]# tar -zxv -f nginx-1.2.6.tar.gz
- [root@admin local]# rm -rf nginx-1.2.6.tar.gz
- [root@admin local]# mv nginx-1.2.6 nginx
- [root@admin local]# cd /usr/local/nginx
- [root@admin nginx]# ./configure --prefix=/usr/local/nginx
- [root@admin nginx]# make
- [root@admin nginx]# make install
配置防火墙
配置防火墙开启80端口,不开启的话,有时防火墙会不让外网访问80端口我们就无法访问nginx配置的网站了。
- #修改防火墙配置:
- [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
启用nginx命令
- #方法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命令
- #查询nginx主进程号
- ps -ef | grep nginx
- #停止进程
- kill -QUIT 主进程号
- #快速停止
- kill -TERM 主进程号
- #强制停止
- pkill -9 nginx
重启nginx命令
- [root@admin local]# /usr/local/nginx/sbin/nginx -s reload
CentOS 6.5安装配置Nginx的更多相关文章
- CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL)
CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL) 一.准备篇: /etc/init.d/iptables stop #关闭防火墙 关闭SELINUX vi /etc/sel ...
- CentOS 7.0安装配置Vsftp服务器
一.配置防火墙,开启FTP服务器需要的端口 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop fi ...
- ELK 6安装配置 nginx日志收集 kabana汉化
#ELK 6安装配置 nginx日志收集 kabana汉化 #环境 centos 7.4 ,ELK 6 ,单节点 #服务端 Logstash 收集,过滤 Elasticsearch 存储,索引日志 K ...
- CentOS 7.0安装配置Vsftp服务器步骤详解
安装Vsftp讲过最多的就是在centos6.x版本中了,这里小编看到有朋友写了一篇非常不错的CentOS 7.0安装配置Vsftp服务器教程,下面整理分享给各位. 一.配置防火墙,开启FTP服务器需 ...
- centos tomcat/resin安装配置 卸载系统自带的java tomcat安装配置 安装JDK resin安装配置 第二十八节课
centos tomcat/resin安装配置 卸载系统自带的java tomcat安装配置 安装JDK resin安装配置 第二十八节课 tomcat和java都不需要编译 tom ...
- 【转发】【linux】【ftp】CentOS 7.0安装配置Vsftp服务器
adduser -d /var/www/android -g ftp -s /sbin/nologin ftp2 一.配置防火墙,开启FTP服务器需要的端口 CentOS 7.0默认使用的是firew ...
- CentOS 7.2安装配置Vsftp服务器
一.配置防火墙,开启FTP服务器需要的端口 CentOS 7.2默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop fi ...
- CentOS 6.6安装配置LAMP服务器(Apache+PHP5+MySQL)
准备篇: CentOS 6.6系统安装配置图解教程 http://www.osyunwei.com/archives/8398.html 1.配置防火墙,开启80端口.3306端口 vi /etc/s ...
- CentOS 6.4安装配置LAMP服务器(Apache+PHP5+MySQL)
这篇文章主要介绍了CentOS 6.4安装配置LAMP服务器(Apache+PHP5+MySQL)的方法,需要的朋友可以参考下 文章写的不错,很详细:IDO转载自网络: 准备篇: 1.配置防火墙,开启 ...
随机推荐
- Centos7配置vsftpd3.0.2
1.安装vsftpd vsftp使用本地用户登陆方式 yum -y install vsftpd yum安装的版本3.0.2 2.配置vsftpd vim /etc/vsftpd/vsftpd.con ...
- CCF CSP 201509-3 模板生成系统
CCF计算机职业资格认证考试题解系列文章为meelo原创,请务必以链接形式注明本文地址 CCF CSP 201509-3 模板生成系统 问题描述 成成最近在搭建一个网站,其中一些页面的部分内容来自数据 ...
- Python全栈开发之21、django
http://www.cnblogs.com/wupeiqi/articles/5237704.html http://www.cnblogs.com/wupeiqi/articles/5246483 ...
- Educational Codeforces Round 45 (Rated for Div. 2) G - GCD Counting
G - GCD Counting 思路:我猜测了一下gcd的个数不会很多,然后我就用dfs回溯的时候用map暴力合并就好啦. 终判被卡了MLE..... 需要每次清空一下子树的map... #inc ...
- 微信公众号第三方平台生成自定义菜单提示 获取"access_token失败"
在微信公众号第三方平台要生成自定义菜单时,程序反应很慢,最终提示"获取access_token失败"(之前程序无改动,使用时间已久),查了大半天,找不出原因. 排除.在微信公众号平 ...
- SpringBoot和微服务
SpringCloud SpringBoot 概念 应用 微服务CAP Consistency(数据强一致性),Availability(服务可用性),Partition-tolerance(分区容错 ...
- POJ - 2785 4 Values whose Sum is 0 二分
4 Values whose Sum is 0 Time Limit: 15000MS Memory Limit: 228000K Total Submissions: 25615 Accep ...
- NetCore控制台实现自定义CommandLine功能
命令行科普: 例如输入: trans 123 456 789 -r 123 -r 789上面例子中:trans是Command,123 456 789是CommandArgument,-r之后的都是C ...
- 深入理解ajax系列第四篇
前面的话 现代Web应用中频繁使用的一项功能就是表单数据的序列化,XMLHttpRequest 2级为此定义了FormData类型.FormData为序列化表单以及创建与表单格式相同的数据提供了便利. ...
- 机器学习之路:python 特征降维 特征筛选 feature_selection
特征提取: 特征降维的手段 抛弃对结果没有联系的特征 抛弃对结果联系较少的特征 以这种方式,降低维度 数据集的特征过多,有些对结果没有任何关系,这个时候,将没有关系的特征删除,反而能获得更好的预测结果 ...