CentOS5.7编译安装 nginx+php5.3.8+php-fpm

 

 

1.编译安装php5.3.8

sudo ./configure –prefix=/usr
–with-config-file-path=/etc
–with-iconv –with-freetype-dir
–with-jpeg-dir –with-png-dir –with-zlib
–with-mhash –enable-sockets –enable-ftp
–with-libxml-dir –enable-xml –disable-rpath
–enable-safe-mode –enable-bcmath
–enable-shmop –enable-sysvsem
–enable-inline-optimization –with-curl
–with-mysql=/usr/lib64/mysql –with-curlwrappers
–enable-mbregex –enable-fpm
–enable-mbstring –with-mcrypt –with-openssl –with-mhash
–enable-pcntl –enable-sockets –with-ldap-sasl
–without-pear –enable-fpm
–enable-zip –enable-soap

sudo make && make install

 

 

 

错误:configure: error: Cannot find libmysqlclient under /usr

http://hi.baidu.com/dmkj2008/blog/item/30600788ce5bcb83a4c272c5.html

编译PHP时候报错:configure: error: Cannot find libmysqlclient under /usr 解决
今天在64位rhel4.7系统上编译PHP5.2.6出错,mysql是使用的RPM方式安装的,PHP编译代码:
./configure    –prefix=/usr/local/php –with-mysql –with-apxs2=/usr/local/apache/bin/apxs –with-openssl –with-curl –enable-xml –with-mcrypt –with-ttf –enable-magic-quotes –enable-fastcgi –enable-mbstring –with-iconv –enable-mbstring –with-gd –with-jpeg-dir –with-png-dir –with-zlib-dir –enable-sysvsem

出现以下错误:

checking for specified location of the MySQL UNIX socket… no
checking for MySQL UNIX socket location… no
configure: error: Cannot find libmysqlclient under /usr.
Note that the MySQL client library is not bundled anymore!
通过查找libmysqlclient,发现是在/usr/lib64/mysql/目录内的libmysqlclient.so.16.0.0做的软连接,PHP默认是去的 /usr/lib/搜索,所以没有找到.找到问题了就好解决了.
类似的问题还有: /usr/lib/libjpeg.so -> /usr/lib64/libjpeg.so
解决方法:
1.cp -rp /usr/lib64/mysql/libmysqlclient.so.16.0.0 /usr/lib/libmysqlclient.so
2.
/usr/lib64/libmysqlclient.so -> libmysqlclient.so.16.0.0/usr/lib/libmysqlclient.so -> /usr/lib64/libmysqlclient.so

checking whether to enable embedded MySQLi support… no
checking for mysql_set_server_option in -lmysqlclient… no
configure: error: wrong mysql library version or lib not found. Check config.log for more information.
经过大量测试, 发现解决方案:
(php-xxxxx为php文件名, 代表路径)

# cd /usr/local/src/php-xxxxx/ext/mysqli
# yum -y install mysql-devel
# /phpize
# ./configure –with-php-config= /php-config –enable-embedded-mysqli=shared –enable-shared
# make
# make install
这时屏幕会打印mysqli.so生成的路径, 在php.ini里加载就好啦

/usr/bin/ld: cannot find -lmysqlclient

Centos yum instal l出错(依赖问题)解决方案

刚安装完Centos6,yum安装软件时经常遇到这种问题:

Packages skipped because of dependency problems:

一般都是用yum install *** –skip-broken

 

后来在网上找到了解决方案:

1、将/etc/yum.repos.d文件夹下所有repos文件转移,然后把用的那个repo拷贝回来(保证repo所在目录只有你的那1个文件)

2、yum clean all

3、再yum install安装看看

http://www.cnblogs.com/wanyao/archive/2011/09/19/2181769.html

备份:[原创 centos 安装mono]CentOS5.6 安装nginx1.0.6+php5.3.8+php-fpm+mongodb1.8.3+Thrift 高性能c# sns平

2011年9月1日 15:56:42

原创作品,允许转载,转载时请务必以超链接形式标明文章原始出处、作者信息和本声明。否则将追究法律责任。http://hi.baidu.com/xc_hai

#1—-PHP 5.3.8 Released!  [2011-08-23]  11M
wget http://cn.php.net/distributions/php-5.3.8.tar.bz2

#2—-nginx 2011-08-29 nginx-1.0.6 stable version has been released.
wget http://nginx.org/download/nginx-1.0.6.tar.gz

#3—-mongodb 1.8.3  8/22/2011  Linux 64-bit
wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-1.8.3.tgz

#4—-mono   Latest Stable Version: 2.10.5       32M
wget http://download.mono-project.com/sources/mono/mono-2.10.5.tar.bz2

#5—–Thrift is 0.7.0 (released on 2011-08-13). ##http://thrift.apache.org/download/
wget http://labs.renren.com/apache-mirror//thrift/0.7.0/thrift-0.7.0.tar.gz

