CentOS 6.4 php环境配置以及安装wordpress

1. nginx php-rpm 包升级

sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

2. 安装mysql

sudo yum install mysql mysql-server
sudo /etc/init.d/mysqld restart
sudo /usr/bin/mysql_secure_installation

 3. 安装nginx

sudo yum install nginx
sudo /etc/init.d/nginx start

 这时你可以直接访问ip或者域名,查看nginx是否安装成功

4. 安装php

sudo yum --enablerepo=remi install php-fpm php-mysql

5. 配置php

sudo vi /etc/php.ini
#cgi.fix_pathinfo=1
cgi.fix_pathinfo=0
doc_root = /usr/share/nginx/html

6. 配置nginx

默认的配置文件nginx.conf

sudo vi /etc/nginx/nginx.conf
processer = 4

 

sudo vi /etc/nginx/conf.d/default.conf

 

#
# The default server
#
server {
    listen       80;
    server_name example.com;

   
    location / {
        root   /usr/share/nginx/html;
        index index.php  index.html index.htm;
    }

    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

 1) location  下

添加index.php

 2) root 可以改成你想要的位置,如/var/www/wordpress

 3)server_name 改成你的域名或者ip或者localhost

 4) location ~ \.php$ { 下面的root要和上面location的一样

 5)fastcgi_param 帮助php解释器在document root找到php脚本

7. 配置php-fpm

sudo vi /etc/php-fpm.d/www.conf

 替换apahce到nginx

[...]
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;	will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
[...]

 重启php-fpm

sudo service php-fpm restart

 8.添加php测试页面

sudo vi /usr/share/nginx/html/info.php
sudo service nginx restart

 9. 添加开机自动重启

sudo chkconfig --levels 235 mysqld on
sudo chkconfig --levels 235 nginx on
sudo chkconfig --levels 235 php-fpm on

 上面环境配置好以后就可以安装wordpress了

1. 下载并解压

wget http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz

2. 创建数据库

mysql -u root -p
CREATE DATABASE wordpress;
CREATE USER wordpressuser@localhost;
SET PASSWORD FOR wordpressuser@localhost= PASSWORD("password");
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit

3. 配置wordpress

 复制配置文件并配置

cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php
vi ~/wordpress/wp-config.php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpressuser');

/** MySQL database password */
define('DB_PASSWORD', 'password');

复制wordpress到nginx的root目录下,

sudo cp -r ~/wordpress/* /var/www/html

可能需要php-gd

sudo yum install php-gd

重启nginx

sudo service httpd restart

 4 安装wordpress

访问你的域名http:xxx.com/wp-admin/install.php 来安装,很简单。

这样一个wordpress的博客配置就完成了。

转载于:https://www.cnblogs.com/iosdev/p/3394583.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值