溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

發(fā)布時(shí)間:2020-08-02 16:26:52 來(lái)源:網(wǎng)絡(luò) 閱讀:501 作者:zhangxiaocen 欄目:web開發(fā)

1、安裝mysql-5.5.33-linux2.6-x86_64

#tar xf mysql-5.5.33-linux2.6-x86_64.tar.gz  –C /usr/local/
# ln -sv mysql-5.5.33-linux2.6-x86_64 mysql
# cd mysql
#mkdir /mydata
# cat INSTALL-BINARY | less
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql --datadir=/mydata
shell> chown -R root .
shell> chown -R mysql  /mydata
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

修改此文件中thread_concurrency的值為你的CPU個(gè)數(shù)乘以2,比如這里使用如下行:

# thread_concurrency = 2

另外還需要添加如下行指定mysql數(shù)據(jù)文件的存放位置:

datadir = /mydata

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

為mysql提供sysv服務(wù)腳本:并添加服務(wù),還需要添加環(huán)境變量

# cd /usr/local/mysql
# cp support-files/mysql.server  /etc/rc.d/init.d/mysqld
# chmod +x /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig mysqld on
# vim /etc/profile.d/mysql.sh
# export PATH=/usr/local/mysql/bin:$PATH
# .  /etc/profile.d/mysql.sh
# echo $PATH

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

輸出mysql的頭文件至系統(tǒng)頭文件路徑/usr/include,并且輸出庫(kù)文件

# ln -sv /usr/local/mysql/include  /usr/include/mysql

# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf

# ldconfig

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

2、編譯安裝php-5.4.26


說(shuō)明:

1、這里為了支持apache的worker或event這兩個(gè)MPM,編譯時(shí)使用了--enable-maintainer-zts選項(xiàng)。

2、如果使用PHP5.3以上版本,為了鏈接MySQL數(shù)據(jù)庫(kù),可以指定mysqlnd,這樣在本機(jī)就不需要先安裝MySQL或MySQL開發(fā)包了。mysqlnd從php 5.3開始可用,可以編譯時(shí)綁定到它(而不用和具體的MySQL客戶端庫(kù)綁定形成依賴),但從PHP 5.4開始它就是默認(rèn)設(shè)置了。

# ./configure --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd

# yum -y groupinstall "Desktop Platform Development"
# yum -y install bzip2-devel libmcrypt-devel
# tar xf php-5.4.26.tar.bz2
# cd php-5.4.26
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2  --enable-maintainer-zts
# make
# make intall
# cp php.ini-production /etc/php.ini
# vim /etc/httpd/httpd.conf
# AddType application/x-httpd-php  .php
# AddType application/x-httpd-php-source  .phps
# DirectoryIndex  index.php  index.html

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

如上圖所示:為php提供配置文件:

# cp php.ini-production /etc/php.ini

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache


LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache


3、安裝xcache,為php加速

安裝

# tar xf xcache-3.0.1.tar.gz
# cd xcache-3.0.1
# /usr/local/php/bin/phpize
# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
# make && make install

安裝結(jié)束時(shí),會(huì)出現(xiàn)類似如下行:

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20100525/

2、編輯php.ini,整合php和xcache:

首先將xcache提供的樣例配置導(dǎo)入php.ini

# mkdir /etc/php.d
# cp xcache.ini /etc/php.d

接下來(lái)編輯/etc/php.d/xcache.ini,找到zend_extension開頭的行,修改為如下行:

zend_extension = /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so

注意:如果php.ini文件中有多條zend_extension指令行,要確保此新增的行排在第一位。

LAMP平臺(tái)實(shí)現(xiàn)之PHP加速,xcache


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI