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
#新建php用户和php组
# groupadd-r PHP && useradd-r-G php-s/bin/false-d/usr/local/php7-m php
##### #从GitHub下载php7安装包
# wget-c--no-check-certificate-o Php7-src-master.zip Https://github.com/php/php-src/archive/master.zip
##### #开始解压php7包
# unzip-q php7-src-master.zip && 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
./buildconf
./configure--PREFIX=/USR/LOCAL/PHP7--EXEC-PREFIX=/USR/LOCAL/PHP7 \
--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 mysqli.so, pdo_mysql.so

4. Set PHP configuration file
php-src-master]# CP Php.ini-production/usr/local/php7/etc/php.ini
php-src-master]# CP SAPI/FPM/INIT.D.PHP-FPM/ETC/INIT.D/PHP-FPM
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
#测试PHP的配置文件是否正确合法
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
Vim/usr/local/php7/etc/php.ini
# Join
Zend_extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20141001/opcache.so
# start
/ETC/INIT.D/PHP7-FPM start
# View PHP Version
/usr/local/php7/bin/php-v
Results:
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
wget http://nginx.org/download/nginx-1.9.9.tar.gz

3, compile Nginx
TAR-ZXVF nginx-1.9.9.tar.gz
Source Installation Nginx
./configure--prefix=/usr/local/nginx--user=nginx--group=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 \
--without-http_ssi_module--without-http_autoindex_module--without-http_uwsgi_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
Extension=mysqli.so
Extension=pdo_mysql.so
VI php-fpm.conf
PID = Run/php-fpm.pid
Error_log = Log/php-fpm.log
Emergency_restart_threshold = 10
Emergency_restart_interval = 1m
Process_control_timeout = 5s

Vi/usr/local/php7/etc/php-fpm.d/www.conf
user = Nginx
Group = Nginx
Listen =/tmp/php-fpm.socket
Listen.backlog = 1024
Listen.owner = Nginx
Listen.group = 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 https://downloads.mariadb.org/mariadb/repositories/#mirror =neusoft&distro=centos
cd/etc/yum.repos.d/

VI Mariadb.repo

# MariaDB 5.5 CentOS repository list-created 2016-01-18 02:46 UTC
# http://mariadb.org/mariadb/repositories/
[MARIADB]
Name = MariaDB
BaseURL = Http://yum.mariadb.org/5.5/centos6-amd64
Gpgkey=http://yum.mariadb.org/rpm-gpg-key-mariadb
Gpgcheck=1
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
mysql-uroot-p123456
GRANT all privileges on * * to [e-mail protected] "%" identified by "123456";
Flush privileges;
Configuration case insensitive
Vi/etc/my.cnf.d/server.cnf
Add under [mysqld]
Lower_case_table_names=1
Character_set_server=utf8
Slow_query_log=on
Slow_query_log_file=/var/lib/mysql/slow_query.log
Long_query_time=1

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