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=0
    date.timezone = PRC
  8. 啓動php-fpm服務
    # service php-fpm start

備註:php

使用下面編譯參數進行編譯時,須要先安裝相關依賴包mysql

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

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

編譯參數列表:api

# ./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=0
    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
相關文章
相關標籤/搜索