多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 编译安装PHP-5.5.32 [toc] ## 一、准备工作 1.安装依赖包 ```sh yum install -y zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel ``` 2.编译安装libiconv扩展 ```sh cd /server/tools wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz tar zxf libiconv-1.14.tar.gz cd libiconv-1.14 ./configure --prefix=/usr/local/libiconv make && make install ``` ## 二、安装php 1.安装扩展组件 ```sh wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo # 如果epel源已安装则略过wget命令 yum -y install libmcrypt-devel mhash mcrypt rpm -qa libmcrypt-devel mhash mcrypt ``` 2.下载解压PHP软件 官网: php.net ```sh cd /server/tools wget http://cn2.php.net/distributions/php-5.5.32.tar.gz tar xf php-5.5.32.tar.gz cd php-5.5.32 ``` 3.防报错预处理 ```sh ln -s /app/mysql/lib/libmysqlclient.so.18 /usr/lib64/ touch ext/phar/phar.phar ``` 4.编译 ```sh ./configure \ --prefix=/app/php-5.5.32 \ --with-mysql=/app/mysql-5.6.34 \ --with-pdo-mysql=mysqlnd \ --with-iconv-dir=/usr/local/libiconv \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --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 \ --with-gd \ --enable-gd-native-ttf \ --with-openssl \ --with-mhash \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-soap \ --enable-short-tags \ --enable-static \ --with-xsl \ --with-fpm-user=www \ --with-fpm-group=www \ --enable-ftp \ --enable-opcache=no ``` 5.安装 ```sh make && make install ln -s /app/php-5.5.32/ /app/php ``` ## 三、配置和启动 1.配置文件 ``` cp php.ini-production /app/php/lib/php.ini cd /app/php/etc/ cp php-fpm.conf.default php-fpm.conf ``` 2.启动服务 ``` /app/php/sbin/php-fpm netstat -lntup|grep php tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 6251/php-fpm ``` 3.设置开机自启动 ``` #增加以下2行到/etc/rc.local中 echo "/app/nginx/sbin/nginx \n /app/php/sbin/php-fpm" >>/etc/rc.local tail -2 /etc/rc.local /app/nginx/sbin/nginx /app/php/sbin/php-fpm ```