mysql+php+mem+openresty

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql+php+mem+openresty相关的知识,希望对你有一定的参考价值。

###########mysql###########

1. mysql安装

 

(1)tar zxf mysql-boost-5.7.17.tar.gz

(2)yum install cmake-2.8.12.2-4.el6.x86_64.rpm  -y

cd mysql-5.7.17/

(3)cmake-DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql-DMYSQL_DATADI=/usr/local/lnmp/mysql/data-DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_NGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0/

(4)根据报错依次安装需要的包,没有错误之后执行下一步

(5)myaqlMake && make install

2.Mysql 配置

[[email protected] mysql-5.7.17]# groupadd -g 27 myaql

[[email protected] mysql-5.7.17]# useradd -u 27 -g 27 -s /sbin/nologin -M -d /usr/local/lnmp/mysql/ mysql

[[email protected] mysql-5.7.17]# id mysql

uid=27(mysql) gid=27(myaql) groups=27(myaql)

[[email protected] mysql-5.7.17]# cd /usr/local/lnmp/mysql/

[[email protected] mysql]# chown mysql.mysql . -R

[[email protected] mysql]# cd support-files/

[[email protected] support-files]# ls

magic  my-default.cnf  mysqld_multi.server  mysql-log-rotate  mysql.server

[[email protected] support-files]# ll /etc/my.cnf 

-rw-r--r--. 1 root root 251 Aug  9  2013 /etc/my.cnf

[[email protected] support-files]# cp my-default.cnf /etc/my.cnf 

cp: overwrite `/etc/my.cnf‘? y

[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld

 

[[email protected] mysql]# mysqld --initialize --user=mysql    ##进行初始化

[[email protected] erver1 mysql]# chown root.root . -R

[[email protected] mysql]# chown mysql data -R

[[email protected] mysql]# ll

 技术分享

[[email protected] mysql]# /etc/init.d/mysqld start

Starting MySQL.Logging to ‘/usr/local/lnmp/mysql/data/server1.err‘.

 SUCCESS!

 

[[email protected] data]# mysql_secure_installation   ##密码设置由大小写数字符号组成

3..php安装

Tar zxf php-5.6.20.tar.bz2

Cd php-5.6.20

./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-gmp --with-gettext --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-fpm --enable-mbstring --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash

随着提示安装所需要的包

yum install libmcrypt-2.5.8-9.el6.x86_64.rpm libmcrypt-devel-2.5.8-9.el6.x86_64.rpm -y

yum install libxml2-devel -y

yum install -y bison

yum install curl-devel freetype-devel gmp-devel net-snmp-devel -y

yum install re2c-0.13.5-1.el6.x86_64.rpm -y

yum provides */png.h

  yum install -y libpng-devel-1.2.49-1.el6_2.x86_64

yum provides */jpeglib.h

  yum install libjpeg-turbo-devel -y

Make && make install

4.php配置

[[email protected] ~]# cd php-5.6.20

[[email protected] php-5.6.20]# cd sapi/

[[email protected] sapi]# cd fpm/

[[email protected] fpm]# file init.d.php-fpm

init.d.php-fpm: POSIX shell script text executable

[[email protected] fpm]# cp init.d.php-fpm /etc/init.d/php-fpm

 

[[email protected] fpm]# chmod +x /etc/init.d/php-fpm 

[[email protected] fpm]# cd /usr/local/

[[email protected] local]# cd lnmp/php/etc/

[[email protected] etc]# vim php.ini 

技术分享

[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf

[[email protected] etc]# vim php-fpm.conf

技术分享

[[email protected] etc]# /etc/init.d/php-fpm start

Starting php-fpm  done

[[email protected] etc]# vim ~/.bash_profile 

技术分享

[[email protected] etc]# source ~/.bash_profile 

[[email protected] etc]# netstat -antlp |  grep :9000

tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      1374/php-fpm      

[[email protected] nginx]# ln -s /usr/local/lnmp/nginx/sbin/nginx /sbin/

[[email protected] conf]# vim nginx.conf

技术分享

 技术分享

[[email protected] nginx]# nginx

[[email protected] nginx]# netstat -antlp  | grep :80

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      1418/nginx          

[[email protected] html]# vim index.php

技术分享

[[email protected] html]# /etc/init.d/iptables stop

 

 

测试:

技术分享

5..论坛

[[email protected] ~]# unzip Discuz_X3.2_SC_UTF8.zip 

[[email protected] ~]# mv upload/ /usr/local/lnmp/nginx/html/bbs

[[email protected] ~]# cd /usr/local/lnmp/nginx/html/bbs

[[email protected] bbs]# chmod 777 config/ data/ uc_client/ uc_server/ -R

[[email protected] local]# cd /usr/local/lnmp/php/etc/

[[email protected] etc]# vim php.ini 

技术分享

技术分享

技术分享

[[email protected] etc]# chmod 755 /usr/local/lnmp/mysql/data/

[[email protected] etc]# /etc/init.d/php-fpm reload

测试:

技术分享

6.Memcache

[[email protected] ~]# tar zxf memcache-2.2.5.tgz

[[email protected] ~]# cd memcache-2.2.5

[[email protected] memcache-2.2.5]# phpize

Configuring for:

PHP Api Version:         20131106

Zend Module Api No:      20131226

Zend Extension Api No:   220131226

[[email protected] memcache-2.2.5]# ./configure 

[[email protected] memcache-2.2.5]# make && make install

 

[[email protected] no-debug-non-zts-20131226]# which php

/usr/local/lnmp/php/bin/php

[[email protected] etc]# cd /usr/local/lnmp/php/etc/

[[email protected] etc]# rpm -e `rpm -qa|grep php`

[[email protected] etc]# vim php.ini 

技术分享

[[email protected] etc]# /etc/init.d/php-fpm reload

Reload service php-fpm  done

[[email protected] etc]# php -m |grep memcache

memcache

 

[[email protected] ~]# cd memcache-2.2.5

[[email protected] memcache-2.2.5]# yum install -y memcached

[[email protected] memcache-2.2.5]# /etc/init.d/memcached start

Starting memcached:                                        [  OK  ]

[[email protected] memcache-2.2.5]# cp example.php memcache.php  /usr/local/lnmp/nginx/html/

[[email protected] memcache-2.2.5]# cd /usr/local/lnmp/nginx/html/

[[email protected] html]# ls

50x.html  bbs  example.php  index.html  index.php  memcache.php

[[email protected] html]# vim memcache.php 

技术分享

[[email protected] html]# /etc/init.d/memcached reload

Stopping memcached:                                        [  OK  ]

Starting memcached:                                        [  OK  ]

 

测试:

技术分享

7.openresty   ##openresty是一个基于nginx的可伸缩web平台,使用lua并编写脚本,然后部署到ngnix web容器中运行,从而能更轻松开发出高性能的web服务

tar zxf openresty-1.11.2.3.tar.gz 

 

cd openresty-1.11.2.3

./configure

Gmake && gmake install

cd /usr/local/openresty/nginx/conf/

 vim nginx.conf

技术分享

技术分享

技术分享

[[email protected] conf]# netstat -antlp | grep :11211

技术分享

nginx -s reload

/etc/init.d/memcached  reload

 测试:

[[email protected] ~]$ ab -c10 -n  5000 http://172.25.254.11/index.php

技术分享


以上是关于mysql+php+mem+openresty的主要内容,如果未能解决你的问题,请参考以下文章

如果在短时间内调用两次 PHP MySQL 更新不会执行

php 使用 Memcache 例子

分布式memcache

mysql ON DUPLICATE KEY UPDATE 演示

php memcache缓存

php_memcahed 使用方法