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

Methods and steps to build nginx file server based on docker

1. Create a new configuration file docker_nginx.c...

Prevent HTML and JSP pages from being cached and re-fetched from the web server

After the user logs out, if the back button on the...

Two ways to achieve horizontal arrangement of ul and li using CSS

Because li is a block-level element and occupies ...

HTML realizes hotel screening function through form

<!doctype html> <html xmlns="http:/...

CSS to achieve fast and cool shaking animation effect

1. Introduction to Animate.css Animate.css is a r...

Implementation of one-click TLS encryption for docker remote api

Table of contents 1. Change the 2375 port of Dock...

Example of implementing a virtual list in WeChat Mini Program

Table of contents Preface analyze Initial Renderi...

Detailed explanation of how to configure openGauss database in docker

For Windows User Using openGauss in Docker Pull t...

Several methods to solve the problem of MySQL fuzzy query index failure

When we use the like % wildcard, we often encount...

Code for implementing simple arrow icon using div+CSS in HTML

In web design, we often use arrows as decoration ...

VMware Workstation download and installation detailed tutorial

Virtual machines are very convenient testing soft...

Mysql Chinese sorting rules description

When using MySQL, we often sort and query a field...

MySQL installation tutorial under Windows with pictures and text

MySQL installation instructions MySQL is a relati...

Let's talk in detail about the difference between unknown and any in TypeScript

Table of contents Preface 1. unknown vs any 2. Th...