设为首页 收藏本站
查看: 913|回复: 0

CentOS 6.x配置WordPress(LNMP)

[复制链接]

尚未签到

发表于 2015-8-21 13:00:15 | 显示全部楼层 |阅读模式
  一、实验环境:
  主机名               IP(Static)                   系统                                                    配置                                用途
wordpress         192.168.20.50        CentOS-6.4-x86_64-minimal          1CPU,1G RAM,20G DISK,1网卡         test

  **************************************************************************************
  二、配置步骤:
  1.关闭selinux和iptables:

  [iyunv@wordpress ~]# vi /etc/selinux/config
  将SELINUX=enforcing修改为SELINUX=disabled
  [iyunv@wordpress ~]# chkconfig iptables off
  [iyunv@wordpress ~]# chkconfig ip6tables off
  [iyunv@wordpress ~]# reboot
  2.下载wordpress,上传到root目录下:
  Wordpress下载地址:http://cn.wordpress.org/
  [iyunv@wordpress ~]# ls
  anaconda-ks.cfg  install.log  install.log.syslog  wordpress-3.8-zh_CN.tar.gz
  3.安装Nginx源:
  [iyunv@wordpress ~]# rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
  4.安装软件包支持:
  4.1.安装nginx:
  [iyunv@wordpress ~]# yum -y install nginx
  4.2.安装mysql数据库:
  [iyunv@wordpress ~]# yum -y install mysql-devel mysql-server
  4.3.安装PHP并支持mysql:
  [iyunv@wordpress ~]# yum -y install php-fpm php-mysql php-gd
  5.配置相关服务:
  5.1.配置mysql:
  (1).设置mysql数据库密码:
  [iyunv@wordpress ~]# service mysqld start
  [iyunv@wordpress ~]# mysqladmin -u root -p password 'rootpasswd'
  (2).创建wordpress数据库:
  [iyunv@wordpress ~]# mysql -uroot -prootpasswd
  mysql> CREATE DATABASE wordpress;                           /*创建名为wordpress的数据库;*/
  Query OK, 0 rows affected (0.00 sec)
  mysql> CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'wppasswd';            /*创建一个用户名为wpuser密码为wppasswd的用户;*/
  Query OK, 0 rows affected (0.00 sec)
  mysql> GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser' IDENTIFIED BY 'wppasswd';     /*给wpuser用于授予wordpress数据库权限;*/
  Query OK, 0 rows affected (0.00 sec)
  mysql> flush privileges;            /*刷新数据库;*/
  Query OK, 0 rows affected (0.00 sec)
  mysql> quit;            /*退出数据库;*/
  5.2.配置php-fpm:

  [iyunv@wordpress ~]# vi /etc/php-fpm.d/www.conf
  将:

  user = apache
  group = apache
  修改为:
  user = nginx
  group = nginx
  保存退出;
  5.3.配置nginx:
  [iyunv@wordpress ~]# vi /etc/nginx/conf.d/default.conf
  
  server {
      listen       80;
      server_name  localhost;
  

      #charset koi8-r;
      #access_log  /var/log/nginx/log/host.access.log  main;
  

      location / {
          #更改网站根目录下
          root   /var/www/html/wordpress;
          #添加php默认页面
          index  index.php index.html index.htm;
  

          #启用伪静态规则,可以支持自定义链接和日志别名
          if (!-e $request_filename)
          {
          rewrite ^/(.+)$ /index.php last;
          }
  

      }
  

      #error_page  404              /404.html;
  

      # redirect server error pages to the static page /50x.html
      #
      error_page   500 502 503 504  /50x.html;
      location = /50x.html {
          root   /var/www/html/wordpress;
      }
  

      # proxy the PHP scripts to Apache listening on 127.0.0.1:80
      #
      #location ~ \.php$ {
      #    proxy_pass   http://127.0.0.1;
      #}
  

      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
      #
          #启用php-fpm支持
        location ~ \.php$ {
      #    root           html;
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           fastcgi_param  SCRIPT_FILENAME  /var/www/html/wordpress$fastcgi_script_name;
           include        fastcgi_params;
       }
  

      # deny access to .htaccess files, if Apache's document root
      # concurs with nginx's one
      #
      #location ~ /\.ht {
      #    deny  all;
      #}
  }
  注意:红色标记部分为修改部分,请仔细核对;

  5.4.配置WordPress:
  (1).将tar.gz解压:
  [iyunv@wordpress ~]# ls
  anaconda-ks.cfg  install.log  install.log.syslog  wordpress-3.8-zh_CN.tar.gz
  [iyunv@wordpress ~]# tar -zxvf wordpress-3.8-zh_CN.tar.gz
  [iyunv@wordpress ~]# ls
  anaconda-ks.cfg  install.log  install.log.syslog  wordpress wordpress-3.8-zh_CN.tar.gz
  (2).将wordpress放置/var/www/html目录下:
  [iyunv@wordpress ~]# mkdir -p /var/www/html
  [iyunv@wordpress ~]# cd /var/www/html
  [iyunv@wordpress html]# mv ~/wordpress ./
  (3).设置wordpress的所有者和权限:
  [iyunv@wordpress html]# chown -R nginx:nginx /var/www/html/wordpress
  [iyunv@wordpress html]# chmod -R 755 /var/www/html/wordpress
  (4).修改wordpress配置文件:
  [iyunv@wordpress html]# cd wordpress/
  [iyunv@wordpress wordpress]# mv wp-config-sample.php wp-config.php
  [iyunv@wordpress wordpress]# vi 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', 'wpuser');
  

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

  /** MySQL hostname */
  define('DB_HOST', 'localhost');
  ………………省略若干行………………
  6.启动服务并设置为自启动:
[iyunv@wordpress ~]# service mysqld restart
  [iyunv@wordpress ~]# service php-fpm start
  [iyunv@wordpress ~]# service nginx start
  [iyunv@wordpress ~]# chkconfig mysqld on
  [iyunv@wordpress ~]# chkconfig php-fpm on
  [iyunv@wordpress ~]# chkconfig nginx on
  7.初始化WordPress:
  浏览器中输入http://192.168.20.50,回车:
  

  配置完毕;

  

  

  

  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-102199-1-1.html 上篇帖子: MAC自带的lnmp 下篇帖子: 和LNMP相比,LNMPA是否效率更高?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表