RedHat7上安装PHP

编译安装PHP

  1. 下载PHP
    # wget http://cn2.php.net/distributions/php-7.0.0.tar.gz
  2. 解压缩PHP
    # tar -zxvf php-7.0.0.tar.gz && cd php-7.0.0
  3. 安装依赖软件
    # yum -y install gcc libxml2-devel
  4. 编译安装PHP
    这里设置php-fpm运行的用户名和组为nginx,如果不存在,需要创建
    # useradd -r -M -s /sbin/nologin nginx
    然后运行下面的命令进行编译安装php
    # ./configure --prefix=/usr/local/php7 --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx
    # make && make install
  5. 复制文件到正确的位置
    # cp php.ini-production /usr/local/php7/php.ini
    # cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
    # cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
    # cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
  6. 设置php-fpm服务开机自启动
    # chmod +x /etc/init.d/php-fpm
    # chkconfig php-fpm on
  7. 修改/usr/local/php7/php.ini文件
    cgi.fix_pathinfo=
    date.timezone = PRC
  8. 启动php-fpm服务
    # service php-fpm start

备注:

使用下面编译参数进行编译时,需要先安装相关依赖包

# yum -y install gcc libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel libc-client-devel libmcrypt-devel libxslt-devel

# ln -sv /usr/lib64/libc-client.so /usr/lib/libc-client.so

编译参数列表:

# ./configure --prefix=/usr/local/php7 \
--with-mcrypt \
--with-mhash \
--with-openssl \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
--enable-inline-optimization \
--disable-rpath \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--without-pear \
--with-curl \
--with-jpeg-dir \
--with-png-dir \
--with-iconv-dir \
--with-freetype-dir \
--with-libxml-dir \
--with-zlib-dir \
--with-gettext \
--without-gdbm \
--disable-fileinfo \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-kerberos \
--with-imap \
--with-imap-ssl \
--enable-exif \
--with-pcre-regex \
--enable-sysvshm \
--enable-calendar \
--enable-xmlreader \
--enable-xmlwriter \
--enable-static \
--with-xsl \
--enable-ftp \
--enable-opcache \
--enable-fpm \
--enable-session \
--disable-fileinfo

yum安装PHP

  1. 安装PHP
    # yum -y install php php-fpm php-mysql
  2. 修改/etc/php.ini文件
    cgi.fix_pathinfo=
    date.timezone = PRC
  3. 修改/etc/php-fpm.d/www.conf文件
    使用nginx用户和用户组来运行php-fpm服务
    user = nginx
    group = nginx
  4. 设置php-fpm服务开机自启动
    # systemctl enable php-fpm
  5. 启动php-fpm服务
    # systemctl start php-fpm
上一篇:Android 热修复 Tinker接入及源码浅析


下一篇:VS Code中编写html(4) 标签的宽高颜色背景设置