PHP5.5安装-创新互联
1. install Development Environment (安装开发环境)
yum install make gcc gcc-c++ -y
2. install library(安装php依赖库)
a) install jpegsrc(安装jpeg库,使php支持jpg、jpeg等图片格式)
下载地址:http://ijg.org
wget http://ijg.org/files/jpegsrc.v9a.tar.gz
mkdir -p /usr/local/webserver/libs/
tar zxvf jpegsrc.v9a.tar.gz
cd jpeg-9a/
./configure --prefix=/usr/local/webserver/libs --enable-shared --enable-static
make
make install
cd ..
b)install libpng(安装libpng库,使php支持png等图片格式)
下载地址:http://libpng.org/pub/png/libpng.html
wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.12.tar.gz
tar -zxvf libpng-1.6.12.tar.gz
cd libpng-1.6.12
./configure --prefix=/usr/local/webserver/libs
make
make install
cd ..
c)install freetype(安装freetype库,使php支持单色位图、反走样位图的渲染)
下载地址:http://freetype.org/download.html
wget http://ncu.dl.sourceforge.net/project/freetype/freetype2/2.5.3/freetype-2.5.3.tar.bz2
tar -zxvf freetype-2.5.3.tar.bz2
cd freetype-2.5.3
./configure --prefix=/usr/local/webserver/libs
make
make install
cd ..
d)install libmcrypt(安装mcrypt库,使php实现加密解密功能)
下载地址:http://sourceforge.net/projects/mcrypt/
wget http://softlayer.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gz
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/webserver/libs
make
make install
cd libltdl/
./configure --prefix=/usr/local/webserver/libs--enable-ltdl-install
make
make install
cd ../..
e)install mhash(安装mmhash库,为PHP提供了多种哈希算法)
wget http://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.bz2
tar xvf mhash-0.9.9.9.tar.bz2
cd mhash-0.9.9.9/
./configure --prefix=/usr/local/webserver/libs
make
make install
cd ..
echo /usr/local/webserver/libs/lib >>/etc/ld.so.conf
ldconfig
f) install mcrypt(安装mcrypt库,使php实现加密解密功能)
下载地址:http://sourceforge.net/projects/mcrypt/
wgethttp://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
export LDFLAGS="-L/usr/local/webserver/libs/lib-L/usr/lib"
export CFLAGS="-I/usr/local/webserver/libs/include-I/usr/include"
touch malloc.h
./configure --prefix=/usr/local/webserver/libs--with-libmcrypt-prefix=/usr/local/webserver/libs
make
make install
cd ..
g) install libxml2、libcurl、gd and openssl
(使php支持curl重写、支持xml语言、支持gd图形处理库和支持openssl加密)
yum install libxml2-devel -y
yum install libcurl-devel -y
yum install -y gd gd-devel
yum install openssl openssl-devel -y
3.install php(安装php程序)
a)定义系统变量指定相关库的位置
export LIBS="-lm -ltermcap -lresolv"
exportDYLD_LIBRARY_PATH="/usr/local/webserver/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
exportLD_LIBRARY_PATH="/usr/local/webserver/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
export LIBS=
export CFLAGS=
下载地址:http://php.net/downloads.php
wget http://cn2.php.net/get/php-5.5.16.tar.gz
tar -zxvf php-5.5.16.tar.gz
cd php-5.5.16
b)编译安装PHP
./configure --prefix=/usr/local/webserver/php--with-config-file-path=/usr/local/webserver/php/etc --with-iconv-dir--with-freetype-dir=/usr/local/webserver/libs--with-jpeg-dir=/usr/local/webserver/libs--with-png-dir=/usr/local/webserver/libs --with-zlib --with-libxml-dir=/usr--enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem--enable-inline-optimization --with-curl --enable-mbregex --enable-fpm--enable-mbstring --with-mcrypt=/usr/local/webserver/libs --with-gd--enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets--with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-pdo-mysql
--prefix=/usr/local/webserver/php
php安装位置
--with-config-file-path=/usr/local/webserver/php/etc
php配置文件位置
--with-iconv-dir
启用字符转换
--with-freetype-dir=/usr/local/webserver/libs
使支持freetype
--with-jpeg-dir=/usr/local/webserver/libs
使支持jpeg等图片格式
--with-png-dir=/usr/local/webserver/libs
使支持png等图片格式
--with-zlib
--enable-zip
支持zlib\zip压缩
--with-libxml-dir=/usr
--enable-xml
--with-xmlrpc
使支持xml语言
--disable-rpath
--enable-bcmath
使支持整型
--enable-shmop
允许PHP读,写,创建和删除UNIX共享内存段
--enable-sysvsem
--enable-inline-optimization
使用inline优化
--with-curl
使支持curl重写功能
--enable-mbregex
--enable-mbstring
支持mbregex、mbstring字符编码
--enable-fpm
支持PHPFastCGI管理器
--with-mcrypt=/usr/local/webserver/libs
--with-gd
--enable-gd-native-ttf
支持mcrypt、GD库
--with-openssl
支持openssl加密
--with-mhash
支持hash算法
--enable-pcntl
--enable-sockets
支持套接字
--enable-soap
支持简单对象访问协议
--enable-opcache
make
make install
cp php.ini-development /usr/local/webserver/php/etc/php.ini
ln -s/usr/local/webserver/mysql/lib/libmysqlclient.18.dylib/usr/lib/libmysqlclient.18.dylib
mv /usr/local/webserver/php/etc/php-fpm.conf.default/usr/local/webserver/php/etc/php-fpm.conf
4. 安装php其它扩展
a)install autoconf(Autoconf是一个用于生成可以自动地配置软件源代码包以适应多种Unix类系统的 shell脚本的工具)
tar -zxvf autoconf-latest.tar.gz -C ../tmp
cd ../tmp/autoconf-2.69/
./configure --prefix=/usr/local/webserver/libs
make
make install
cd ../../soft
b)install memcache(使支持memcache)
tar -zxvf memcache-2.2.7.tgz -C ../tmp
cd ../tmp/memcache-2.2.7/
exportPHP_AUTOCONF="/usr/local/webserver/libs/bin/autoconf"
exportPHP_AUTOHEADER="/usr/local/webserver/libs/bin/autoheader"
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../../soft
5. start whith onboot(设置开机启动PHP)
$ cp
$ chmod 755 /etc/init.d/php-fpm
vim /etc/init.d/php-fpm
设置以下内容:
php_fpm_BIN=/usr/local/webserver/php/sbin/php-fpm
php_fpm_CONF=/usr/local/webserver/php/etc/php-fpm.conf
php_fpm_PID=/var/run/php-fpm.pid
cp /usr/local/webserver/libs/etc/php-fpm.conf.default /usr/local/webserver/libs/etc/php-fpm.conf
cp php.ini-production /usr/local/webserver/php/lib/php.ini
可以通过以下控制:
$ /etc/init.d/php-fpm start
$ /etc/init.d/php-fpm stop
$ /etc/init.d/php-fpm reload
开机启动
$ chkconfig php-fpm on
使用killall php-fpm也可以杀死所有进程
6.Nginx启动php验证
nginx.conf的server中加入如下配置,并重启:
location ~ \.php$ {
root /opt/www/bi;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}
在指定的root目录下,写入一个
echo phpinfo();
?>
文件进行测试。
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网页标题:PHP5.5安装-创新互联
网址分享:http://azwzsj.com/article/dghops.html