安装步骤# php–>php-fpm–>nginx–>mongoDB–>mono–>thrift(Memcached可选)

 

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
在64位的 CentOS 上yum 只安装64位的软件包
#vim /etc/yum.conf
[main]
cachedir=/var/cache/yum
keepcache=0
……##加一行那可##
exclude=*.i?86
……
exclude选项支持正则表达式,*.i?86可以用来过滤掉i386,i686等32bit包了
如果你已经安装了一些32位的软件包你也可以以下命令删除哦 #yum remove *.i?86
——————————————————————————————————–
定时校正服务器时钟,定时与中国国家授时中心授时服务器同步
# crontab -e
加入一行: */5 * * * * /usr/sbin/ntpdate cn.pool.ntp.org && hwclock -w > /dev/null 2>&1
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
一、#安装依赖库和开发工具
sudo -s
LANG=C
yum install 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
yum install pcre-devel  zlib-devel
##* PHP:
yum install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-devel
二、创建www用户和组,虚拟主机使用的目录:
A#/usr/sbin/groupadd www && /usr/sbin/useradd -g www www 

##useradd -s /sbin/nologin -M www  ###  chmod a+rwx -R /var/log/nginx
创建Nginx日志目录
B# mkdir -p /var/log/nginx && chmod +w /var/log/nginx &&chown -R www:www /var/log/nginx  
创建www用户和组,以及供www虚拟主机使用的目录:
C# mkdir -p /data0/www  && chmod +w /data0/www  &&  chown -R www:www /data0/www  

#三、(1)安装PHP 5.3.8(FastCGI模式)
##1、编译安装PHP 5.3.8所需的支持库:
wget http://ncu.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
wget http://ncu.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
wget http://ncu.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
2、编译安装PHP 5.3.8所需的支持库:
##第2.1步,按顺序安装
tar zxvf libiconv-1.14.tar.gz && cd libiconv-1.14/
./configure –prefix=/usr/local
make && make install && cd ../

## 2.2首先安装libmcrypt
tar zxvf 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 ../../

## 2.3接着安装mhash
tar zxvf mhash-0.9.9.9.tar.gz && cd mhash-0.9.9.9/ && ./configure
make && make install && cd ../

## 2.3最后安装mcrypt
tar zxvf mcrypt-2.6.8.tar.gz &&cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make && make install && cd ../

如果报错就用: error: “You need at least libmhash 0.8.15 to compile this program.
# 需要执行,/sbin/ldconfig,或者指定LD_LIBRARY_PATH的路径
#用下列方法#再次编译#
#tar zxvf mcrypt-2.6.8.tar.gz &&cd mcrypt-2.6.8/
#LD_LIBRARY_PATH=/usr/local/lib ./configure
# make && make install && cd ../

3、编译安装PHP(FastCGI模式,不支持mysql) 开启 php-fpm # –with-fpm (*) 不是 –enable-fpm 而是 –with-fpm
tar xjvf php-5.3.8.tar.bz2 && cd php-5.3.8
./configure –prefix=/usr/local/webserver/php
–with-config-file-path=/usr/local/webserver/php/etc
–with-iconv-dir=/usr/local/webserver –with-freetype-dir
–with-jpeg-dir –with-png-dir –with-zlib
–with-mhash –enable-sockets –enable-ftp
–with-libxml-dir –enable-xml –disable-rpath
–enable-safe-mode –enable-bcmath
–enable-shmop –enable-sysvsem
–enable-inline-optimization –with-curl
–with-curlwrappers
–enable-mbregex  –enable-fpm
–enable-mbstring –with-mcrypt –with-gd
–enable-gd-native-ttf –with-openssl –with-mhash
–enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl
–without-pear –enable-fpm 
–with-xmlrpc –enable-zip –enable-soap

3-1# make                    #去掉#make ZEND_EXTRA_LIBS=’-liconv’  #因为-liconv的目录不是在/usr/local下所以安装时需要手动指定
3-2# make install
3-3# cp php.ini-production /usr/local/webserver/php/etc/php.ini  //拷贝php配置文件

 

如果 make: *** [sapi/fpm/php-fpm] Error 1 报错:
1 -2/3 # ==php=make 不去除 iconv模块(Ice要用)再编译应用,只要+以下2步。
===4分钟=ok>先装:1–wget ftp://xmlsoft.org/libxml2/libxml2-2.7.8.tar.gz
tar xzvf libxml2-2.7.8.tar.gz && cd libxml2-2.7.8
./configure && make && make install && cd ../
===3分钟===ok>2步(得上面装好才能装,要不报版本太低。)–wget http://xmlsoft.org/sources/libxslt-1.1.26.tar.gz
tar xzvf libxslt-1.1.26.tar.gz && cd libxslt-1.1.26
./configure  && make && make install && cd ../

