Linux系统PHP5.5安装
第1章 安装php
1.1 进行编译下载到/install/目录中
#上传到/install/目录中
-rw-r--r-- 1 root root 17773092 Apr 1 10:19 php-5.5.32.tar.gz
1.2 安装PHP软件的依赖关系
命令:(检查)yum install -y zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel
命令:(检查)rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel
1.3 libiconv软件安装---字符集转换库(默认可以不进行安装了)
命令:(切换)cd /install/
命令:(下载)wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
命令:(解压)tar zxf libiconv-1.14.tar.gz
命令:(切换)cd /install/libiconv-1.14
命令:(进行)/install/libiconv-1.14/configure --prefix=/opt/libiconv
命令:(进行翻译)make
命令:(进行编译安装)make install
命令:(切换)cd /install/
命令:(下载)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
命令:(下载)yum install libmcrypt-devel mhash mcrypt -y
命令:(检查)rpm -qa libmcrypt-devel mhash mcrypt
1.4 下载解压PHP软件
命令:(切换)cd /opt/
命令:(解压)tar xf php-5.5.32.tar.gz
命令:(切换)cd /opt/php-5.5.32
命令:(进行配置)
./configure \
--prefix=/opt/php-5.5.32 \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir=/opt/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=nginx \
--with-fpm-group=nginx \
--enable-ftp \
--enable-opcache=no
./configure --prefix=/opt/php-5.5.32 --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/opt/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=nginx --with-fpm-group=nginx --enable-ftp --enable-opcache=no
=============================================================================
注:说明:LNMP架构部署时,如果mysql服务和web服务不在一台主机上,php配置参数需要进行调整
--with-mysql=/application/mysql/ => --with-mysql=mysqlnd
======================================================================================
PHP扩展参数:(配置没有问题可以省略以下配置参数,以下参数和PHP优化有关)
--with-curlwrappers \
--enable-zip \
--enable-zend-multibyte \
1.5 怕出错(防错)(以下信息可以不进行配置了)
命令:(创建软连接)ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
命令:(创建文件)touch ext/phar/phar.phar
命令:(进行翻译php)make
命令:(进行编译安装php)make install
1.6 PHP软件程序创建软链接
命令:(创建软连接)ln -s /opt/php-5.5.32/ /opt/php
1.7 配置php解析文件/配置php-fpm配置文件
命令:(切换)cd /opt/php-5.5.32
命令:(查看)ll php.ini*
-rw-r--r--. 1 1001 1001 69236 2016-02-02 21:33 php.ini-development
-rw-r--r--. 1 1001 1001 69266 2016-02-02 21:33 php.ini-production
(php.ini-developments是开发人员调试用配置文件,php.ini-production是生产常见所有配置文件)
命令:(复制)cp php.ini-production /opt/php/lib/php.ini
php.ini-production 与 php.ini-development 文件区别关系对比
扩展:文件比较命令 diff zdiff vimdiff windows上的文件比较
命令:(切换)cd /application/php/etc/
命令:(切换)cp php-fpm.conf.default php-fpm.conf
(以下内容看情况)
# 编译安装PHP时,若配置未正确指定PHP进程用户信息,可以修改PHP文件进行调整
sed -i 's#user = www#user = nginx#g;s#group = www#group = nginx#g' /application/php-5.5.32/etc/php-fpm.conf
1.8 启动php-fpm程序
命令:(启动)/application/php/sbin/php-fpm
命令:(进行检查端口)lsof -i :9000 <--- 确认php 9000端口是否正确启动
命令:(进行检查程序)ps -ef|grep php-fpm