Linux配置nginx、PHP7详解

阿里云为例,安装nginx和最新的PHP7.0.10!

一.安装Nginx

  • 下载并安装nginx

    # yum install nginx

  • 启动nginx服务

    systemctl start nginx

    安装后,输入 :nginx -v 查看安装版本,确认安装成功,至于修改配置文件nginx.conf 我们下面再说!

    二.安装PHP7.0.10

    阿里云默认支持wget下载

    cd /usr/local
    wget  http://cn2.php.net/get/php-7.0.10.tar.gz/from/this/mirror
    tar zxvf php-7.0.10.tar.gz
    cd php-7.0.10
    首先查看安装帮助
     ./configure   –help
    然后复制下面的代码,黏贴后回车,把这些代码标记为“XXX命令”,后面会多次使用
     ./configure --prefix=/usr/local/php \
    --with-curl \
    --with-freetype-dir \
    --with-gd \
    --with-gettext \
    --with-iconv-dir \
    --with-kerberos \
    --with-libdir=lib64 \
    --with-libxml-dir \
    --with-mysqli \
    --with-openssl \
    --with-pcre-regex \
    --with-pdo-mysql \
    --with-pdo-sqlite \
    --with-pear \
    --with-png-dir \
    --with-xmlrpc \
    --with-xsl \
    --with-zlib \
    --enable-fpm \
    --enable-bcmath \
    --enable-libxml \
    --enable-inline-optimization \
    --enable-gd-native-ttf \
    --enable-mbregex \
    --enable-mbstring \
    --enable-opcache \
    --enable-pcntl \
    --enable-shmop \
    --enable-soap \
    --enable-sockets \
    --enable-sysvsem \
    --enable-xml \
    --enable-zip
    由于缺少很多编译工具,安装下面工具!
    yum install libxslt-devel
    yum -y install curl-devel
    yum install openssl openssl-devel
    yum install gcc
    yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQLpcre-devel
    yum install make apr* autoconf automake bzip2 bzip2-devel curl curl-devel gcc gcc-c++ gcc-g77 e2fsprogs e2fsprogs-devel zlib* zlib-devel openssl openssl-devel pcre-devel gd gd-devel kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* libvpx libjpeg libpng zlib libXpm libXpm-devel t1lib libt1-devel freetype freetype-devel libpng* libpng10 libpng10-devel libpng-devel php-common php-gd ncurses* ncurses-devel libtool* libtool-libs libxml2-devel patch glibc glibc-devel glib2 glib2-devel krb5 krb5-devel libevent libevent-devel libidn libidn-devel nss_ldap openldap openldap-clients openldap-devel openldap-servers openssl openssl-devel pspell-devel net-snmp* net-snmp-devel -y
    直接运行上面两条命令即可!此时再次运行“XXX命令”,如果出现报错,如cc、gcc、openSSL什么的没有安装,直接百度命令yum安装即可!
    切记,安装一个编译工具,执行一次“XXX命令”!直到出现 类似Thanks php的语句,并没有任何报错,说明预编译成功!
    然后编译安装

    make &&  make install
    安装过程较长,耐心等待!
    然后复制配置文件
    # cp php.ini-development /usr/local/php/lib/php.ini
    # cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
    # cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
    # cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm

    更多内容,请点击原文: http://www.phpthinking.com/archives/1605

你可能感兴趣的:(PHP)