Centos7 under construction Nginx+php7.1+mariadb+memcached+redis

Source: Internet
Author: User
Tags fpm memcached

I. Environmental preparedness

1. First introduce the environment, and our protagonists today

I use the environment is minimized installation of the centos7,mariadb (rumors of MySQL after the acquisition of Oracle, people worried like Java as destroyed in Oracle's hands as a new branch, but still like MySQL),

php7.1.0 (version does not matter, are 7 version), nginx1.10 (we installed stable version without blindly pursuit of new), memcached, and Redis can randomly select one, of course, all installed without interference

2. Package download

1) mariadb software package (yum install, compile and install because of the boost problem hangs up and takes a long time to give up)

First add the mariadb yum source  

cd/etc/Yumrepos.d//etc/yum. Repos.d/mariadb.repo
10.0 --£ º  UTC  # http:///mariadb.org /mariadb/repositories/  [mariadb]  = mariadb  = http://  Yum.mariadb.org/10.0/centos6-amd64  Gpgkey=https://yum.mariadb.org/ RPM-GPG-KEY-MARIADB  gpgcheck=1   

2) php7.10 Package

wget https://downloads.php.net/~davey/php-7.1.0beta3.tar.gz

3) Nginx Package

wget http://nginx.org/download/nginx-1.10.1.tar.gz

Nginx also need to download Ngx_http_upstream_consistent_hash (multiple cache server when using the consistent hash algorithm required)

and Ngx_http_redis (Redis supported) (--add-dynamic-module=path equals their path)

cd/usr/local/src/
wget https://codeload.github.com/replay/ngx_http_consistent_hash/zip/masterUnzip Master

#解压之后的文件夹名字
Ngx_http_consistent_hash-maste
wget  http://people.freebsd.org/~osa/ngx_http_redis-0.3.8.tar.gztar zxvf ngx_http_redis- 0.3. 8. tar. gz

#解压之后的文件夹名字
ngx_http_redis-0.3.8

4) memcached software package (and PHP support for memcached version PHP7) (Libevent libevent-devel required)

#memcached wget http://memcached.org/files/memcached-1.4.31.tar.gz for PHP7  wget https://github.com/websupport-sk/pecl-memcache/archive/php7.zip

5) Redis Package and REDIS-PHP7 package

#rediswget http: // download.redis.io/releases/redis-3.2.3.tar.gz   for php7wget https://CODELOAD.GITHUB.COM/PHPREDIS/PHPREDIS/ZIP/PHP7

3. Install and compile the relevant environment and dependencies of PHP and other related libraries

Yum Yum Upgrade Yum " Development Tools "

Of course the following code and some of the above are duplicated, do not worry, installed will skip

Yum Install  Make GCC GCC GCC file bzip2 bzip2 Unzip libcap lsof libxslt libxslt-devel

Second, software Installation and configuration

0. Create new users and folders

-s/sbin/false -G www--s/sbin/false -G mysql-m MySQL

#创建web目录
Mkdir-r/var/www/html
Chown-r www:www/var/www/

1. Installing MARIADB

Yum Install Mariadb-server mariadb-client Mariadb-devel

After the installation is complete, change my.cnf, restart

mv /etc/my.cnf  /etc/my.cnf.bak   cp /usr/share/mysql/my-huge.cnf  /etc/ my.cnfservice mysql start  or   /etc/init.d/mysql restart   restart

2. Compile and install PHP7

unzip the file CD first, of course ./usr/local/src/TarZXVF PHP-7.1.0BETA3.TAR.GZCD php-7.1.0beta3
#需要安装什么就./configure--help | grep MySQL (here is just an example of XXX) to see what his options are./configure--prefix=/usr/local/PHP--with-Curl--with-freetype-dir --with-GD--with-GetText--with-iconv-dir --with-Kerberos--with-libdir=lib64--with-libxml-dir --with-mysqli--with-OpenSSL--with-pcre-Regex--with-pdo-MySQL--with-pdo-SQLite--with-Pear--with-png-dir --with-xmlrpc \
--with-xsl--with-zlib--enable-mysqli--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#提示缺啥就安装什么, or install libxxx-devel
#比如提示我缺少xslt
#我就试着安装了libXXX Libxxx-devel (Devel is a header file)

