Install PHP7+NGINX+MARIADB Environment under centos6.4

Source: Internet
Author: User
Tags curl fpm install php openssl zts

One, install PHP7
1, create PHP users and user groups, and download PHP7 source on GitHub
# groupadd-r PHP && useradd-r-G php-s/bin/false-d/usr/local/php7-m php
##### #从GitHub下载php7安装包
# wget-c--no-check-certificate-o Https://
##### #开始解压php7包
# unzip-q && CD Php-src-master
# # # #安装编译php7时需要的依赖包
php-src-master]# yum-y Install libxml2 libxml2-devel OpenSSL openssl-devel curl-devel libjpeg-devel libpng-devel Freetyp E-devel Libmcrypt-devel

2, compile and install PHP
--bindir=/usr/local/php7/bin--sbindir=/usr/local/php7/sbin--includedir=/usr/local/php7/include \
--libdir=/usr/local/php7/lib/php--mandir=/usr/local/php7/php/man--with-config-file-path=/usr/local/php7/etc \
--with-mysql-sock=/var/run/mysql/mysql.sock--with-mcrypt=/usr/include--with-mhash--with-openssl \
--with-mysql=shared,mysqlnd--with-mysqli=shared,mysqlnd--with-pdo-mysql=shared,mysqlnd \
--WITH-GD--with-iconv--with-zlib--enable-zip--enable-inline-optimization--disable-debug--disable-rpath \
--enable-shared--enable-xml--enable-bcmath--enable-shmop--enable-sysvsem--enable-mbregex--enable-mbstring \
--enable-ftp--enable-gd-native-ttf--enable-pcntl--enable-sockets--with-xmlrpc--enable-soap--without-pear \
--with-gettext--enable-session--with-curl--with-jpeg-dir--with-freetype-dir \
--enable-opcache--enable-fpm--enable-fastcgi--with-fpm-user=nginx--with-fpm-group=nginx--without-gdbm-- Disable-fileinfo
Make clean && make && make install

3 Optional steps: Execute the Make Test command to test
View PHP Extensions ls/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/
Need to make sure that there are at least two dynamic library files of,

4. Set PHP configuration file
php-src-master]# CP Php.ini-production/usr/local/php7/etc/php.ini
php-src-master]# cp/usr/local/php7/etc/php-fpm.conf.default/usr/local/php7/etc/php-fpm.conf
php-src-master]# cp/usr/local/php7/etc/php-fpm.d/www.conf.default/usr/local/php7/etc/php-fpm.d/www.conf

5, add environment variables for PHP
# echo-e ' \nexport path=/usr/local/php7/bin:/usr/local/php7/sbin: $PATH \ n ' >>/etc/profile && source/etc /profile

6, create PHP related process log directory
# mkdir-p/var/log/php-fpm/&& mkdir-p/var/run/php-fpm && cd/var/run/&& chown-r Nginx:nginx php-fpm
###### #修改session的目录配置
# mkdir-p/var/lib/php/session
# Chown-r nginx:nginx/var/lib/php

7, set PHP boot and test configuration file is correct
php-src-master]# chmod +x/etc/init.d/php-fpm
php-src-master]# chkconfig--add php-fpm
php-src-master]# Chkconfig php-fpm on
sbin]# php-fpm-t
[03-may-2015 17:50:04] Notice:configuration file/usr/local/php7/etc/php-fpm.conf Test is successful

8, Configuration Opcache
# Join
# start
# View PHP Version
PHP 7.0.0-dev (CLI) (Built:mar 3 2015 10:02:26)
Copyright (c) 1997-2015 the PHP Group
Zend Engine V3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
With Zend Opcache V7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies

VI php.ini
Memory_limit = 256M

Second, install Nginx

1, create user
Groupadd Nginx
Useradd-r-G nginx-d/usr/local/nginx Nginx

2. Install the required extensions

Yum-y Install Zlib-devel pcre-devel openssl-devel

3, compile Nginx
TAR-ZXVF nginx-1.9.9.tar.gz
Source Installation Nginx
--with-openssl=/usr/include/openssl--with-pcre--with-http_stub_status_module--with-http_gzip_static_module \
--with-http_ssl_module--with-http_stub_status_module \
Make && make install

4, register as system service
#/sbin/chkconfig--add Nginx
#/sbin/chkconfig--level 345 nginx on

Change the program directory owner:
Chown-r nginx:nginx/var/www/linda040/

Nginx and PHP configuration file modifications:
VI php.ini
VI php-fpm.conf
PID = Run/
Error_log = Log/php-fpm.log
Emergency_restart_threshold = 10
Emergency_restart_interval = 1m
Process_control_timeout = 5s

user = Nginx
Group = Nginx
Listen =/tmp/php-fpm.socket
Listen.backlog = 1024
Listen.owner = Nginx = Nginx
Listen.mode = 0666
PM = dynamic
Pm.max_children = 256
Pm.start_servers = 150
Pm.min_spare_servers = 50
Pm.max_spare_servers = 250
m.max_requests = 8000
Slowlog = log/$pool. Log.slow
request_slowlog_timeout = 1s

Three, install MARIADB
Back up the database first
Mysqldump--single-transaction--add-drop-database--master-data=2-uroot-p123456--databases linda030 Linda_ Copyright > Source.sql

Generate MARIADB Warehouse configuration online in =neusoft&distro=centos

VI Mariadb.repo

# MariaDB 5.5 CentOS repository list-created 2016-01-18 02:46 UTC
Name = MariaDB
BaseURL = Http://
And then
Yum-y Install Mariadb-server mariadb-client

Installation Complete
Service MySQL Start

Set the root user password
mysqladmin-u root password ' 123456 '
Setting up remote Logins
GRANT all privileges on * * to [e-mail protected] "%" identified by "123456";
Flush privileges;
Configuration case insensitive
Add under [mysqld]

Service MySQL Restart

Install PHP7+NGINX+MARIADB Environment under centos6.4

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: 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.