sudo apt-get update
sudo apt-get install nginx php5-fpm php5-cli php5-curl php5-gd php5-mcrypt php5-mysql php5-cgi mysql-server
期间会提示设置mysql密码,下载安装好nginx和mysql后在/etc/nginx/sites-available/目录下创建文件wordpress写入如下代码并保存。
# Upstream to abstract backend connection(s) for php
upstream php {
server unix:/var/run/php5-fpm.sock;
}
server {
## Your only path reference.
root /srv/www/wordpress/public_html;
listen 80;
## Your website name goes here. Change to domain.ltd in VPS
server_name _;
access_log /srv/www/wordpress/logs/access.log;
error_log /srv/www/wordpress/logs/error.log;
## This should be in your http block and if it is, it's not needed here.
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
然后将此文件复制到/etc/nginx/sites-sites-enabled/目录下,分别删除两个文件夹中的default文件。
然后是下载和解压wordpress(代码已修改为下载最新中文版wordpress)
sudo mkdir -p /srv/www/wordpress/logs/
sudo mkdir -p /srv/www/wordpress/public_html
cd /srv/www/wordpress/public_html
sudo wget http://cn.wordpress.org/latest.tar.gz
sudo tar xzvf latest.tar.gz
sudo mv wordpress/* .
设置mysql数据库(其中的raspi为wordpress数据库的密码)
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5340 to server version: 3.23.54
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO "wordpress"@"localhost"IDENTIFIED BY "raspi";
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql> EXIT
Bye
$
将/srv/www/wordpress/public_html目录下的wp-config-sample.php文件名改为wp-config.php然后打开修改其中的以下几行
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'raspi');
重启 nginx 和 php5-fpm
sudo cp wp-config-sample.php wp-config.php
sudo edit wp-config.php
在浏览器中输入
http://
你的树莓派ip/wp-admin/install.php,就可以安装wordpress啦!
我使用的是网通的1M ADSL,动态域名解析用的是花生壳和它提供的免费二级域名