# yum Install Libxslt

# yum Install Libxslt-devel

Make && make install

Remove the php.ini file from the compilation directory (production environment and development environment optional), note is LIB, do not believe afterwards can see phpinfo in the configuration file (php.ini) path This option, move php.ini into this location  cp php.ini-development  /usr/local/php/lib/php.ini add php-fpm to the etc/init.d/directoryfrom the compilation directory   cp sapi/fpm/init.d.php-fpm  /etc/init.d/php-fpmchmod +x/etc/init.d/php-  /usr/local/php/etc/mv php-fpm.conf.default  php-fpm.confcd php-fpm.d/MV Www.conf.default www.conf

#修改www. conf user is www

user = www
Group = www


#启动

3. Compile and install Nginx

Enter the directory under/usr/local/src/, unzip the Nginx file no longer detailed # Add module is the folder extracted with--add-dynamic-module= module

./configure--prefix=/usr/local/nginx  --add-dynamic-module=/usr/local/src/ngx_http_consistent_ hash-Master  --add-dynamic-module=/usr/local/src/ngx_http_redis-0.3.  8  --with-http_stub_status_module

Make && make Install

Simple configuration Nginx Let it start, detailed configuration optimization We have a special article

/ {            root   /var/www/html;            Index  ~ \.php$ {            root           /var/www/html;            Fastcgi_pass   127.0. 0.1:9000;            Fastcgi_index  index.php;            Fastcgi_param  script_filename  /var/www/html$fastcgi_script_name;            Include        Fastcgi_params;}

#保存退出
#启动
cd/usr/local/nginx/sbin/
./nginx
#会在/usr/local/nginx/logs/generate a nginx.pid, you can use the semaphore later

4. Compiling and installing Redis

Unzip, enter the catalogue no longer detailed

#直接编译安装就行make makeinstall#为redis建立工作目录 mkdir  /usr/local/  redis# from the compiled directory will be the configuration file, client, server-side copy past CP redis.conf  /usr/local/redis/CD  src/CP redis-cli  redis-server  /usr/local/redis# Simple configuration redis.conf (set to background boot)
Cd/usr/local/redis
Vim redis.conf
Daemonize Yes
Save exit

Cd/usr/local/redis
#启动服务器端
./redis-server redis.conf
#启动客户端, you can do all kinds of things.
./redis-cli

Let PHP support Redis (PHP installation extension is all-in-one, into the pressurized folder to execute Phpize, and then./configure point to Php-config, end will tell you what the extension directory is copied into the php.ini)

/usr/local/php/bin/phpize. /configure--with-php-config=/usr/loca/php/bin/php-config

Vim/usr/local/php/lib/php.ini

Add in almost the last place (same as memcache, no more details later)

Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/" (this directory is, of course, the address that is prompted when the Redis extension is compiled)

[Redis]
Extension=redis.so

5. Compile and install memcached (unzip into directory no longer detailed)

#因为是yum安装的libevent, you do not have to--with-libevent to specify Libevent. /configure--prefix=/usr/local/memcachedmake make andinstall

#启动 (user www, background start-D), www did not build a
Cd/usr/local/memcached/bin
./memcached-u www-d

PHP supports Memcache expansion (unzip into the directory)

/usr/local/php/bin/phpize. /configure--with-php-config=/usr/loca/php/bin/php-config

Add in PHP.ini
[Memcache]
Extension=memcache.so

#重启nginx和php-FPM
Service PHP-FPM Restart
Kill-hup ' Cat/usr/local/nginx/logs/nginx.pid '

Centos7 under construction Nginx+php7.1+mariadb+memcached+redis

Related Article

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.