1.安装nginx
tar zxvf nginx-1.9.9.tar.gz
./configure --prefix=/usr/local/nginx
make
make install
vim /usr/local/nginx/conf/nginx.conf
listen 80
改成8099
服务器上没有冲突的端口
如果报错:
the HTTP gzip module requires the zlib library 则安装:yum install zlib zlib-devel 之后再删掉nginx重新解压
执行 /usr/local/nginx/sbin/nginx
netstat -nltp|grep 8099看是否端口已经起来
2. yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc mysql-devel php-devel php spawn-fcgi
3.建一个你的用户 useradd zouhuiying -G zouhuiying
4.解压wordpress安装包
mv wordpress /home/zouhuiying/
cd /home/zouhuiying/wordpress/
vim run.sh
#!/bin/sh
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u zouhuiying -g zouhuiying -f /usr/bin/php-cgi -P /var/run/fastcgi-php.pid
chmod 777 run.sh
5.mysql
新建一个数据库
create database wp;
设置这个库的权限和密码
grant all on *.* to root@'%' identified by "mima" WITH GRANT OPTION;
刷新数据库
flush privileges;
测试mysql -uroot -h192.168.139.174 -pmima wp; 如能进入mysql则说明连接成功
进入wordpress的目录
cp wp-config-sample.php wp-config.php
vim wp-config.php
define('DB_NAME', 'wp');
define('DB_USER', 'root');
define('DB_PASSWORD', 'mima');
define('DB_HOST', '192.168.139.174');
5.更改nginx配置文件
vim /usr/local/nginx/conf/nginx.conf
第一行加user zouhuiying;(刚才新建的用户)
server {
listen 8099;
server_name 192.168.139.174;
access_log /home/zouhuiying/log/access.log;
location / {
root /home/zouhuiying/wordpress;
index index.html index.htm index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
set $path_info "/";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/zouhuiying/wordpress;
}
fastcgi_param SCRIPT_FILENAME /home/zouhuiying/wordpress/$real_script_name;
fastcgi_param script_name $real_script_name;
fastcgi_param path_info $path_info;
include /usr/local/nginx_wordpress/conf/fastcgi_params;
6.
mkdir /home/zouhuiying/log
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u zouhuiying -g zouhuiying -f
/usr/bin/php-cgi -P /var/run/fastcgi-php.pid
./run.[img]shQQ图片20151227224101.png[/img]
重启nginx服务
[url]http://192.168.139.174:8099/[/url]查看是否成功
7
.mysql -uroot -h192.168.139.174 -pmima haowordpress;
show tables 能看到一堆表
cd /home/zouhuiying
chmod -R 777 wordpress/
[url]http://192.168.139.174:8099/wp-admin/ [/url]访问如果成功,则就完成。