阿里云腾讯云服务器ubuntu多域名配置
1、将域名A记录解析到服务器的公网 IP 地址,把www也添加A记录到公网ip
2、ubuntu系统修改hosts文件,hosts文件目录为/etc/hosts,可以用vim编辑 sudo vim /etc/hosts
添加内容:
127.0.0.1 a.com www.a.com
127.0.0.1 b.com www.b.com
编辑后,你需要重新启动一下你的网络。命令:/etc/init.d/networking restart
3、创建站点目录,比如/data/www/a 和/data/www/b ;分别在a文件夹下和b文件夹下新建index.html文件,内容自己随便写。
4、进入目录 /etc/apache2/sites-available/ ;可以看到有一个默认文件000-default.conf,修改内容如下:
<VirtualHost *:80>
ServerName a.com
ServerAlias www.a.com
<Directory /data/www/a>
#AllowOverride伪静态
AllowOverride All
Require all granted
</Directory>
ServerAdmin [email protected]
DocumentRoot /data/www/a
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
复制000-default.conf文件并命名为001-default.conf作为站点b的配置文件,相应修改域名和网站根目录
5、启动站点
sudo a2ensite 000-default.conf
sudo a2ensite 001-default.conf如果提示需要运行apache load,你可以按照提示运行命令。
6、重启Apache service
sudo service apache2 restart
7、成功
中途遇到的问题:apache无法启动
1、提示:Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
解决方法:命令:apache2ctl configtest;可以查看出现错误文件行号,主要是000-default.conf出现错误,注意空格。
2、提示:Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}
解决方法:hosts文件配置错误,查看是否添加了域名指向127.0.0.1
推荐阅读
-
解析阿里云ubuntu12.04环境下配置Apache+PHP+PHPmyadmin+MYsql
-
如何使用阿里云服务器解析域名?
-
在腾讯云的ubuntu服务器上面安装git服务器
-
阿里云服务器安装配置mysql数据库
-
使用阿里云服务器的总结一----修改配置,阿里----
-
阿里云服务器的域名云解析CDN加速开启的方法
-
阿里云邮箱服务器设置方法(阿里云com域名注册条件)
-
node链接mongodb数据库的方法详解【阿里云服务器环境ubuntu】
-
阿里云服务器ECS上ubuntu安装nginx后默认站点页面打开错误,显示无法访问此网站
-
阿里云服务器ECS上ubuntu安装nginx后默认站点页面打开错误,显示无法访问此网站