-
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...
- 不知道大家有沒有便秘的經歷,相當痛苦,肚子里翻江倒海,但就是出不來。這時候,你需要的是一只開塞露(一種幫助人們拉出...