useradd duser
#下載并解壓縮nginx包
tar zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2
#編譯安裝
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' --add-module=/tmp/echo-nginx-module
make
make install
說明??:其中,如不需要echo模塊,將最后一個選項去掉,如需要echo模塊,從github上面拉到指定位置
為企業(yè)提供成都做網(wǎng)站、成都網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站優(yōu)化、全網(wǎng)營銷推廣、競價托管、品牌運營等營銷獲客服務(wù)。創(chuàng)新互聯(lián)擁有網(wǎng)絡(luò)營銷運營團隊,以豐富的互聯(lián)網(wǎng)營銷經(jīng)驗助力企業(yè)精準獲客,真正落地解決中小企業(yè)營銷獲客難題,做到“讓獲客更簡單”。自創(chuàng)立至今,成功用技術(shù)實力解決了企業(yè)“網(wǎng)站建設(shè)、網(wǎng)絡(luò)品牌塑造、網(wǎng)絡(luò)營銷”三大難題,同時降低了營銷成本,提高了有效客戶轉(zhuǎn)化率,獲得了眾多企業(yè)客戶的高度認可!cd /etc/nginx/
cp nginx.conf nginx.conf_bak
#cat nginx.conf
user duser duser;
#Single core
worker_processes 2;
#Multicore
#worker_processes 8;
#worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 10240;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$http_host"'
'$request_time $upstream_response_time $pipe - $upstream_addr';
log_format post_format $request_body;
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 120;
proxy_connect_timeout 600;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
#gzip on;
include /etc/nginx/http.d/*.conf;
}
stream {
log_format proxy '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr" '
'"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
access_log /var/log/nginx/stream.access.log proxy;
include /etc/nginx/stream.d/*.conf;
}
#創(chuàng)建更改http,tcp服務(wù)目錄和權(quán)限
mkdir /etc/nginx/http.d
mkdir /etc/nginx/stream.d
chmod 777 /etc/nginx/http.d
chmod 777 /etc/nginx/stream.d
chmod u+s /usr/sbin/nginx
#啟動nginx
nginx
#查看nginx服務(wù)
ps -ef |grep nginx
root 22828 1 0 14:17 ? 00:00:00 nginx: master process nginx
duser 23062 22828 0 14:50 ? 00:00:00 nginx: worker process
duser 23063 22828 0 14:50 ? 00:00:00 nginx: worker process
duser 23064 22828 0 14:50 ? 00:00:00 nginx: worker process
duser 23065 22828 0 14:50 ? 00:00:00 nginx: worker process
root 23396 23364 0 16:20 pts/2 00:00:00 grep --color=auto nginx
#先切到duser賬戶下
su - duser
#自定義一個http服務(wù)
cat /etc/nginx/http.d/test.conf
server {
listen 8080;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
}
#平滑重啟nginx
nginx -t
nginx -s reload
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。