This website requires JavaScript.

Windows Azure 下Linux虚拟机部署WordPress

本文为Windows Azure 下Linux虚拟机部署WordPress的指导.使用的LAMP环境

安装LAMP环境

  1. 检查是否有新版本更新
do-release-upgrade
  1. 安装安全补丁
unattended-upgrade
  1. 安装LAMP包
apt-get install taksel
```

4.  执行tasksel选择 LAMP包

```
tasksel
```

## 安装SMTP

1.  安装SMTP服务用来发送邮件

```
apt-get install postfix
```
2.  设置域名
3.  安装Mail组件

```
apt-get install mailutils
```

4.  发送测试邮件

```
echo "Test mail from postfix" | mail -s "Test Postfix" youremail@email.com
```
Mail日志查看

```
tail /var/log/mail.log
```

## 建立Web站点

1.  可以理解为虚拟目录,以域名bihell.com为例

```
mkdir -p /var/www/bihell.com/public_html
chown -R $USER:$USER /var/www/bihell.com/public_html
chmod -R 755 /var/www
cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/bihell.com.conf
```

2.  修改配置

```
vim /etc/apache2/sites-available/bihell.com
```
内容编辑如下:
VirtualHost *:80>
 ServerName bihell.com
 ServerAlias www.bihell.com

ServerAdmin webmaster@bihell.com
 DocumentRoot /var/www/bihell.com/public_html
 <Directory />
 Options FollowSymLinks
 AllowOverride All
 </Directory>
 <Directory /var/www/>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 allow from all
 </Directory>
 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

```

3.  启用站点

```
a2ensite example.com
a2dissite 000-default
```

4.  加载一些模块,用来加强性能和开启缓存

```
a2enmod rewrite
a2enmod headers
a2enmod expires
```

5.  重启apache服务以后如果发现下面提示,则修改apache配置文件
* Restarting web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 100.88.124.9 for ServerName
```

```
vim /etc/apache2/apache2.conf
```
添加一行
ServerName bihell.com
```

6.  检查配置

```
grep -R AllowOverride /etc/apache2
```
看到如下文字说明配置正确
/etc/apache2/sites-enabled/bihell.com: AllowOverride All
/etc/apache2/sites-enabled/bihell.com: AllowOverride All
/etc/apache2/sites-enabled/bihell.com: AllowOverride All
```

7.  创建个html文件进行访问测试

```
vim /var/www/bihell.com/public_html/index.html
```

8.  修改Hosts文件

```
vim /etc/hosts
```
把自己站点域名加进去
42.159.134.77 bihell.com
```

## 安装WordPress

这里可以参考我其他几篇博文.
[迁移WordPress](http://www.bihell.com/migrate-wordpress/)
[在LNMP环境中安装WordPress](http://www.bihell.com/lnmp-install-wordpress/)

## 优化配置

## 监控Apache 流量

1.  安装apachetop软件,然后执行apachetop命令即可

```
apt-get install apachetop
```

### 限制Mysql 内存使用

1.  因为用的是小的虚拟机,我们要限制Mysql内存使用

```
cp /etc/mysql/my.cnf my-original.cnf
```
修改如下
 # * Fine Tuning
 #
 key_buffer = 1M
 max_allowed_packet = 1M
 thread_stack = 64K
 thread_cache_size = 8
 innodb_buffer_pool_size = 1M
 ```
有可能没有innodb_buffer_pool_size这一项,需要手工添加. 注意要添加在[mysqld]章节里面

### 检查错误链接

1.  有一些404和500错误的页面,可以查看日志,然后清理

```
tail -n 10000 /var/log/apache2/access.log | awk '($9 !~ /200|304/)' | awk '{print $9,$7}' | sort | uniq
```

## 参考文档

[How to setup a rock solid VM on Windows Azure for your WordPress blogs](http://www.codeproject.com/Articles/597944/HowplustoplussetupplusaplusrockplussolidplusVMplus)
0条评论
avatar