4、编译安装PHP5扩展模块    ##一、(2) php-fpm
eaccelerator加速器,是一个自由开放源码PHP加速器,优化和动态内容缓存,提高了性能php脚本的缓存性能,使得PHP脚本在编译的状态下,对服务器的开销几乎完全消除。
它还有对脚本起优化作用,以加快其执行效率。使您的PHP程序代码执效率能提高1-10倍;(这个不是必须的,可以不安装,但为了性能提升,必须的)
tar jxvf eaccelerator-0.9.6.1.tar.bz2 &&cd eaccelerator-0.9.6.1/
/usr/local/webserver/php/bin/phpize
./configure –enable-eaccelerator=shared –with-php-config=/usr/local/webserver/php/bin/php-config
make && make install && cd ../

修改vim /usr/local/webserver/php/etc/php.ini 配置文件, cgi.fix_pathinfo=0,防止Nginx文件类型错误解析漏洞。
再查找output_buffering = Off  修改为output_buffering = On
修改为cgi.fix_pathinfo=0

配置eAccelerator加速PHP:创建缓存存放目录
mkdir -p /usr/local/webserver/eaccelerator_cache && chmod 777 /usr/local/webserver/eaccelerator_cache
建立存放日志的目录
mkdir -p /usr/local/webserver/php/logs
vim /usr/local/webserver/php/etc/php.ini
按shift+g键跳到配置文件的最末尾,加上以下配置信息:
[eaccelerator]
zend_extension=”/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so”
eaccelerator.shm_size=”64″
eaccelerator.cache_dir=”/usr/local/webserver/eaccelerator_cache”
eaccelerator.enable=”1″
eaccelerator.optimizer=”1″
eaccelerator.check_mtime=”1″
eaccelerator.debug=”0″
eaccelerator.filter=””
eaccelerator.shm_max=”0″
eaccelerator.shm_ttl=”3600″
eaccelerator.shm_prune_period=”3600″
eaccelerator.shm_only=”0″
eaccelerator.compress=”1″
eaccelerator.compress_level=”9″

查看安裝是否成功,无错误信息提示:#/usr/local/webserver/php/bin/php -v
PHP 5.3.8 (cli) (built: Jun 18 2011 11:53:28)
全部安装工作准备已经完成,剩下进行一些配置.
cp /usr/local/webserver/php/etc/php-fpm.conf.default /usr/local/webserver/php/etc/php-fpm.conf
vim /usr/local/webserver/php/etc/php-fpm.conf   ##首先修改下面来配置修改
该配置文件只用修改以下四点,只需要把蓝色部分前面的注释去掉pm.max_children = 64
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 1024

修改完成,试着启动, 启动前可先测试下php-fpm.conf的语法是否正确。如出现下面的提示,表示没有问题。
#/usr/local/webserver/php/sbin/php-fpm -t
# /usr/local/webserver/php/sbin/php-fpm &   

# killall -9 php-fpm
启动后用netstat -tnlp   //查看如果有如图所示端口 如果有表示正常启动

如需要开机自动启动 则可以添加到/etc/rc.d/rc.local中
vim /etc/rc.d/rc.local
在空白行添加   /usr/local/php/sbin/php-fpm &

四、##安装nginx ===2011年9月8日最新版本1.0.6===

安装Nginx所需的pcre库:
# ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.tar.gz
#tar zxvf pcre-8.13.tar.gz && cd pcre-8.13/ && ./configure
#make && make install && cd ../

http://www.nginx.org/download/nginx-1.0.6.tar.gz
tar zxvf nginx-1.0.6.tar.gz && cd nginx-1.0.6/

./configure –user=www –group=www
–prefix=/usr/local/webserver/nginx
–sbin-path=/usr/local/webserver/nginx/sbin/nginx
–conf-path=/usr/local/webserver/nginx/conf/nginx.conf
–with-http_stub_status_module
–with-http_ssl_module
–with-pcre
–lock-path=/var/run/nginx.lock
–pid-path=/var/run/nginx.pid

make && make install && cd ../
##–with-pcre  //这个一定要加,不加启动nginxd会报错
五、## 安装mono (10分钟)

#由于只要c#的mono环境,仅需要安装mono的主程序 1个包)

1.  mono-x.x.x.tar.bz2 (安装) mono的主程序,必须安装。

2.  xsp-x.x.x.tar.bz2 (不安装)   xsp程序,包含mono的fastcgi支持,如果采用fastcgi方式运行asp.net程序,不可少,必须安装。

3.  mod_mono-x.x.x.tar.bz2(不安装) mono的apache模块程序,如你采用apache模块方式运行mono,则不可少,必须安装。 apache 能够和XSP 服务沟通。

tar jxvf mono-2.10.5.tar.bz2 && cd mono-2.10.5
./configure
make
make install


六、##安装mongoDB

七、##安装thrift