How to install php7 + nginx environment under centos6.6

How to install php7 + nginx environment under centos6.6

This article describes how to install php7 + nginx environment under centos6.6. Share with you for your reference, the details are as follows:

1. Install necessary dependency libraries

> yum -y install gd zlib libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel openssl openssl-devel curl-devel libxslt-devel

2. Download the PHP source package

http://php.net/downloads.php

The file name is: php-7.0.4.tar.gz

3. Unzip the source package

> tar -zxvf php-7.0.4.tar.gz

4. Enter the directory and configure

./configure --prefix=/data/nmp/php \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib \
--with-libxml-dir \
--with-mysqli=mysqlnd \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql=mysqlnd \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-mysqlnd \
--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 \
--enable-pthreads \
--enable-maintainer-zts \
--enable-fileinfo

5. make && make install

> make && make install

6. Configuration File

> cp php.ini-development /data/nmp/php/lib/php.ini
> cp /data/nmp/php/etc/php-fpm.conf.default /data/nmp/php/etc/php-fpm.conf
> cp /data/nmp/php/etc/php-fpm.d/www.conf.default /data/nmp/php/etc/php-fpm.d/www.conf
> cp -R ./sapi/fpm/php-fpm /data/nmp/php/etc/init.d/php-fpm

(*Need to create init.d directory)

7. Startup

> /data/nmp/php/etc/init.d/php-fpm

8. Nginx integration with PHP

>vi /data/nmp/nginx/conf/nginx.conf

server {
  listen 80;
  server_name localhost;
 
  charset utf-8;
 
  #root website directory location / {
    root /data/wwwroot;
    index index.html index.htm index.php;
  }
 
  location ~ \.php$ {
 
    #Website directory root /data/wwwroot;
    #phpcgi port, default 9000
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
 
    #document_root points to the website directory fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
}

9. Reload nginx

> /data/nmp/nginx/sbin/nginx -s reload

I hope this article will help you configure your CentOS environment.

You may also be interested in:
  • Building a LEMP (Linux+Nginx+MySQL+PHP) environment under CentOS 8.1 (tutorial details)
  • How to install PHP7.4 and Nginx on Centos
  • Solve the problem of only redirecting to the home page when deploying thinkPHP 5 with nginx
  • A brief discussion on the nginx configuration of thinkphp and how to rewrite the hidden index.php entry file
  • Detailed explanation of PHP+nginx service 500 502 error troubleshooting ideas
  • How to build php+nginx+swoole+mysql+redis environment with docker
  • Solution to "No input file specified" in nginx+php
  • Nginx+php configuration file and principle analysis

<<:  MySQL quickly obtains the table instance code without primary key in the library

>>:  Bootstrap+Jquery to achieve calendar effect

Recommend

Analysis of Hyper-V installation CentOS 8 problem

CentOS 8 has been released for a long time. As so...

Implementation ideas for docker registry image synchronization

Intro Previously, our docker images were stored i...

Steps to install cuda10.1 on Ubuntu 20.04 (graphic tutorial)

Pre-installation preparation The main purpose of ...

VMware Workstation is not compatible with Device/Credential Guard

When installing a virtual machine, a prompt appea...

A detailed introduction to for/of, for/in in JavaScript

Table of contents In JavaScript , there are sever...

4 Scanning Tools for the Linux Desktop

While the paperless world has not yet emerged, mo...

HTML+Sass implements HambergurMenu (hamburger menu)

A few days ago, I watched a video of a foreign gu...

Ten useful and simple MySQL functions

function 0. Display current time Command: select ...

MySQL 8.0.18 installation tutorial under Windows (illustration)

Download Download address: https://dev.mysql.com/...

Common usage of hook in react

Table of contents 1. What is a hook? 2. Why does ...

Use of Linux chkconfig command

1. Command Introduction The chkconfig command is ...