将WDCP升级为MySQL 5.5、PHP 5.6 ,并开启PDO_MySQL、opcache

By lincanbin at 2014-12-07 • 0人收藏 • 9847人看过
#!/bin/bash
IN_DIR="/www/wdlinux"
MYS_VER="5.5.27"
if [ ! -f mysql-${MYS_VER}.tar.gz ];then
	wget -c http://dl.wdlinux.cn:5180/soft/mysql-${MYS_VER}.tar.gz
fi
yum install -y cmake
tar zxvf mysql-${MYS_VER}.tar.gz
cd mysql-${MYS_VER}
cmake -DCMAKE_INSTALL_PREFIX=$IN_DIR/mysql-$MYS_VER -DSYSCONFDIR=$IN_DIR/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_SSL=no -DWITH_DEBUG=OFF -DWITH_EXTRA_CHARSETS=complex -DENABLED_PROFILING=ON -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1
[ $? != 0 ] && echo "configure err" && exit
make
[ $? != 0 ] && echo "make err" && exit
make install
[ $? != 0 ] && echo "make install err" && exit
service mysqld stop
if [ ! -d /www/wdlinux/mysql_bk ];then
mkdir -p /www/wdlinux/mysql_bk
cp -pR /www/wdlinux/mysql/var/* /www/wdlinux/mysql_bk
fi
rm -f /www/wdlinux/mysql
ln -sf $IN_DIR/mysql-$MYS_VER /www/wdlinux/mysql
sh scripts/mysql_install_db.sh --user=mysql --basedir=/www/wdlinux/mysql --datadir=/www/wdlinux/mysql/var
chown -R mysql.mysql /www/wdlinux/mysql/var
mv /www/wdlinux/mysql/var/mysql /www/wdlinux/mysql/var/mysqlo
cp -pR /www/wdlinux/mysql_bk/* /www/wdlinux/mysql/var/
cp support-files/mysql.server /www/wdlinux/init.d/mysqld
chmod 755 /www/wdlinux/init.d/mysqld
service mysqld restart
echo
if [ -d /www/wdlinux/mysql-5.1.63 ];then
	ln -sf /www/wdlinux/mysql-5.1.63/lib/mysql/libmysqlclient.so.16* /usr/lib/
fi
sleep 2
sh /www/wdlinux/tools/mysql_wdcp_chg.sh
echo
echo "mysql update is OK"

将以上脚本在服务器端保存为mysql_upgrade.sh

然后执行

sh mysql_upgrade.sh

即可将WDCP下的MySQL从5.1升级为MySQL 5.5

blob.png

#!/bin/bash

###yum
yum install -y libmcrypt-devel libjpeg-devel libpng-devel freetype-devel curl-devel openssl-devel libxml2-devel

###
Ver=5.6.3

if [ ! -f php-${Ver}.tar.gz ];then
#wget -c http://cn2.php.net/distributions/php-${Ver}.tar.gz
wget -c http://us1.php.net/distributions/php-${Ver}.tar.gz
#http://downloads.php.net/tyrael/php-${Ver}.tar.gz
fi
if [ ! -f iconv_ins.sh ];then
wget -c http://down.wdlinux.cn/in/iconv_ins.sh
sh iconv_ins.sh
fi

###
tar zxvf php-${Ver}.tar.gz
cd php-${Ver}
if [ -d /www/wdlinux/apache_php ];then
make clean
./configure --prefix=/www/wdlinux/apache_php-${Ver} -with-config-file-path=/www/wdlinux/apache_php-${Ver}/etc -with-mysql=/www/wdlinux/mysql -with-mysqli=/www/wdlinux/mysql/bin/mysql_config -with-iconv=/usr -with-freetype-dir -with-jpeg-dir -with-png-dir -with-zlib -with-libxml-dir=/usr -enable-xml -disable-fileinfo -enable-inline-optimization -with-curl -enable-mbregex -enable-mbstring -with-mcrypt=/usr -with-gd -enable-gd-native-ttf -with-openssl -with-mhash -enable-ftp -enable-sockets -enable-zip -with-apxs2=/www/wdlinux/apache/bin/apxs -with-pdo-mysql=/www/wdlinux/mysql -enable-opcache
[ $? != 0 ] && echo "configure err" && exit
make
[ $? != 0 ] && echo "make err" && exit
make install
[ $? != 0 ] && echo "make install err" && exit
cp php.ini-production /www/wdlinux/apache_php-${Ver}/etc/php.ini
#grep ‘\[eaccelerator\]‘ -A15 /www/wdlinux/apache_php/etc/php.ini >> /www/wdlinux/apache_php-${Ver}/etc/php.ini
#grep ‘\[Zend\]‘ -A5 /www/wdlinux/apache_php/etc/php.ini >> /www/wdlinux/apache_php-${Ver}/etc/php.ini
sed -i ‘s/short_open_tag = Off/short_open_tag = On/g’ /www/wdlinux/apache_php-${Ver}/etc/php.ini
rm -f /www/wdlinux/apache_php
ln -sf /www/wdlinux/apache_php-${Ver} /www/wdlinux/apache_php
service httpd restart
echo
echo "php update is OK"
fi

if [ -d /www/wdlinux/nginx_php ];then
make clean
./configure --prefix=/www/wdlinux/nginx_php-${Ver} -with-config-file-path=/www/wdlinux/nginx_php-${Ver}/etc -with-mysql=/www/wdlinux/mysql -with-mysqli=/www/wdlinux/mysql/bin/mysql_config -with-iconv=/usr -with-freetype-dir -with-jpeg-dir -with-png-dir -with-zlib -with-libxml-dir=/usr -enable-xml -disable-fileinfo -enable-inline-optimization -with-curl -enable-mbregex -enable-mbstring -with-mcrypt=/usr -with-gd -enable-gd-native-ttf -with-openssl -with-mhash -enable-ftp -enable-sockets -enable-zip -enable-fpm -with-pdo-mysql=/www/wdlinux/mysql -enable-opcache
[ $? != 0 ] && echo "configure err" && exit
make
[ $? != 0 ] && echo "make err" && exit
make install
[ $? != 0 ] && echo "make install err" && exit
cp php.ini-production /www/wdlinux/nginx_php-${Ver}/etc/php.ini
#grep ‘\[eaccelerator\]‘ -A15 /www/wdlinux/nginx_php/etc/php.ini >> /www/wdlinux/nginx_php-${Ver}/etc/php.ini
#grep ‘\[Zend\]‘ -A5 /www/wdlinux/nginx_php/etc/php.ini >> /www/wdlinux/nginx_php-${Ver}/etc/php.ini
sed -i 's/short_open_tag = Off/short_open_tag = On/g' /www/wdlinux/nginx_php-${Ver}/etc/php.ini
service php-fpm stop
rm -f /www/wdlinux/nginx_php
ln -sf /www/wdlinux/nginx_php-${Ver} /www/wdlinux/nginx_php
cp /www/wdlinux/nginx_php-${Ver}/etc/php-fpm.conf.default /www/wdlinux/nginx_php-${Ver}/etc/php-fpm.conf
sed -i 's/user = nobody/user = www/g' /www/wdlinux/nginx_php/etc/php-fpm.conf
sed -i 's/group = nobody/group = www/g' /www/wdlinux/nginx_php/etc/php-fpm.conf
sed -i 's/;pid =/pid =/g' /www/wdlinux/nginx_php/etc/php-fpm.conf
cp -f sapi/fpm/init.d.php-fpm /www/wdlinux/init.d/php-fpm
chmod 755 /www/wdlinux/init.d/php-fpm
service php-fpm start
echo
echo "php update is OK"
fi
echo

将以上脚本在服务器端保存为php_upgrade.sh

然后执行

sh php_upgrade.sh

即可将WDCP下的PHP从5.2升级为PHP 5.6.3,同时开启安装Carbon Forum需要的PDO_MySQL,并启用opcache加速运行。

blob.png

blob.png

上图为升级PHP 5.6.3,需要比较长的时间。

1417884048760873.pngPHP 5.6.3升级完成

直接复制代码可能会出问题,建议直接下载shell脚本上传到服务器执行。

mysql_upgrade.sh.zip

php_upgrade.sh.zip

17 个回复 | 最后更新于 2015-04-06
2014-12-07   #1

opcache编译安装完不是默认启用的,需要打开php.ini

插入一行:

zend_extension=opcache.so

然后找到

[opcache]
; Determines if Zend OPCache is enabled
;opcache.enable=0

;opcache.enable=0

改为

opcache.enable=1

重启Apache生效

service httpd restart
2014-12-07   #2

有时候升级到MySQL 5.5会出问题:

[root@vps mysql]# service mysqld restart
 ERROR! MySQL server PID file could not be found!
Starting MySQL. ERROR! The server quit without updating PID file (/www/wdlinux/mysql-5.5.27/data/vps.94cb.com.pid).

这种情况下执行:

vi /www/wdlinux/init.d/mysqld

blob.png

找到:

# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.

basedir=
datadir=

改为

# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.

basedir=/www/wdlinux/mysql
datadir=/www/wdlinux/mysql/var

保存退出

重启mysql,成功

blob.png

2014-12-20   #3

上传到哪里?刚玩Linux的小白看不懂

2014-12-20   #4

回复#3 @hlbj105 :任意文件夹,例如/tmp,然后execute,也就是用sh命令执行。

这个只对WDCP面板有用,其他面板要重新自己写升级脚本。

2014-12-21   #5

回复#4 @lincanbin :还是搞不定啊,,我用的是azure  cenos6.5的不知道是不是主机问题?

2014-12-21   #6

回复#5 @hlbj105 :Azure的VPS相当不错,应该不会有什么问题。

2014-12-21   #7

回复#6 @lincanbin :那个sql升级成功了,就php不成功,显示这个

tar: Unexpected EOF in archive

tar: Unexpected EOF in archive

tar: Error is not recoverable: exiting now

make: *** No rule to make target `clean'.  Stop.

php_upgrade.sh: line 24: ./configure: No such file or directory

configure err

2014-12-21   #8

回复#7 @hlbj105 :你的PHP源码下载不完整,所以解压出错了。

删除php-5.6.3.tar.gz,然后重新升级PHP。

也有可能是因PHP是在US,你的VPS在国内,撞墙了。

可以尝试修改升级文件,找到

#wget -c http://cn2.php.net/distributions/php-${Ver}.tar.gz
wget -c http://us1.php.net/distributions/php-${Ver}.tar.gz

修改为

wget -c http://cn2.php.net/distributions/php-${Ver}.tar.gz
#wget -c http://us1.php.net/distributions/php-${Ver}.tar.gz

这样就可以从国内镜像站下载PHP源。

2014-12-21   #9

回复#8 @lincanbin :哦,我再试试!

2014-12-21   #10

终于升级成功了!谢谢站长了!

2014-12-22   #11

升级数据库后,进不去登录面板了。。显示:

无法连接mysql,请检查mysql是否已启动及用户密码是否设置正确!:

2014-12-22   #12

回复#11 @hlbj105 :参照#2

2014-12-22   #13

回复#12 @lincanbin :ok,谢谢

2015-02-05   #14

运行

<?php
phpinfo();
?>

在mysql项可以看到

blob.png

PHP 5.3后加入了mysqlnd这个MySQL驱动,性能更强,内存占用更少,线程数也更加稳定(http://www.94cb.com/t/2392 ),我们可以更换为这个。

对编译选项进行修改,不指定Dir则默认使用mysqlnd:

-with-mysql -with-mysqli -with-pdo-mysql

则最后的PHP升级脚本如下:

php_upgrade.zip

#!/bin/bash

###yum
yum install -y libmcrypt-devel libjpeg-devel libpng-devel freetype-devel curl-devel openssl-devel libxml2-devel

###
Ver=5.6.5

if [ ! -f php-${Ver}.tar.gz ];then
#wget -c http://cn2.php.net/distributions/php-${Ver}.tar.gz
wget -c http://us1.php.net/distributions/php-${Ver}.tar.gz
#http://downloads.php.net/tyrael/php-${Ver}.tar.gz
fi
if [ ! -f iconv_ins.sh ];then
wget -c http://down.wdlinux.cn/in/iconv_ins.sh
sh iconv_ins.sh
fi

###
tar zxvf php-${Ver}.tar.gz
cd php-${Ver}
if [ -d /www/wdlinux/apache_php ];then
make clean
./configure --prefix=/www/wdlinux/apache_php-${Ver} -with-config-file-path=/www/wdlinux/apache_php-${Ver}/etc -with-iconv=/usr -with-freetype-dir -with-jpeg-dir -with-png-dir -with-zlib -with-libxml-dir=/usr -enable-xml -disable-fileinfo -enable-inline-optimization -with-curl -enable-mbregex -enable-mbstring -with-mcrypt=/usr -with-gd -enable-gd-native-ttf -with-openssl -with-mhash -enable-ftp -enable-sockets -enable-zip -with-apxs2=/www/wdlinux/apache/bin/apxs -with-mysql -with-mysqli -with-pdo-mysql -enable-opcache
[ $? != 0 ] && echo "configure err" && exit
make
[ $? != 0 ] && echo "make err" && exit
make install
[ $? != 0 ] && echo "make install err" && exit
cp php.ini-production /www/wdlinux/apache_php-${Ver}/etc/php.ini
#grep ‘\[eaccelerator\]‘ -A15 /www/wdlinux/apache_php/etc/php.ini >> /www/wdlinux/apache_php-${Ver}/etc/php.ini
#grep ‘\[Zend\]‘ -A5 /www/wdlinux/apache_php/etc/php.ini >> /www/wdlinux/apache_php-${Ver}/etc/php.ini
sed -i ‘s/short_open_tag = Off/short_open_tag = On/g’ /www/wdlinux/apache_php-${Ver}/etc/php.ini
rm -f /www/wdlinux/apache_php
ln -sf /www/wdlinux/apache_php-${Ver} /www/wdlinux/apache_php
service httpd restart
echo
echo "php update is OK"
fi

if [ -d /www/wdlinux/nginx_php ];then
make clean
./configure --prefix=/www/wdlinux/nginx_php-${Ver} -with-config-file-path=/www/wdlinux/nginx_php-${Ver}/etc -with-iconv=/usr -with-freetype-dir -with-jpeg-dir -with-png-dir -with-zlib -with-libxml-dir=/usr -enable-xml -disable-fileinfo -enable-inline-optimization -with-curl -enable-mbregex -enable-mbstring -with-mcrypt=/usr -with-gd -enable-gd-native-ttf -with-openssl -with-mhash -enable-ftp -enable-sockets -enable-zip -enable-fpm -with-mysql -with-mysqli -with-pdo-mysql -enable-opcache
[ $? != 0 ] && echo "configure err" && exit
make
[ $? != 0 ] && echo "make err" && exit
make install
[ $? != 0 ] && echo "make install err" && exit
cp php.ini-production /www/wdlinux/nginx_php-${Ver}/etc/php.ini
#grep ‘\[eaccelerator\]‘ -A15 /www/wdlinux/nginx_php/etc/php.ini >> /www/wdlinux/nginx_php-${Ver}/etc/php.ini
#grep ‘\[Zend\]‘ -A5 /www/wdlinux/nginx_php/etc/php.ini >> /www/wdlinux/nginx_php-${Ver}/etc/php.ini
sed -i 's/short_open_tag = Off/short_open_tag = On/g' /www/wdlinux/nginx_php-${Ver}/etc/php.ini
service php-fpm stop
rm -f /www/wdlinux/nginx_php
ln -sf /www/wdlinux/nginx_php-${Ver} /www/wdlinux/nginx_php
cp /www/wdlinux/nginx_php-${Ver}/etc/php-fpm.conf.default /www/wdlinux/nginx_php-${Ver}/etc/php-fpm.conf
sed -i 's/user = nobody/user = www/g' /www/wdlinux/nginx_php/etc/php-fpm.conf
sed -i 's/group = nobody/group = www/g' /www/wdlinux/nginx_php/etc/php-fpm.conf
sed -i 's/;pid =/pid =/g' /www/wdlinux/nginx_php/etc/php-fpm.conf
cp -f sapi/fpm/init.d.php-fpm /www/wdlinux/init.d/php-fpm
chmod 755 /www/wdlinux/init.d/php-fpm
service php-fpm start
echo
echo "php update is OK"
fi
echo

运行一次后,看到:

blob.png

说明升级成功,phpinfo中可以看到驱动已经变成了mysqlnd了

blob.png

2015-02-07   #15

回复#14 @lincanbin :测试下回复

2015-04-05   #16

更换为mysqlnd后的改变:

http://www.94cb.com/t/2392

2015-04-06   #17

我用的5.4

登录后方可回帖

登 录
信息栏

Carbon Forum是一个基于话题的高性能轻型PHP论坛

下载地址:Carbon Forum v5.9.0
QQ群:12607708(QQ我不常上)

donate

手机支付宝扫描上方二维码可向本项目捐款

粤公网安备 44030602003677号
粤ICP备17135490号

Loading...