Nginx在centoslinux安装、部署完整步骤并测试通过
系统大全为您提供
1.选定源码目录
选定目录 /usr/local/
cd /usr/local/
2.安装PCRE库
cd /usr/local/
wget http://exifr/pcre/pcre-8.02.tar.gz
tar -zxvf pcre-8.02.tar.gz
cd pcre-8.02
./configure && make && make install
3.安装zlib库
cd /usr/local/
wget http://zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8
./configure
make
make install
4.安装ssl
cd /usr/local/
wget http://org/source/openssl-1.0.1c.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz
./config
make
make install
5.安装nginx
Nginx 一般有两个版本,分别是稳定版和开发版,您可以根据您的目的来选择这两个版本的其中一个,下面是把 Nginx 安装到 /usr/localinx 目录下的详细步骤:
cd /usr/local/
wget http://g/download/nginx-1.2.8.tar.gz
tar -zxvf nginx-1.2.8.tar.gz
cd nginx-1.2.8
./configure --prefix=/usr/localinx
make
make install
--with-pcre=/usrc/pcre-8.21 指的是pcre-8.21 的源码路径。
--with-zlib=/usrc/zlib-1.2.7 指的是zlib-1.2.7 的源码路径。
6.启动
确保系统的 80 端口没被其他程序占用,
/usr/localinx/sbininx
检查是否启动成功:
netstat -ano|grep 80 有结果输入说明启动成功
打开浏览器访问此机器的 IP,如果浏览器出现 Welcome to nginx! 则表示 Nginx 已经安装并运行成功。
7.重启
/usr/localinx/sbininx –s reload
8.修改配置文件
cd /usr/localinx/conf
vi nginx.conf
9.常用配置
#nginx运行用户和组
user www www;
#启动进程,通常设置成和cpu的数量相等
worker_processes 4;
#全局错误日志及PID文件
pid ar/runinx.pid;
error_log ar/loginx/error.log;
events {
#epoll是多路复用IO(I/O Multiplexing)中的一种方式,但是仅用于linux2.6以上内核,可以大大提高nginx的性能
use epoll;
#单个后台worker process进程的最大并发链接数
worker_connections 10240;
}
#设定http服务器,利用它的反向代理功能提供负载均衡支持
http {
include mime.types;
default_type application/octet-stream;
error_page 400 403 500 502 503 504 /50x.html;
index index.html index.shtml
autoindex off;
fastcgi_intercept_errors on;
sendfile on;
# These are good default values.
tcp_nopush on;
tcp_nodelay off;
# output compression saves bandwidth
gzip off;
#gzip_static on;
#gzip_min_length 1k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_buffers 4 16k;
gzip_proxied any;
gzip_disable "MSIE [1-6].";
gzip_types text/plain textml text/css application/x-Javascript application/xml application/xml+rss text/Javascript;
#gzip_vary on;
server_name_in_redirect off;
#设定负载均衡的服务器列表
upstream portals {
server 172.16.68.134:8082 max_fails=2 fail_timeout=30s;
server 172.16.68.135:8082 max_fails=2 fail_timeout=30s;
server 172.16.68.136:8082 max_fails=2 fail_timeout=30s;
server 172.16.68.137:8082 max_fails=2 fail_timeout=30s;
}
#upstream overflow {
# server 10.248.6.34:8090 max_fails=2 fail_timeout=30s;
# server 10.248.6.45:8080 max_fails=2 fail_timeout=30s;
#}
server {
#侦听8080端口
listen 8080;
server_name 127.0.0.1;
#403、404页面重定向地址
error_page 403 = http:///www.win7cn.com
error_page 404 = http://www.win7cn.com
proxy_connect_timeout 90;
proxy_send_timeout 180;
proxy_read_timeout 180;
proxy_buffer_size 64k;
proxy_buffers 4 128k;
proxy_busy_buffers_size 128k;
client_header_buffer_size 16k;
large_client_header_buffers 4 64k;
#proxy_send_timeout 3m;
#proxy_read_timeout 3m;
#proxy_buffer_size 4k;
#proxy_buffers 4 32k;
proxy_set_header Host $http_host;
proxy_max_temp_file_size 0;
#proxy_hide_header Set-Cookie;
# if ($host != 'www.e100.cn' ) {
# rewrite ^/(.*)$ http://www.win7cn.com/$1 permanent;
# }
location / {
deny all;
}
location ~ ^/resource/res/imgue/space.gif {
proxy_pass http://tecopera;
}
location = / {
rewrite ^(.*)$ /ebiz/event/517.html last;
}
location = /ebiz/event/517.html {
add_header Vary Accept-Encoding;
root /data/webml;
expires 10m;
}
location = eck.html {
root /usr/localinxml/;
access_log off;
}
location = /50x.html {
root /usr/localinxml/;
expires 1m;
access_log off;
}
location = /index.html {
add_header Vary Accept-Encoding;
#定义服务器的默认网站根目录位置
root /data/webml/ebiz;
expires 10m;
}
#定义反向代理访问名称
location ~ ^/ecps-portal/* {
# expires 10m;
#重定向集群名称
proxy_pass http://portals;
#proxy_pass http://
}
location ~ ^/fetionLogin/* {
# expires 10m;
proxy_pass http://portals;
#proxy_pass http://
}
#location ~ ^siness/* {
# proxy_pass http:
#}
location ~ ^/rsmanager/* {
expires 10m;
root /data/web/;
#proxy_pass http://rsm;
}
#定义nginx处理的页面后缀
location ~* (.*).(jpg|gif|htm|html|png|js|css)$ {
root /data/webml/;
#页面缓存时间为10分钟
expires 10m;
}
#设定查看Nginx状态的地址
location ~* ^/NginxStatus/ {
stub_status on;
access_log off;
allow 10.1.252.126;
allow 10.248.6.49;
allow 127.0.0.1;
deny all;
}
# error_page 405 =200 @405;
# location @405
# {
# proxy_pass
# }
access_log /data/logsinx/access.log combined;
error_log /data/logsinx/error.log;
}
server {
listen 8082;
server_name _;
location = eck.html {
root /usr/localinxml/;
access_log off;
}
}
server {
listen 8088;
server_name _;
location ~ ^/* {
root /data/web/b2bhtml/;
access_log off;
}
}
server {
listen 9082;
server_name _;
# location ~ ^/resource/* {
# expires 10m;
# root /data/webml/;
# }
location / {
root /data/webml/sysMaintain/;
if (!-f $request_filename) {
rewrite ^/(.*)$ /sysMaintain.html last;
}
}
}
}
以上就是系统大全给大家介绍的如何使的方法都有一定的了解了吧,好了,如果大家还想了解更多的资讯,那就赶紧点击系统大全官网吧。
本文来自系统大全http://www.win7cn.com/如需转载请注明!推荐:win7纯净版
系统下载排行榜71011xp
番茄花园 Win7 64位 快速稳定版
2【纯净之家】Windows7 64位 最新纯净版
3【老机专用】Windows7 32位 精简旗舰版
4【纯净之家】Windows7 SP1 64位 全补丁旗舰版
5JUJUMAO Win7 64位 最新纯净版
6【纯净之家】Windows7 32位 最新纯净版
7【纯净之家】Windows7 SP1 64位 办公旗舰版
8【雨林木风】Windows7 64位 装机旗舰版
9【电脑公司】Windows7 64位 免费旗舰版
10【国庆献礼】JUJUMAO Win7 SP1 64位旗舰克隆纯净版
【纯净之家】Windows10 22H2 64位 专业工作站版
2【纯净之家】Windows10 22H2 64位 游戏优化版
3【纯净之家】Windows10 企业版 LTSC 2021
4【纯净之家】Windows10企业版LTSC2021 纯净版
5【深度技术】Windows10 64位 专业精简版
6联想Lenovo Windows10 22H2 64位专业版
7JUJUMAO Win8.1 Up3 X64 极速精简版v2019.11
8【纯净之家】Windows10 22H2 64位 专业精简版
9【雨林木风】Windows10 64位 专业精简版
10【纯净之家】Windows10 22H2 64位 专业办公版
【纯净之家】Windows11 23H2 64位 游戏优化版
2【纯净之家】Windows11 23H2 64位 专业工作站版
3【纯净之家】Windows11 23H2 64位 纯净专业版
4风林火山Windows11下载中文版
5【纯净之家】Windows11 23H2 64位 最新企业版
6【纯净之家】Windows11 23H2 64位 中文家庭版
7JUJUMAO Win11 24H2 64位 专业版镜像
8深度精简 Win11 ESD 全新优化纯净版V2024
9【纯净之家】Windows11 23H2 64位专业精简版
10【纯净之家】Windows11 23H2 64位 纯净家庭版
深度技术 GHOST XP SP3 电脑专用版 V2017.03
2深度技术 GGHOST XP SP3 电脑专用版 V2017.02
3Win7系统下载 PCOS技术Ghost WinXP SP3 2017 夏季装机版
4萝卜家园 GHOST XP SP3 万能装机版 V2017.03
5番茄花园 GHOST XP SP3 极速体验版 V2017.03
6雨林木风 GHOST XP SP3 官方旗舰版 V2017.03
7电脑公司 GHOST XP SP3 经典旗舰版 V2017.03
8雨林木风GHOST XP SP3完美纯净版【V201710】已激活
9萝卜家园 GHOST XP SP3 完美装机版 V2016.10
10雨林木风 GHOST XP SP3 精英装机版 V2017.04
热门教程
装机必备 更多+
重装工具