MYSQL+PHP-FPM+NGINX+phpmy安装与排错

bin/bash
echo "Update Libs"
yum -y install wget gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

nginx_dir="/usr/local/nginx"
php52_dir="/usr/local/php52"
mysql_dir="/usr/local/mysql"

groupadd www && useradd www -s /sbin/nologin -g www
useradd -M -s /sbin/nologin mysql
#############mysql install###########
cd packages/
tar zxf mysql-5.1.59.tar.gz
cd mysql-5.1.59
CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=nocona -O2 -pipe"
CXXFLAGS="${CFLAGS}"
./configure "--prefix=/usr/local/mysql" "--with-server-suffix=-DZWWW" "--with-mysqld-user=mysql" "--without-debug" "--with-charset=utf8" "--with-extra-charsets=all" "--with-pthread" "--with-big-tables" "--enable-thread-safe-client" "--enable-assembler" "--with-readline" "--with-ssl" "--enable-local-infile" "--with-plugins=partition,myisammrg" "--without-ndb-debug"

make && make install

#########建立配置文件###########
\cp support-files/my-medium.cnf /etc/my.cnf

#########初始化数据库###########
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown -R root.mysql /usr/local/mysql/
chown -R mysql /usr/local/mysql/var

###########调整lib库路径#########
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
ldconfig

###########MYSQL启动配置###########

echo 'start MySQL 5.1.59'

/usr/local/mysql/bin/mysqld_safe --user=mysql &

\cp support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on

#cd /usr/local/mysql
#chown -R mysql:mysql.
#rm -rf sql-bench mysql-test
#echo 'config MySQL 5.1.59'
#chmod +w /usr/local/mysql

###########设置MYSQL程序的执行路径##############
export PATH=$PATH:/usr/local/mysql/bin
echo "PATH=$PATH:/usr/local/mysql/bin">> /etc/profile

source /etc/profile

###设置MYSQL密码##
cd ..
echo 'init db MySQL 5.1.59'

sleep 3s
echo 'set password MySQL 5.1.59'

/usr/local/mysql/bin/mysqladmin -uroot password '123456quanlian'

#sed -i 's#/home/mysql:/bin/bash#/home:/sbin/nologin#' /etc/passwd

echo "mysql server 5.1.59 installed successfully"



错误:

err.....1:如果/var/lib/mysql/mysql.sock存在,而配置文件/etc/my.cnf的是/tmp/mysql.sock,可以该路径或者做软链接。

# err.....2: 出现"/var/lib/mysql/mysql.sock“不存在的解决方法

#1、查询计算机内所有与mysql有关的进程
#ps -A|grep mysql
#2、将查到的进程全部杀死
#kill [PID]
#注:[PID]为你查到的进程的进程号
#3、重启mysql服务
#/etc/init.d/mysql restart
#或者
#service mysql restart
# err......3:服务器启动的时候报错:[root@www var]# service mysqld restart
 ERROR! MySQL manager or server PID file could not be found!
 Starting MySQL. ERROR! Manager of pid-file quit without updating file.


用/usr/local/mysql/bin/mysqld_safe --user=mysql & 启动不了,报以上错误。

然后用:/usr/local/mysql/bin/mysqld_safe --user=root & 启动,启动成功,生成/tmp/mysql.sock,但是重启后又出现以上错误

解决:[root@www /]# chown -R mysql:mysql /tmp/


#    安装PDO_MYSQL-1.0.2.tgz,mysql开启PDO, 在php.ini加上extension=pdo_mysql.so,再重启php


[root@www /]# service mysqld restart
Shutting down MySQL. SUCCESS!
Starting MySQL. SUCCESS!





################安装libunwind########
cd packages/
if [ `uname -m` == "x86_64" ];then
#tar zxf libunwind-0.99.tar.gz
tar zxvf libunwind-0.99.tar.gz
cd libunwind-0.99/
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install
cd ../
else

echo "your system is 32bit ,not install libunwind lib"
fi

#############安装google-perftools############

#is_version
#tar zxvf gperftools-2.0.tar.gz
#cd gperftools-2.0
#./configure
#make
#make install

cd ..
tar zxf pcre-8.12.tar.gz
cd pcre-8.12/
./configure
make
make install
cd ..

###############NGINX##############

tar zxf pcre-8.12.tar.gz
cd pcre-8.12
./configure
make
make install
cd ..
tar zxf nginx-1.1.4.tar.gz  
cd nginx-1.1.4
./configure --prefix=${nginx_dir} --with-google_perftools_module --user=www --group=www --with-http_stub_status_module --with-http_flv_module --with-http_ssl_module
make && make install

service httpd stop
echo `nginx -t` #####测试是否成功
  mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.bak
  cp conf/nginx.conf /usr/local/nginx/conf/nginx.conf
  cp conf/fastcgi.conf /usr/local/nginx/conf/fcgi.conf
 
  echo `nginx -t`
  ln -sf /usr/local/nginx/sbin/nginx /sbin/nginx     ###方便管理
