1. 程式人生 > >mysql+php+mem+openresty

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