-
1. 安装依赖库
yum -y install gcc-c++ yum -y install pcre pcre-devel yum -y install zlib zlib-devel yum -y install openssl openssl-devel
-
2. 安装nginx
移动到下载路径
下载最新版的稳定版nginxcd /data
解压wget http://nginx.org/download/nginx-1.12.0.tar.gz
安装tar -zxvf nginx-1.12.0.tar.gz
cd nginx-1.12.0 ./configure make make install
-
3. 优化nginx配置
新建nginx/html , nginx/logs文件夹
更改nginx配置文件mkdir -p /data/nginx/html mkdir /data/nginx/logs
参考如下vim /usr/local/nginx/conf/nginx.conf
启动nginxworker_processes 2; error_log /data/nginx/logs/error.log crit; pid /data/nginx/logs/nginx.pid; worker_rlimit_nofile 65535; events { use epoll; worker_connections 65535; } http { include mime.types; default_type application/octet-stream; fastcgi_intercept_errors on; server_tokens off; charset utf-8; server_names_hash_bucket_size 128; client_header_buffer_size 2k; large_client_header_buffers 4 4k; client_max_body_size 8m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /data/nginx/logs/access.log access; upstream site { server 127.0.0.1:8080 weight=1; } server { listen 80; server_name ~^(?<subdomain>.+)\.domain\.com$; root /data/nginx/html/$subdomain; location / { index index.html index.htm; } location ~* ^.+\.(ico|gif|jpg|jpeg|png|html|htm|eot|otf|ttf|woff)$ { expires -1s; } location ~* ^.+\.(css|js|txt|xml|swf|wav)$ { expires -1s; } location ^~ /service { proxy_pass http://site; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; expires -1s; } } }
删除冗余文件/usr/local/nginx/sbin/nginx
rm -rf /data/nginx-1.12.0 rm -rf /data/nginx-1.12.0.tar.gz
centos nginx安装与配置
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- Page 1:nginx 服务器安装及配置文件详解 CentOS 6.2 x86_64 安装 nginx 1.1 ...
- nginx在工作中已经有好几个环境在使用了,每次都是重新去网上扒博客,各种编译配置,今天自己也整理一份安装文档和n...
- 不知道大家有没有便秘的经历,相当痛苦,肚子里翻江倒海,但就是出不来。这时候,你需要的是一只开塞露(一种帮助人们拉出...