博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CentOS 6.5 安装nginx 1.6.3
阅读量:6267 次
发布时间:2019-06-22

本文共 3468 字,大约阅读时间需要 11 分钟。

使用epel

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

下载nginx 1.6.3

[root@nginx /]# wget http://nginx.org/download/nginx-1.6.3.tar.gz

安装前准备

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

[root@nginx /]# yum -y install pcre pcre-devel

 

安装openssl

[root@nginx /]# yum -y install openssl openssl-devel

 

gcc编译器

[root@nginx /]# yum -y install gcc gcc-c++

 

解压

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

 

创建nginx用户 

[root@nginx nginx-1.6.3]# useradd nginx -s /sbin/nologin -M

 

配置、编译、安装

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

 

启动nginx

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

 

浏览器访问:http://192.168.161.134

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

[root@nginx nginx-1.6.3]# /etc/init.d/iptables stopiptables: Setting chains to policy ACCEPT: filter        [  OK  ]iptables: Flushing firewall rules:                       [  OK  ]iptables: Unloading modules:                             [  OK  ]

 

root@nginx nginx-1.6.3]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT[root@nginx nginx-1.6.3]# /etc/init.d/iptables saveiptables: Saving firewall rules to /etc/sysconfig/iptables:                                                        [  OK  ]

 

或本机测试

[root@nginx nginx-1.6.3]# curl 192.168.161.134Welcome to nginx!

Welcome to nginx!

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

For online documentation and support please refer tonginx.org.

Commercial support is available atnginx.com.

Thank you for using nginx.

 关闭 开启 nginx

/usr/local/sbin/nginx -s stop   //关闭服务器 /usr/local/sbin/nginx  开启服务器

  

修改nginx.conf

[root@nginx nginx-1.6.3]# cd /usr/local/nginx/conf/[root@nginx conf]# pwd/usr/local/nginx/conf[root@nginx conf]# vim nginx.confuser  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;        }

转载地址:http://dlcpa.baihongyu.com/

你可能感兴趣的文章
lakala反欺诈建模实际应用代码GBDT监督学习
查看>>
java 解析excel工具类
查看>>
Google FireBase - fcm 推送 (Cloud Messaging)
查看>>
BBS论坛(二十七)
查看>>
html DOM 的继承关系
查看>>
装饰器的邪门歪道
查看>>
Dubbo常用配置解析
查看>>
【转】C#解析Json Newtonsoft.Json
查看>>
macports的安装及常用命令
查看>>
(转)使用C#开发ActiveX控件
查看>>
spring mvc 基于注解 配置默认 handlermapping
查看>>
半小时学会上传本地项目到github
查看>>
Android学Jni/Ndk 开发记录(一)
查看>>
Linux Tcl和Expect的安装
查看>>
WPF中的依赖项属性(转)
查看>>
linux防火墙相关 iptables
查看>>
最简单的单例模式
查看>>
JPopupMenu的使用以及JPopupMenu中子组件的事件处理
查看>>
从反汇编的角度看引用和指针的区别
查看>>
拓马长枪定乾坤
查看>>