找回密码
 立即注册
搜索
查看: 1816|回复: 2

如果要在服务器新增一个虚拟主机(附带配置HTTPS)

  [复制链接]

581

主题

110

回帖

4066

积分

管理员

积分
4066

众神之神

发表于 2015-12-30 18:42:53 | 显示全部楼层 |阅读模式
如果要在服务器新增一个虚拟主机,二级域名为app.13cloud.cn
1.到/alidata/server/nginx/conf/vhosts/目录下
2.复制cp 13cloud.cn.conf app.13cloud.cn.conf
3.打开app.13cloud.cn.conf并且编辑(i),最后保存(wq!)
  1. server {
  2.         listen       80;
  3.         server_name  app.13cloud.cn;        //二级域名的名字
  4.         index index.html index.htm index.php;
  5.         root /alidata/www/app.13cloud.cn;      //虚拟主机的目录(这一步还未创建此目录)

  6.         location ~ .*\.(php|php5)?$
  7.         {
  8.                 #fastcgi_pass  unix:/tmp/php-cgi.sock;
  9.                 fastcgi_pass  127.0.0.1:9000;
  10.                 fastcgi_index index.php;
  11.                 include fastcgi.conf;
  12.         }

  13.         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  14.         {
  15.                 expires 30d;
  16.         }

  17.         location ~ .*\.(js|css)?$
  18.         {
  19.                 expires 1h;
  20.         }

  21.         include /alidata/server/nginx/conf/rewrite/wordpress.conf;      //加载主流框架伪静态规则
  22. }
复制代码
4.创建虚拟主机目录mkdir /alidata/www/app.13cloud.cn(之后可以向此目录下上传程序)可以现在此目录下创建一个index.html占位
5.给此目录赋予www权限chown -R www:www app.13cloud.cn/
6.重启 nginx 服务器 /etc/init.d/nginx reload



=====================================================
下面是配置https,配置完不要忘记6.重启 nginx 服务器 /etc/init.d/nginx reload

  1. server {
  2.         listen       80;
  3.         listen 443 ssl;
  4.     #listen       443;
  5.     server_name  xxx.abc.net;
  6.         index index.html index.htm index.php;
  7.         root /alidata/www/xxx.abc.net;

  8.         #下面是为了支持https
  9.         ssl on;
  10.         ssl_certificate   cert/xxx.pem;
  11.     ssl_certificate_key  cert/xxx.key;
  12.     ssl_session_timeout 5m;
  13.     ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  14.     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  15.     ssl_prefer_server_ciphers on;



  16.         location ~ .*\.(php|php5)?$
  17.         {
  18.                 #fastcgi_pass  unix:/tmp/php-cgi.sock;
  19.                 fastcgi_pass  127.0.0.1:9000;
  20.                 fastcgi_index index.php;
  21.                 include fastcgi.conf;
  22.         }
  23.         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  24.         {
  25.                 expires 30d;
  26.         }
  27.         location ~ .*\.(js|css)?$
  28.         {
  29.                 expires 1h;
  30.         }
  31.         #α¾²Ì¬¹æÔò
  32.         #include /alidata/server/nginx/conf/rewrite/phpwind.conf;
  33.         access_log  /alidata/log/nginx/access/wechat.log;
  34. }
复制代码


581

主题

110

回帖

4066

积分

管理员

积分
4066

众神之神

 楼主| 发表于 2017-7-25 09:43:04 | 显示全部楼层
如果是首次解析,可以看一下安全组的配置是否正确(阿里云ECS)

581

主题

110

回帖

4066

积分

管理员

积分
4066

众神之神

 楼主| 发表于 2018-6-29 18:12:57 | 显示全部楼层
linux 阿里云cert 目录:
  1. /alidata/server/nginx/conf/cert
复制代码

初次没有的话,先自行创建
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|十三博客 ( 鲁ICP备2023000528号 )

GMT+8, 2026-6-1 16:15 , Processed in 0.101754 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表