nginx搭建文件服务器脚本,nginx搭建web服务器,配置端口复用
1、文件安裝目錄說明Nginx安裝目錄為/usr/local/nginx
Nginx主配置文件目錄為/usr/local/nginx/conf/nginx.conf
https密鑰key存放目錄/usr/local/nginx/sslkey/vhost*
網(wǎng)站存放目錄/usr/local/nginx/WebServer
各網(wǎng)站主配置文件存放目錄/usr/local/nginx/WebServer/vhost*.conf
2、Nginx主配置文件worker_processes??1;
events?{
worker_connections??1024;
}
http?{
include???????mime.types;
default_type??application/octet-stream;
sendfile????????on;
keepalive_timeout??65;
#gzip??on;
server?{
listen???????80;?????????????????#業(yè)務(wù)監(jiān)聽端口
server_name??localhost;
#charset?koi8-r;
#access_log??logs/host.access.log??main;
location?/?{
root???html;
index??index.html?index.htm;
}
}
include?/usr/local/nginx/WebServer/*.conf;?????????????????#外鏈加載的主Nginx的配置文件路徑,需要指向到各個(gè)網(wǎng)站的配置文件上去
}
3、各網(wǎng)站主配置文件的解釋server?{
listen???????80;
server_name??www.secddi.com;???????#此處為需要重寫的URL地址
rewrite?^(.*)?https://$server_name$1?permanent;
}?????????????????????????????????????#以上配置文件的意思為重寫服務(wù)器的http?80端口至https?443端口
server?{
listen?443;
server_name?www.secddi.com;????????#此處為https的URL地址
index?index.html;
root?/usr/local/nginx/WebServer/vhostA;????????#此處為web網(wǎng)站的訪問目錄,主頁路徑
ssl_certificate??????/usr/local/nginx/sslkey/vhostA/full_chain.pem;????????#此處為配置的https證書路徑
ssl_certificate_key??/usr/local/nginx/sslkey/vhostA/private.key;???????????#此處為配置的https證書路徑
ssl_session_cache????shared:SSL:1m;
ssl_session_timeout??5m;
server_tokens?off;
fastcgi_param???HTTPS???????????????on;
fastcgi_param???HTTP_SCHEME?????????https;
access_log?/usr/local/nginx/logs/httpsaccess.log;
}
4、配置nginx腳本#!/bin/bash
#description:?Ngnix?Service
#chkconfig:2345?88?77
#幫助函數(shù)
Usage?(){
echo?$"Usage:$0?{start|stop|restart}"
}
#啟動(dòng)函數(shù)
start(){
pid_file="/usr/local/nginx/logs/nginx.pid"
if?[?-f?$pid_file?];then
echo?"Ngnix?Already?Running,?Do?Not?Run?Again.。"
exit?1
else
echo?"Ngnix?Service?Is?Start?Running..."
/usr/local/nginx/sbin/./nginx
/usr/local/nginx/sbin/./nginx?-s?reload
fi
}
#停止函數(shù)
stop(){
pid_file="/usr/local/nginx/logs/nginx.pid"
if?[?-f?$pid_file?];then
echo?"Ngnix?coming?to?stop?running"
/usr/local/nginx/sbin/./nginx?-s?stop
else
echo?"Ngnix?is?not?running..."
exit?1
fi
}
#選擇語句
case?$1?in
start?)
start
;;
stop?)
stop
;;
restart?)
stop
sleep?1
start
;;
*?)
Usage
;;
esac
5、將配置文件保存在/etc/init.d/nginx位置即可。之后即可通過下面的命令進(jìn)行啟動(dòng)服務(wù)。chmod?+777?/etc/init.d/nginx
/etc/init.d/nginx?stop/start/restart
標(biāo)簽:web,配置文件,stop,復(fù)用,server,nginx,usr,local
來源: https://blog.51cto.com/eholog/2685046
總結(jié)
以上是生活随笔為你收集整理的nginx搭建文件服务器脚本,nginx搭建web服务器,配置端口复用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 捕获计算机屏幕++方法,如何在Windo
- 下一篇: wcf简单教程(10) ajax调用,w