CENTOS7 Installation NGINX+PHP7 Operating environment

Source: Internet
Author: User
  • See if Nginx.repo exists
    Cat/etc/yum.repos.d/nginx.repo
  • Add or edit Nginx.repo

    Vi/etc/yum.repos.d/nginx.repo

    [Nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/7/$basearch/gpgcheck=0enabled=1
  • Installing Nginx

    Yum Install Epel-releaseyum install Nginx
  • Firewall Open Port 80

    Firewall-cmd--permanent--add-service=httpfirewall-cmd--permanent--zone=trusted--add-port=80/tcpfirewall-cmd-- Reload
  • Install the necessary dependencies

    Yum install-y \gcc-c++ autoconf \libjpeg libjpeg-devel libpng \libpng-devel freetype freetype-devel \libpng libpng-devel LIBXML2 libxml2-devel \zlib zlib-devel glibc glibc-devel \glib2 glib2-devel bzip2 bzip2-devel \ncurses Curl Openssl-devel \gdbm-devel db4-devel libxpm-devel \libx11-devel gd-devel gmp-devel \readline-devel libxslt-devel \expat-devel xmlrpc-c Xmlrpc-c-devel \libicu-devel Libmcrypt-devel \libmemcached-devel
  • Download php-7.0.7

    Cd/usr/src/wget HTTP://CN2.PHP.NET/DISTRIBUTIONS/PHP-7.0.7.TAR.BZ2TAR-XJF php-7.0.7.tar.bz2mv php-7.0.7 php7cd/usr /src/php7
  • Compiling PHP

    # Depending on the circumstances and additions to the parameters, the following are some common./configure--prefix=/usr/local/php7 \--with-mysql-sock--with-mysqli \--enable-fpm--enable-soap \ --with-libxml-dir--with-openssl \--with-mcrypt--with-mhash \--with-pcre-regex--with-zlib \--enable-bcmath-- With-iconv \--with-bz2--enable-calendar \--with-curl--with-cdb--enable-dom \--enable-exif--enable-fileinfo \-- Enable-filter--with-pcre-dir \--enable-ftp--with-gd \--with-openssl-dir--with-jpeg-dir \--with-png-dir-- With-zlib-dir \--with-freetype-dir \--enable-gd-native-ttf \--enable-gd-jis-conv--with-gettext \--with-gmp-- With-mhash \--enable-json--enable-mbstring \--enable-mbregex \--enable-mbregex-backtrack \--WITH-LIBMBFL-- With-onig \--enable-pdo--with-pdo-mysql \--with-zlib-dir--with-readline \--enable-session--enable-shmop \-- Enable-simplexml--enable-sockets \--enable-sysvmsg--enable-sysvsem \--enable-sysvshm--enable-wddx \-- With-libxml-dir--with-xsl \--enable-zip \--enable-mysqlnd-compression-support \--with-pear--enable-intl-- Enable-pcnTl 
  • Install PHP

    Makemake Install
  • Test whether the installation was successful

    /usr/local/php7/bin/php-v
  • Make a soft chain to run directly with PHP

    ln-sf/usr/local/php7/bin/php/usr/local/bin/php
  • Verify

    Php-v
  • Copying a configuration file

    Cp/usr/src/php7/php.ini-development/usr/local/php7/lib/php.ini
  • Configure PHP-FPM

    cp/usr/local/php7/etc/php-fpm.conf.default/usr/local/php7/etc/php-fpm.confcp/usr/local/php7/etc/php-fpm.d/ www.conf.default/usr/local/php7/etc/php-fpm.d/www.confcp/usr/src/php7/sapi/fpm/init.d.php-fpm/etc/init.d/ Php-fpmchmod +X/ETC/INIT.D/PHP-FPM
  • Start PHP-FPM

    Service PHP-FPM Start
  • Configure Nginx

    Vi/etc/nginx/nginx.conf

    Add the following configuration to the/ETC/NGINX/NGINX.CONF server block, note: The server needs to add the root configuration, otherwise $document_root is invalid

    Root/www/;location ~ \.php$ {fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $ Document_root$fastcgi_script_name;include Fastcgi_params;}
  • Re-start Nginx

    Service Nginx Restart
  • Create a new PHP file in the Web directory

    Echo '
      
         /usr/share/nginx/html/info.php
  • Browser Access Validation

    http://127.0.0.1/info.php

PHP extension installation, with memcached examples

    • Download php-memcached from GitHub and remember to select the corresponding PHP7 branch

      Cd/usr/srcgit clone HTTPS://GITHUB.COM/PHP-MEMCACHED-DEV/PHP-MEMCACHED.GITCD Php-memcached/git Checkout php7/usr/ Local/php7/bin/phpize./configure--with-php-config=/usr/local/php7/bin/php-configmakemake Install
    • Modify PHP.ini

      vi/usr/local/php7/lib/php.ini# at the bottom and add extension=memcached.so.
    • Save and exit, restart PHP-FPM

      Service PHP-FPM Start
    • Visit info.php again and you can see that the memcached has been installed successfully.

If you have any other questions, please leave a message below ^_^

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.