关于服务器的搭建
一、搭建服务器
1、登录服务器
walter666.cn
www.mozetop.net
ssh root@47.104.228.111
root@106.12.108.62 root@123
2、安装epel仓库
yum install epel-release -y
3、安装nginx
yum install nginx -y
4、启动nginx
centos 7.0:
systemctl start nginx
systemctl enable nginx
centos 6.9:
(1)启动脚本
#!/bin/sh
# chkconfig: 2345 85 15
# description:Nginx Server
NGINX_HOME=/usr/local/nginx
NGINX_SBIN=$NGINX_HOME/sbin/nginx
NGINX_CONF=$NGINX_HOME/conf/nginx.conf
NGINX_PID=$NGINX_HOME/logs/nginx.pid
NGINX_NAME="Nginx"
. /etc/rc.d/init.d/functions
if [ ! -f $NGINX_SBIN ]
then
echo "$NGINX_NAME startup: $NGINX_SBIN not exists! "
exit
fi
start() {
$NGINX_SBIN -c $NGINX_CONF
ret=$?
if [ $ret -eq 0 ]; then
action $"Starting $NGINX_NAME: " /bin/true
else
action $"Starting $NGINX_NAME: " /bin/false
fi
}
stop() {
kill `cat $NGINX_PID`
ret=$?
if [ $ret -eq 0 ]; then
action $"Stopping $NGINX_NAME: " /bin/true
else
action $"Stopping $NGINX_NAME: " /bin/false
fi
}
restart() {
stop
start
}
check() {
$NGINX_SBIN -c $NGINX_CONF -t
}
reload() {
kill -HUP `cat $NGINX_PID` && echo "reload success!"
}
relog() {
kill -USR1 `cat $NGINX_PID` && echo "relog success!"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
check|chk)
check
;;
status)
status -p $NGINX_PID
;;
reload)
reload
;;
relog)
relog
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status|check|relog}"
exit 1
esac
(2)启动
service nginx start / stop
chkconfig nginx on
注:启动报错修复
vim /etc/nginx/conf.d/default.conf
将
listen 80 default_server;
listen [::]:80 default_server;
改为:
listen 80;
#listen [::]:80 default_server;
5、配置nginx代理服务
cd /etc/nginx/conf.d
vi walter666.cn.conf
添加配置:
upstream tunnel {
server 127.0.0.1:7788;
}
server {
listen 80;
server_name walter666.cn;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://tunnel;
}
}
重新加载nginx:
service nginx reload
6、SSH通道:将服务器请求转发给本地
在本地计算机命令行里执行:
ssh -vnNt -R 7788:localhost:3333 root@39.107.232.245
输入密码后重新访问应用
!!!: 穿透时不要忘记在阿里云服务器上配置端口:实例安全组>内网方向全部规则 添加 7000-8000端口
7、配置使用HTTPS
(1)申请免费SSL证书
https://help.aliyun.com/document_detail/28549.html?spm=a2c4g.11186623.6.554.OiPQ5A
(2)下载证书
下载完成后,得到 .key, .pem两个文件
(3)创建证书
cd /etc/nginx
mkdir ssl
cd ssl
vi walter666.cn.key
将.key的内容复制粘贴,保存退出
vi walter666.cn.pem
将.pem的内容复制粘贴,保存退出
(4)配置 nginx
复制:
ssl on;
ssl_certificate ssl/walter666.cn.pem;
ssl_certificate_key ssl/walter666.cn.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
到:cd ../ vi conf.d/walter666.cn.conf
同时修改端口号为 443
~END~
二、微信店铺账号申请
weixinpay:
https://pay.weixin.qq.com/index.php/core/home/login?return_url=%2F
商户平台:
appid:wx100749d4612ea385
mchid:1448624302
key:T8NHKqOfKWtqZPnQm8K77PtQtaRXluU8
网友评论