码迷,mamicode.com
首页 > Web开发 > 详细

十、LNMP(php redis)wordpress部署

时间:2018-06-02 11:34:23      阅读:273      评论:0      收藏:0      [点我收藏+]

标签:linux

1.安装依赖包

yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel gd-devel zlib-devel mcrypt mhash
cd /application/tools/
wget http://ftp.gnu.org/gnu/libiconv/libiconv-1.15.tar.gz
tar xf libiconv-1.15.tar.gz
cd libiconv-1.15
./configure --prefix=/usr/local/libiconv
make
make install

2.php7编译安装

cd /application/tools/
wget http://cn2.php.net/get/php-7.1.17.tar.gz/from/this/mirror
tar xf php-7.1.17.tar.gz
cd php-7.1.17
./configure \
--prefix=/application/php-7.1.17 \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-fpm-user=www \
--with-fpm-group=www \
--with-config-file-path=/application/php-7.1.17/etc \
--with-config-file-scan-dir=/application/php-7.1.17/etc/php.d \
--with-mcrypt=/usr/local/libmcrypt \
--with-png-dir=/usr/local/libpng \
--with-jpeg-dir \
--with-freetype-dir \
--with-bz2 \
--with-curl \
--with-gd \
--with-mhash \
--with-openssl \
--with-zlib \
--with-gettext \
--with-xmlrpc \
--enable-mysqlnd \
--enable-bcmath \
--enable-fpm \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-pcntl \
--enable-soap \
--enable-sockets \
--enable-session \
--enable-zip

make
make install
chown -R www.www /application/php-7.1.17
ln -s /application/php-7.1.17 /application/php
chown -R www.www /application/php
cp php.ini-production /application/php/etc/php.ini
cd /application/php/etc
cp php-fpm.conf.default php-fpm.conf
cd php-fpm.d/
cp www.conf.default www.conf

3.redis扩展

cd /application/tools/
wget https://codeload.github.com/phpredis/phpredis/zip/develop
unzip develop
cd phpredis-develop/
/application/php/bin/phpize
./configure --with-php-config=/application/php/bin/php-config
make && make install
vim /application/php/etc/php.ini
extension=redis.so

4.nginx-phpfpm

worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name lhj.blog.com;
location / {
root html;
index index.php index.htm;
}

    location ~* \.(php|php5)$ {
        root html/blog;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
       }

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

}

5.访问测试
技术分享图片

6.wordpress

cd /application/tools/
wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
tar xf wordpress-4.9.4-zh_CN.tar.gz
mkdir /application/nginx/html/blog
mv wordpress /application/nginx/html/blog/
chown -R www.www /application/nginx/html/blog
cd /application/nginx/html/blog
mv wordpress/* ./

修改mycat设置
vim /application/mycat/conf/schema.xml
<mycat:schema xmlns:mycat="http://io.mycat/">;
<!--定义MyCAT实例的逻辑库和逻辑表-->
<schema name="wordpress" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn_test"> </schema>
<!--定义MyCAT逻辑表中提到的所有dataNode所在的真实Host,以及dataNode所属的真实数据库-->
<dataNode name="dn_test" dataHost="dn85" database="wordpress" />
<!--定义dataNode提到的dataHost的连接限制数、负载均衡取向,以及真实的读写地址(writeHost和readHost)-->
<!--balance属性 负载均衡类型,目前的取值有3种-->
<!--balance="0", 所有读操作都发送到当前可用的writeHost上-->
<!--balance="1",所有读操作都随机的发送到readHost-->
<!--balance="2",所有读操作都随机的在writeHost、readhost上分发-->

    &lt;!--writeType属性 负载均衡类型,目前的取值有3种--&gt;
    &lt;!--writeType="0", 所有写操作都发送到可用的writeHost上--&gt;
    &lt;!--writeType="1",所有写操作都随机的发送到readHost--&gt;
    &lt;!--writeType="2",所有写操作都随机的在writeHost、readhost分上发--&gt;

    &lt;!--switchType="-1,1,2,3" 是否启用主从切换--&gt;
    &lt;!--switchType=‘-1‘ 表示不自动切换--&gt;
    &lt;!--switchType=‘1‘ 默认值,表示自动切换--&gt;
    &lt;!--switchType=‘2‘ 基于MySQL主从同步的状态决定是否切换,心跳语句为 show slave status--&gt;
    &lt;!--switchType=‘3‘基于MySQL galary cluster的切换机制(适合集群)(1.4.1),心跳语句为 show status like ‘wsrep%‘--&gt;
    &lt;dataHost name="dn85" maxCon="1000" minCon="3" balance="1"
     writeType="0" dbType="mysql" dbDriver="native" switchType="-1"  slaveThreshold="100"&gt;
    &lt;!--真实的读写地址--&gt;
            &lt;heartbeat&gt;select user()&lt;/heartbeat&gt;
            &lt;writeHost host="200_M"  url="172.16.1.200:3306" user="wordpress" password="123456"&gt;
                    &lt;readHost host="105_S1" url="172.16.1.105:3306" user="wordpress" password="123456"/&gt;
            &lt;/writeHost&gt;
    &lt;/dataHost&gt;

</mycat:schema>

vim /application/mycat/conf/server.xml
<user name="wordpress">
<property name="password">123456</property>
<property name="schemas">wordpress</property>
</user>

数据库中创建用户和库
create user wordpress@‘%‘ identified by ‘123456‘;
create database wordpress char set utf8;
grant all on wordpress.* to wordpress@‘%‘;
flush privileges;
/application/mycat/bin/mycat stop
/application/mycat/bin/mycat start

nginx.conf修改
location ~* .(php|php5)$ {
root html/blog;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}

7.网页访问安装
技术分享图片
技术分享图片

十、LNMP(php redis)wordpress部署

标签:linux

原文地址:http://blog.51cto.com/13712476/2123359

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!