http://nginx.org/
下載地址:
http://nginx.org/en/download.html
2、下載Windows Service Wrapper
官網(wǎng)地址:
https://github.com/kohsuke/winsw/
下載地址:
http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/
3、解壓Nginx壓縮包文件到C盤根目錄,并且重命名為nginx
4、將winsw-1.19-bin.exe重命名為nginx-service.exe,并且復(fù)制到nginx根目錄
5、在nginx根目錄編寫nginx-service.xml文件
nginx-service.xml文件內(nèi)容
<?xml version=1.0 encoding=UTF-8 ?> <service> <id>Nginx</id> <name>Nginx</name> <description>本服務(wù)用于加載Nginx服務(wù),請確保開機(jī)啟動。</description> <logpath>C:\\\\nginx\\\\logs</logpath> <executable>nginx.exe</executable> <stopexecutable>nginx.exe</stopexecutable> <stopargument>-s</stopargument> <stopargument>stop</stopargument> <logmode>rotate</logmode> </service>
6、安裝Nginx系統(tǒng)服務(wù)或者卸載Nginx系統(tǒng)服務(wù)
6.1、安裝Nginx系統(tǒng)服務(wù)
按下Win X A鍵
打開命令提示符(管理員)
輸入:
C:\\\\nginx\\\\nginx-service.exe install
6.2、卸載Nginx系統(tǒng)服務(wù)
按下Win X A鍵
打開命令提示符(管理員)
輸入:
C:\\\\nginx\\\\nginx-service.exe uninstall
7、查看系統(tǒng)服務(wù)
7.1、進(jìn)入服務(wù)
運(yùn)行Win R輸入:
services.msc
7.2、啟動Nginx服務(wù)
8、成功啟動之后,在IE瀏覽器中輸入:http://localhost/
9、用命令方式啟動、關(guān)閉Nginx服務(wù)
9.1、啟動Nginx服務(wù)
按下Win X A鍵
打開命令提示符(管理員)
輸入:net start nginx
9.2、關(guān)閉Nginx服務(wù)
按下Win X A鍵
打開命令提示符(管理員)
輸入:net stop nginx
10、Windows查看進(jìn)程和殺死進(jìn)程
10.1、查看Nginx進(jìn)程號
tasklist | findstr 服務(wù)名
按下Win X A鍵
打開命令提示符(管理員)
輸入:
tasklist | findstr nginx
10.2、使用tskill命令殺死進(jìn)程(tskill PID)
11、配置Nginx文件
Nginx配置文件目錄:
C:\\\\nginx\\\\conf
11.1、編輯Nginx核心配置文件nginx.conf
# 根據(jù)你服務(wù)器的cpu核數(shù)來確定此值
worker_processes 2;
# events事件主要用來確定Nginx使用哪種算法
events {
worker_connections 1024;
}
http {
#隱藏Nginx版本信息
server_tokens off;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#代理的相關(guān)參數(shù)設(shè)置
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 128k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
#啟用gzip壓縮,提高用戶訪問速度
gzip on;
gzip_min_length 1k;
gzip_buffers 4 32k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
gzip_disable MSIE [1-6].;
server_names_hash_bucket_size 128;
client_max_body_size 100m;
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;
#增加虛擬主機(jī)
include vhosts.conf;
}
11.2、編輯Nginx虛擬主機(jī)配置文件vhosts.conf
#NGINX安裝初始化
server {
listen 80;
charset utf-8;
server_name 127.0.0.1;
location / {
#打開瀏覽目錄
autoindex on;
#顯示出文件的大概大小
autoindex_exact_size off;
#顯示的文件時間為文件的服務(wù)器時間
autoindex_localtime on;
root C:\\\\wwwroot\\\\html;
index index.html index.htm;
}
}
12、創(chuàng)建網(wǎng)站根目錄
12.1、在C盤根目錄創(chuàng)建網(wǎng)站目錄,命名為wwwroot。
12.2、在網(wǎng)站根目錄放入站點(diǎn)目錄,命名為html。
12.3、瀏覽網(wǎng)頁
更多關(guān)于云服務(wù)器,域名注冊,虛擬主機(jī)的問題,請?jiān)L問西部數(shù)碼官網(wǎng):www.ps-sw.cn