阿里云服务器怎么绑定域名

阿里云服务器怎么绑定域名?下面来解释一下Nginx和Apache绑定域名方法。

Nginx 服务绑定域名

以 YUM 安装的 Nginx 为例:

  1. 执行命令 vi /etc/nginx/nginx.conf 编辑 Nginx 的配置文件,将默认的server {...} 配置修改为以下内容:
    1. server {
    2. listen 80 default_server;
    3. server_name www.123.com;
    4. root /home/web1;
    5. location / {
    6. }
    7. error_page 404 /404.html;
    8. location = /40x.html {
    9. }
    10. error_page 500 502 503 504 /50.xhtml;
    11. location = /50x.html {
    12. }
    13. }
    14. server {
    15. server_name www.abc.com;
    16. root /home/web2;
    17. location / {
    18. }
    19. error_page 404 /404.html;
    20. location = /40x.html {
    21. }
    22. error_page 500 502 503 504 /50x.html;
    23. location = /50x.html {
    24. }
    25. }
    • 访问 www.123.com 时,跳转到 /home/web1 目录。
    • 访问 www.abc.com 时,跳转到 /home/web2 目录。
  2. 执行命令 nginx -s reload 重启 Nginx 服务。

 

Apache 服务绑定域名

以一键安装包配置的 Apache 环境为例:

  1. 执行命令 cd /alidata/server/httpd/conf/vhosts/ 进入站点配置文件目录。
  2. 执行命令 vi aa.conf 新建一个配置文件,按下键盘上的字母 “I” 键,复制并粘贴以下内容:
    1. Order allow,deny
    2. Deny from all
    3. DocumentRoot /alidata/www/test
    4. ServerName www.test.com
    5. ServerAlias test.com
    6. ErrorLog "/alidata/log/httpd/test-error.log"
    7. CustomLog "/alidata/log/httpd/test.log"

    注意:您需要修改对应的日志名字以区分不同网站的日志信息。

  3. 执行命令 /alidata/server/httpd/bin/apachectl restart 重启 Apache 服务。

标签:,

上一篇:

下一篇: