一、 环境
ubuntu12.04.4
nginx 1.6.0
mariadb 10.0
更新系统补丁
sudo apt-get
update
sudo apt-get dist-upgrade
-y
挂载swap分区
dd
if=/dev/zeroof=/media/fasthdd/swapfile.img bs=1024
count=1M
mkswap
/media/fasthdd/swapfile.img
sudo vim
/etc/fstab
/media/fasthdd/swapfile.img swap swap sw
00
swapon
/media/fasthdd/swapfile.img
cat /proc/swaps
grep ‘Swap‘
/proc/meminfo
二、 安装nginx
wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add
nginx_signing.key
在/etc/apt/sources.list末尾添加
deb
http://nginx.org/packages/ubuntu/ precise nginx
deb-srchttp://nginx.org/packages/ubuntu/ precise
nginx
sudo apt-get
update
sudo apt-get install nginx
-y
三、 安装PHP
sudo apt-get
installpython-software-properties
sudo add-apt-repository
ppa:ondrej/php5
sudo apt-get install -y php5
php5-mysqlphp5-fpm
四、 安装数据库MariaDB
安装数据库MariaDB10.0
sudo apt-get
installpython-software-properties -y
sudo apt-key adv --recv-keys
--keyserverhkp://keyserver.ubuntu.com:80
0xcbcb082a1bb943db
sudo add-apt-repository
‘debhttp://mirrors.syringanetworks.net/mariadb/repo/10.0/ubuntu precise
main‘
sudo apt-get
update
sudo apt-get install mariadb-server
-y
查询DB编码
mysql -uroot -p
show variables like
‘character\_set\_%‘;
sudo vim
/etc/mysql/my.cnf
默认UTF8,不用加,加以下会出错
default-character-set=utf8
init_connect=‘SETNAMES utf8‘
加入到[mysqld]
lower_case_table_names=1
skip-name-resolve
sudo /etc/init.d/mysql
reload
五、 部署wordpress
下载wordpress的tar包,解压并拷贝至/home/www/www
sudo chown -R nginx:nginx
/home/www/www
sudo chmod -R 711
/home/www/www
配置nginx站点
sudo vim /etc/php5/fpm/php.ini
cgi.fix_pathinfo=1
sudo vim
/etc/php5/fpm/pool.d/www.conf
user =
nginx
group
= nginx
listen.mode= 0666
sudo /etc/init.d/php5-fpm
restart
#将socket文件,放在内存文件区域,有利于提升性能
sudo vim
/etc/nginx/conf.d/default.conf
##########################################################
server {
listen
80;
server_name
*.aser.me aser.me*.showall.org showall.org;
root
/home/www/www;
index
index.php;
location = /favicon.ico
{
log_not_found off;
access_log off;
}
location /
{
try_files $uri $uri//index.php?$args ;
}
location ~*
\.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_passunix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME
/home/www/www$fastcgi_script_name;
include
fastcgi_params;
}
error_page
500 502 503 504 /50x.html;
location = /50x.html
{
root
/usr/share/nginx/html;
}
location ~ /\.ht
{
deny
all;
}
location ~*
/(?:uploads|files)/.*\.php$ {
deny
all;
}
}
##########################################################
sudo service php5-fpm
restart
sudo service nginx
restart
配置wordpress数据库
sudo vim
/etc/hosts
127.0.0.1
dbhost
建立wordpress库
mysql -uroot-p
CREATE DATABASE
wordpress;
GRANT ALL PRIVILEGES ON wordpress.*
TO"wordpress"@"dbhost" IDENTIFIED BY "password";
GRANT ALL PRIVILEGES ON wordpress.*
TO"wordpress"@"localhost" IDENTIFIED BY "password";
GRANT ALL PRIVILEGES ON wordpress.*
TO"wordpress"@"127.0.0.1" IDENTIFIED BY "password";
FLUSH PRIVILEGES;
EXIT;
配置wordpress连接数据库的信息
sudo cp -rp
wp-config-sample.phpwp-config.php
sudo vim
/home/www/www/wp-config.php
define(‘DB_NAME‘,‘wordpress‘);
define(‘DB_USER‘,‘wordpress‘);
define(‘DB_PASSWORD‘,‘password‘);
define(‘DB_HOST‘,‘dbhost‘);
更安全更详细设置参考:
http://conanca.iteye.com/blog/1044256
http://codex.wordpress.org/zh-cn:%E5%AE%89%E8%A3%85_WordPress
http://codex.wordpress.org/Nginx
http://wiki.nginx.org/WordPress