利用CentOS6搭建簡(jiǎn)易的web服務(wù)

提示: 其中沒有涉及到MySQl、MongoDB的安裝和使用,包括docker容器等,使用nginx反向代理靜態(tài)服務(wù)
centOS服務(wù)器
可以選用國(guó)外或者國(guó)內(nèi)的服務(wù)器,這里只展示centOS系統(tǒng)配置,本人實(shí)在window系統(tǒng)下完成下列操作
選購一臺(tái)合適的云服務(wù)器,系統(tǒng)為centOS
在window系統(tǒng)下安裝xshell和xftp, 保證可以系統(tǒng)訪問centOS系統(tǒng)
使用xshell連接上云服務(wù)器,使用超級(jí)管理員root登錄
登錄完成之后安裝nginx
下面是需要下載的文件:
wget # yum install wget # yum install gcc-c++ # yum -y install pcre pcre-devel # yum -y install zlib zlib-devel # wget -c https://nginx.org/download/nginx-1.10.3.tar.gz解壓與安裝:
# tar -zxvf nginx-1.10.3.tar.gz#cd nginx-1.10.3# ./configure# make# make install# whereis nginx 它會(huì)告訴你nginx在哪,nginx的命令在/usr/local/nginx/sbin目錄下nginx命令:
nginx命令開啟# ./nginx
停止# ./nginx -s stop
# ./nginx -s quit
重啟# ./nginx -s reload
開啟nginx # ./nginx 必須在nginx的安裝目錄下的sbi文件開啟,當(dāng)然也可全局配置
查看是否開啟nginx # ps aux|grep nginx
nginx配置
以下是nginx配置的部分參考
# http server
server {
listen 80;
server_name www.didiheng.com;
#charset koi8-r;
#access_log logs/host.access.log main;
access_log off; #緩存日志關(guān)閉
server_tokens off;
tcp_nopush on;
tcp_nodelay on;
gzip on; #gzip開啟
gzip_comp_level 6; #gzip比率
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
proxy_connect_timeout 5; #緩存鏈接
proxy_read_timeout 60;
proxy_send_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
location / {
root /www; #此處絕對(duì)地址
index index.html index.htm;
try_files $uri $uri/ /index.html; //使用客戶端路由需配置
rewrite ^(.*)$ https://$host$1 permanent; /強(qiáng)制定向https
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#https server
server {
listen 443 ssl;
server_name www.didiheng.com;
ssl_certificate server.crt;
ssl_certificate_key server.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
access_log off;
server_tokens off;
tcp_nopush on;
tcp_nodelay on;
expires epoch;
gzip on;
gzip_comp_level 6;
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
proxy_connect_timeout 5;
proxy_read_timeout 60;
proxy_send_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
location / {
root /www;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}
}
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
當(dāng)前題目:CentOS6使用nginx搭建web網(wǎng)站服務(wù)的方法-創(chuàng)新互聯(lián)
文章位置:http://chinadenli.net/article24/cosjce.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、用戶體驗(yàn)、做網(wǎng)站、虛擬主機(jī)、搜索引擎優(yōu)化、網(wǎng)站維護(hù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容