nginx
echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local
echo "nginx installed sucussfully"
cd ..

###NGINX平滑重启:1....killall -s HUP nginx       2..kill -HUP `cat /usr/local/nginx/nginx.pid`     nginx -s reload    (可以直接用1方法)
#####平滑重启的优点:“平滑重启”,在ps -aux中可以看到,nginx首先启动新进程,旧的进程仍然提供服务,在一段时间后,旧的进程服务结束就自动关闭,剩下新进程继续服务。      注意:还可以平滑升级nginx版本,具体查网上资料。


#####phpinstall 组件###########
#cd packages/
tar zxf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure --prefix=/usr/local
make
make install
cd ../

tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../

tar zxf mhash-0.9.9.tar.gz
 cd mhash-0.9.9/
./configure
make
make install

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

tar zxf mcrypt-2.6.7.tar.gz
cd mcrypt-2.6.7/
/sbin/ldconfig
./configure
make
make install
cd ../
################PHP install##############
tar zxf php-5.2.17.tar.gz
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
cd php-5.2.17/
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config
--with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir
--with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode
--enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers
--enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd
--enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap

或者: ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-sockets --enable-roxen-zts --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl

或者(成功案例之一):./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap



make ZEND_EXTRA_LIBS='-liconv'
make install

#如果有错误:则,cp -frp /usr/lib64/libjpeg.* /usr/lib/       ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2
#cd ..
#cp php.ini /usr/local/php52/etc/
cp php.ini-dist /usr/local/php/etc/php.ini
cp php.ini-dist /usr/local/php/lib/php.ini
cp php-fpm.conf /usr/local/php52/etc/
#php5.3:
#cp php*/php.ini-development /etc/php.ini
#cp php*/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
#chmod 755 /etc/init.d/php-fpm


echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf.d/mysql_lib.conf
/sbin/ldconfig

/usr/local/php/sbin/php-fpm start
echo "/usr/lcoal/php/sbin/php-fpm" >> /etc/rc.local

 
#启动:/usr/local/php/sbin/php-fpm start 如果启动错误:Starting php_fpm Nov 05 05:44:48.271363 [ERROR] fpm_unix_conf_wp(), line 124: #please specify user and group other than root, pool 'default'  
#则说明php-fpm.conf没有修改好,默认<!-- <value name="user">nobody</value> --> ,去掉“<!--  -->”,然后php- fpm restart 即可。如有问题,#查看 vi /etc/php-fpm.conf 中的 < value name="listen-address" > 127.0.0.1:9000</value >
#手动开启PDO,在php-ini文件上开启,连接数据库用。#    安装PDO_MYSQL-1.0.2.tgz,mysql开启PDO, 在php.ini加上extension=pdo_mysql.so,extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613",再重启php

#如果网站有做缓存,则在php.ini开启缓存输入输出 output_buffering = on

configure: error: Cannot find MySQL header files under /usr/share/mysql.   安装mysql-devel即可
Note that the MySQL client library is not bundled anymore!


configure: error: Cannot find libmysqlclient under /usr.                    下载 libmysqlclient.a 即可
Note that the MySQL client library is not bundled anymore!







configure: error: mysql configure failed. Please check config.log for more information.     设置成 --with-mysql-dir 就OK


echo "php52 installed successfully!"
}

function ins_php52-ext()

{
cd packages/


如果不是php-fpm而是spawn-fcgi启动,则
ps -aux | grep cgi
 killall -HUP php-cgi
killall -s HUP nginx
/usr/sbin/spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/local/php/bin/php-cgi -C 16

############### memcache 等扩展安装 #################


tar zxf memcache-2.2.5.tgz
cd memcache-2.2.5/
${php52_dir}/bin/phpize
./configure --with-php-config=${php52_dir}/bin/php-config
make
make install
cd ../

tar jxf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1/
${php52_dir}/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=${php52_dir}/bin/php-config
make
make install
cd ../

tar zxf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
${php52_dir}/bin/phpize
./configure --with-php-config=${php52_dir}/bin/php-config --with-pdo-mysql=${mysql_dir}
make
make install
cd ../

tar zxf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
cd ../

tar zxf imagick-2.3.0.tgz
cd imagick-2.3.0/
${php52_dir}/bin/phpize
./configure --with-php-config=${php52_dir}/bin/php-config
make
make install
cd ../
echo "php52 extension installed successfully!"

#################PHPMyadmin install#################333

echo 'install phpMyAdmin 3.2.0.1'
tar xvzf phpMyAdmin-3.2.0.1-all-languages.tar.gz
mv phpMyAdmin-3.2.0.1-all-languages $phpdir/phpMyAdmin
cp $phpdir/phpMyAdmin/libraries/config.default.php $phpdir/phpMyAdmin/config.inc.php

exit


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值