centos 7 安装 php7

1.下载源代码

2.添加epel 源

3.安装依赖

# yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel
4.创建用户


# groupadd www 
# useradd -g www -s /sbin/nologin -M www
5.编译安装

收集的比较全的编译选项:

./configure \
--prefix=/usr/local/php7 \
--with-config-file-path=/usr/local/php7/etc \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-opcache \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--enable-calendar \
--enable-wddx \
--with-gmp \
--with-curl \
--with-zlib \
--enable-zip \
--with-bz2 \
--with-gd \
--enable-gd-native-ttf \
--enable-exif \
--with-readline
 
# make -j8 
# make install

配置 PHP

配置文件

# cp php.ini-development /usr/local/php56/etc/php.ini

php-fpm 服务

# cp /usr/local/php56/etc/php-fpm.conf.default /usr/local/php56/etc/php-fpm.conf 
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm56 
# chmod +x /etc/init.d/php-fpm56

启动 php-fpm

# service php-fpm56 start Starting php-fpm done

php-fpm 可用参数 start|stop|force-quit|restart|reload|status

添加 PHP 命令到环境变量

编辑 ~/.bash_profile,将:

PATH=$PATH:$HOME/bin 改为: PATH=$PATH:$HOME/bin:/usr/local/php56/bin

使 PHP 环境变量生效:

# . ~/.bash_profile

查看看 PHP 版本

# php -v 








你可能感兴趣的:(centos 7 安装 php7)