将WDCP升级为MySQL 5.5、PHP 5.6 ,并开启PDO_MySQL、opcache
#!/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
#!/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加速运行。
上图为升级PHP 5.6.3,需要比较长的时间。
PHP 5.6.3升级完成
直接复制代码可能会出问题,建议直接下载shell脚本上传到服务器执行。
有时候升级到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
找到:
# 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,成功
回复#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源。
运行
<?php phpinfo(); ?>
在mysql项可以看到
PHP 5.3后加入了mysqlnd这个MySQL驱动,性能更强,内存占用更少,线程数也更加稳定(http://www.94cb.com/t/2392 ),我们可以更换为这个。
对编译选项进行修改,不指定Dir则默认使用mysqlnd:
-with-mysql -with-mysqli -with-pdo-mysql
则最后的PHP升级脚本如下:
#!/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
运行一次后,看到:
说明升级成功,phpinfo中可以看到驱动已经变成了mysqlnd了
登录后方可回帖
opcache编译安装完不是默认启用的,需要打开php.ini
插入一行:
然后找到
将
改为
重启Apache生效