网站图怎么做会高清,抖音上的小程序怎么赚钱,常德网站建设wynet123,建设工程合同范本工程施工合同范本一、将域名绑定到ip上1、环境介绍#xff1a;阿里云服务器ESC#xff08;美国硅谷#xff09;
2、购买域名
3、备案
注#xff1a;由于我买的是美国地区服务器#xff0c;所以不用备案#xff0c;如果买的国内服务器#xff0c;这里需要添加一个备案操作。
4、域名实名认…一、将域名绑定到ip上1、环境介绍阿里云服务器ESC美国硅谷
2、购买域名
3、备案
注由于我买的是美国地区服务器所以不用备案如果买的国内服务器这里需要添加一个备案操作。
4、域名实名认证
5、将域名绑定到云服务器公网ip
阿里云官网域名解析地址https://dc.console.aliyun.com/next/index#/domain/list/all-domain
5.1、对购买的域名进行解析点击解析按钮5.2、进入解析域名页面后点击添加记录按钮看上图可以清晰的看出来我绑定了5个子域名现在访问子域名就直接访问我的ip所在的云服务器了。
到此将域名绑定到ip地址的操作就完成了剩下的就需要在我们云服务器上进行相应操作了。二、实现浏览器访问不同子域名服务器进入不同子目录
环境介绍centos7.4、LNMP
注上面将域名解析后如果我们不在本地nginx进行配置访问的就是nginx的默认目录为了实现不同子域名对应不同目录我们就需要对nginx进行相应SERVER的配置。
1、使用的是yum安装的nginx这里直接配置nginx子配置文件就可以了。 /etc/nginx/conf.d 文件夹下注yum安装nginx https://blog.csdn.net/m_nanle_xiaobudiu/article/details/80640293在这里我将www.a.xiaobudiu.conf 和 www.b.xiaobudiu.conf 代码展示出来。
www.a.xiaobudiu.top.conf 代码
server {listen 80;server_name www.a.xiaobudiu.top;#charset koi8-r;#access_log /var/log/nginx/host.access.log main;location / {root /data/main;index index.html index.htm;}#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 /usr/share/nginx/html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {# proxy_pass http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {# root html;# fastcgi_pass 127.0.0.1:9000;# fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;# include fastcgi_params;#}# deny access to .htaccess files, if Apaches document root# concurs with nginxs one##location ~ /\.ht {# deny all;#}
}www.b.xiaobudiu.top.conf 代码
server {listen 80;server_name www.b.xiaobudiu.top;#charset koi8-r;#access_log /var/log/nginx/host.access.log main;location / {root /data/b;index index.html index.htm;}#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 /usr/share/nginx/html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {# proxy_pass http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {# root html;# fastcgi_pass 127.0.0.1:9000;# fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;# include fastcgi_params;#}# deny access to .htaccess files, if Apaches document root# concurs with nginxs one##location ~ /\.ht {# deny all;#}
}
注nginx.conf 我没进行改动yum安装之后是什么样就是什么样。为了测试方便我这里只对conf.d下的子配置文件进行了更改。2、到这里其实配置已经结束了systemctl restart nginx 重启一下nginx清除一下浏览器缓存现在就可以在浏览器中看到效果了。
注意想要实现浏览器访问不同子域名对应不同文件夹的效果域名解析和nginx配置文件一定要两者都有浏览器访问时才会访问到对应目录。按照上面的步骤来操作就没问题了三、效果演示1、访问www.a.xiaobudiu.top2、访问www.b.xiaobudiu.top