Linux系统 安装Nginx
2015-06-21 00:26
567 查看
rpm安装:
/article/3863863.html
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 ~]# yum install nginx
[root@server ~]# service nginx start
Starting nginx: [ OK ]
4,然后进入浏览器,输入http://192.168.0.161/测试,如果看到
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
重启若出现:
iptables: Applying firewall rules: iptables-restore: line 14 failed
[FAILED]
解决办法:将
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
放在“COMMIT”之前:
源码安装:
/article/5320691.html
软件:nginx-1.2.6.tar.gz
安装方式:源码编译安装
安装位置:/usr/local/nginx
下载地址:http://nginx.org/en/download.html
检查系统安装的Nginx:
卸载原有的Nginx
配置
/article/3863863.html
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 ~]# yum install nginx
[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
重启若出现:
iptables: Applying firewall rules: iptables-restore: line 14 failed
[FAILED]
解决办法:将
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
放在“COMMIT”之前:
源码安装:
/article/5320691.html
安装说明
系统环境:CentOS-6.3软件:nginx-1.2.6.tar.gz
安装方式:源码编译安装
安装位置:/usr/local/nginx
下载地址:http://nginx.org/en/download.html
安装前提
在安装nginx前,需要确保系统安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件。安装必须软件:[root@admin /]#yum install gcc-c++ yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel |
[root@admin local]# find -name nginx ./nginx ./nginx/sbin/nginx ./nginx-1.2.6/objs/nginx |
[root@admin /]# yum remove 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 // 出现:make[1]: Entering directory `/usr/local/nginx' [root@admin nginx]# make install |
#修改防火墙配置: [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 |
相关文章推荐
- Nginx虚拟主机配置
- nginx下502和504错误的解决办法
- nginx.conf 完整的集群配置
- LNMP第一部分环境搭建
- Nginx源代码安装
- Nginx深入详解之日志
- Nginx实现异步访问mysql的配置方法
- Nginx中使用Lua脚本配置示例
- 把ImageMagic库编译进nginx服务器的一些必要配置
- 把Lua编译进nginx步骤方法
- Nginx 配置详解
- Nginx的location配置
- Nginx报出504 Gateway Timeout错误2
- Nginx+Lua开发
- Varnish+Nginx搭建缓存服务器
- Rhel6.5_Nginx1.45_Php5.59_MySQL5.6.16编译安装(集成LNMP环境)
- Nginx源码分析之变量
- Nginx的Rewrite配置
- 【Nginx】epoll事件驱动模块
- 【Nginx】Nginx配置文件nginx.conf中文详解