@phper
2015-04-01T10:28:28.000000Z
字数 2879
阅读 8978
php
linux
yum install -y make cmake gcc gcc-c++ autoconf automake libpng-devel libjpeg-devel zlib libxml2-devel ncurses-devel bison \
libtool-ltdl-devel libiconv libmcrypt mhash mcrypt pcre-devel openssl-devel freetype-devel libcurl-devel
#先下载PHP
cd /software
wget http://cn2.php.net/distributions/php-5.6.6.tar.gz
tar -zxvf php-5.6.6.tar.gz
cd php-5.6.6.tar.gz
#我们先配置下PHP的编译参数
./configure --prefix=/usr/local/php --with-mysql --with-mysqli --with-pdo_mysql --with-iconv-dir --with-zlib --with-libxml-dir --enable-xml --with-curl --enable-fpm --enable-mbstring --with-gd --with-openssl --with-mhash --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-freetype-dir=/usr/lib64
#编译
make
make install clean
#复制php.ini
cp php.ini-development /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
#运行php-fpm
/usr/local/php/sbin/php-fpm
#将php命令加入到全局
vi /root/.bash_profile
#将/usr/local/php/bin 加到后面,用:隔开
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib:/usr/local/php/bin
#重启
source /root/.bash_profile
先卸载老版本:
#查看老版本号
[root@centos6 /]# rpm -qa|grep -i mysql
mysql-libs-5.1.71-1.el6.x86_64
#无依赖卸载删除
[root@centos6 /]# rpm -ev --nodeps mysql-libs-5.1.71-1.el6.x86_64
#检查下还存在否?
[root@centos6 /]# rpm -qa|grep -i mysql
[root@centos6 /]# rpm -q mysql
package mysql is not installed
再安装新版本:
cd /software
#先下载mysql 5.6
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.23.tar.gz
tar zxvf mysql-5.6.23.tar.gz
cd mysql-5.6.23
#cmake配置下
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ #安装目录
-DMYSQL_DATADIR=/usr/local/mysql/data \ #数据库存放目录
-DDEFAULT_CHARSET=utf8 \ #使用utf8字符
-DDEFAULT_COLLATION=utf8_general_ci \ #校验字符
-DEXTRA_CHARSETS=all \ #安装所有扩展字符集
-DENABLED_LOCAL_INFILE=1 #允许从本地导入数据
#编译安装
make && make install
#创建mysql用户和用户组
groupadd mysql
useradd -r -g mysql mysql
#给mysql目录设置目录权限
chown -R mysql:mysql /usr/local/mysql
#将mysql的启动服务添加到系统服务中
cd /usr/local/mysql/
cp support-files/my-default.cnf /etc/my.cnf
#创建系统数据库的表
cd scripts/
./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/
#复制mysql管理脚本到系统服务目录
cd /opt/mysql/support-files
cp mysql.server /etc/rc.d/init.d/mysql
#添加mysql命令到系统服务命令
chkconfig --add mysql
#加入开机启动策略
chkconfig mysql on
service mysql start
#以后就可以调用service 命令来管理mysql
service mysql start
service mysql stop
service mysql restart
#将mysql命令加入全局可用
vi /root/.bash_profile
#在PATH=$PATH:$HOME/bin添加参数为:
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
#重新生效
source /root/.bash_profile
#修改root密码
mysql -u root mysql
mysql>use mysql;
mysql>desc user;
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root"; //为root添加远程连接的能力。
mysql>update user set Password = password('12346') where User='root';
mysql>select Host,User,Password from user where User='root';
mysql>flush privileges;
mysql>exit
#重新登录:
mysql -uroot -p123456
附上云盘的我下载好的安装包: http://yunpan.cn/cZ2QJMSKVGsdU (提取码:06ec)
参考资料:
http://www.markdream.com/technologies/server/centos-install-nmp.shtml
http://www.cnblogs.com/fly1988happy/archive/2011/11/21/2257682.html