本文介绍如何在AWS EC2一个实例下安装多个wordpress。我之前已在/var/www/
安装了一个WordPress,安装过程见博文《已将博客迁移到亚马逊云:简要笔记》。在此基础上再安装一个WordPress。
步骤1:下载wordpress
SSH登录到AWS EC2,进入到/var/www/
目录,用wget
工具下载WordPress,相关命令如下:
wget https://cn.wordpress.org/wordpress-4.2.2-zh_CN.tar.gz tar -xvf wordpress-4.2.2-zh_CN.tar.gz mv wordpress zhilitea.com sudo chmod -R 755 zhilitea.com
步骤2:web服务器配置文件
在/etc/apache2/sites-available/
目录下创建配置文件zhilitea.com.conf
,对着000-default.conf
修改,最后内容如下(以zhilitea.com为例):
<VirtualHost *:80> ServerAdmin admin@zhilitea.com ServerName zhilitea.com ServerAlias www.zhilitea.com DocumentRoot /var/www/zhilitea.com ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
启用设置文件
sudo a2ensite zhilitea.com.conf sudo service apache2 restart
步骤3:修改hosts文件
打开/etc/hosts
文件,在文件末尾添加如下内容:
# added by sparkandshine # xx.xx.xx.xx为AWS EC2 Elastic IP xx.xx.xx.xx zhilitea.com
步骤4:修改DNS解析
将zhilitea.com的A记录@
解析到xx.xx.xx.xx
(为AWS EC2 Elastic IP)。
@ --> xx.xx.xx.xx # xx.xx.xx.xx为AWS EC2 Elastic IP
好了,大功告成。现在可以同时访问sparkandshine.net和zhilitea.com。
问题及解决
访问主机zhilitea.com一切正常,但访问文章时,比如http://zhilitea.com/just-for-test/,就提示如下问题:
Not Found
The requested URL /just-for-test/ was not found on this server.
Apache/2.4.7 (Ubuntu) Server at zhilitea.com Port 80
原来是这个站点目录下缺少.htaccess
文件,详情见博文《解决“The requested URL was not found on this server”》。
参考资料:
[1]Blog: How To Set Up Apache Virtual Hosts on Ubuntu 14.04 LTS
[2]Blog: MULTIPLE WEBSITES ON AMAZON EC2 LINUX WITH VIRTUAL HOSTS
[3]Blog: Host Multiple Sites on a Single Amazon EC2 Instance
专题: AWS上建立wordpress站点 (6/10)
微信赞赏
支付宝赞赏
Reload apache configuration for a site without restarting apache:
<br/>sudo /etc/init.d/apache2 reload<br/>sudo service apache2 reload<br/>
Pingback: 批量搭建wordpress站点:修改url、博客名称、博客描述、用户名 | Spark and Shine