Linux LNMP architecture Introduction, MySQL installation, PHP installation

Source: Internet
Author: User
Tags bz2 fpm install php pear sapi

LNMP Architecture Introduction

The only difference with lamp is that n in Lnmp refers to Nginx (a Web service software similar to Apache). The application of this kind of environment is also very many at present. Nginx Design is designed to provide a fast, efficient, multi-concurrent Web services software. In the static page processing, Nginx is better than Apache, but in the dynamic page processing, Nginx does not have an advantage over Apache. But there are still a lot of enthusiasts are more enthusiastic about nginx. With the continuous maturation of nginx technology, it will become more and more important in the field of Web services software.
and PHP is the existence of a standalone service called PHP-FPM. Nginx handles static requests directly, and dynamic requests are forwarded to PHP-FPM.

MySQL installation 1. Remove the previously installed MySQL
[[email protected] ~]# ps aux |grep mysql  //查看服务是否启动root       2233  0.0  0.0 112680 972 pts/0 R+ 19:16 0:00 grep --color=auto mysql[[email protected] ~]# rm -rf /usr/local/mysql [[email protected] ~]# rm -rf /etc/init.d/mysqld
2. Install the MySQL process
[[Email protected] ~]# Cd/usr/local/src/[[email protected] ~]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz [[email protected] src]# tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz[[email protected] src]# mv Mysql-5.6.35-linux-glibc2.5-x86_64/usr/local/mysql[[email protected] src]# Cd/usr/local/mysql/[[email protected] MySQL# lsbin COPYING data docs include Lib man mysql-test README scripts share sql-bench support-files[[email protected] MySQL# ls/data/mariadb MyData mysql wwwroot[[email protected] MySQL# ID Mysqluid=gid= (MySQL)(mysql) group =(MySQL) [[email protected] MySQL]# rm-rf/data/mysql/*//due to previously created, delete [[email protected] MySQL]# useradd Mysql[[email protected] MySQL# Mkdir/data/[[email protected] MySQL#./scripts/mysql_install_db--user=mysql--datadir=/data/mysql[[email protected] MySQL# echo $?0[[email protected] MySQL# CP SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF [[email protected] MySQL]# VIM/ETC/MY.CNF is defined as follows: datadir=/data/mysqlsocket=/tmp/mysql.sock[[email protected] MySQL# CP Support-files/mysql.server/etc/init.d/mysqld[[email protected] MySQL# VIM/ETC/INIT.D/MYSQLD is defined as follows: basedir=/usr/local/mysqldatadir=/data/mysql[[email protected] mysql]#/etc/init.d/mysqld Start//startup mysqlstarting mysql.logging to'/data/mysql/gary-tao.err '. success! [[email protected] MySQL]# PS aux |grep mysql//Check whether the service starts root23170.10.11132681592 pts/1 219:400:00/bin/sh/usr/Local/mysql/bin/mysqld_safe--datadir=/data/mysql--pid-file=/data/mysql/gary-tao.pidmysql 2452 4.1 45.1 973060 451828 pts/0 Sl19:400:00/usr/Local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/data/mysql--PLUGIN-DIR=/USR/local/mysql/lib/plugin--user=mysql--Log-error=/data/mysql/gary-tao.err--pid-file=/data/mysql/gary-tao.pid--socket=/tmp/mysql.sockroot 2480 0.  0 0.  0 112680 976 pts/0 r+ : 0: + grep--color=auto mysql[[email protected] mysql]
                                                                                
                                                                                 # chkconfig--add mysqld//Add startup script to system service [[email protected] MySQL]
                                                                                 # chkconfig mysqld on//Set boot start Mysql[[email protect [ed] MySQL]# service mysqld start//start service starting MySQL success!  
                                                                                      
PHP Installation

Nginx PHP Installation and the previous chapter of the PHP installation is different, because Nginx PHP is fastcgi to the way to the nginx, can be understood as Nginx proxy php fastcgi, and httpd is the PHP as their own module to invoke.

1. Because previously installed PHP, this reinstallation of the words directly in the source code package Directory Execution command: Make clean, delete the previously compiled file content, back to the previous decompression state.
[[Email protected] ~]# Cd/usr/local/src/[[email protected] src]# lsapr-1.6.3 apr-util-1.6.1.tar.gz mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz php-5.6.30.tar.gz phpredis-developapr-1.6.3.tar.gz httpd-2.4.mysql-5.6.35-LINUX-GLIBC2.5-x86_64.tar.gz php-7.1.6 phpredis-develop.zipapr-util-1.6.1 httpd-2.4.29.tar.gz php-5.6.php-7.1.6.tar.bz2[[email protected] src]# CD Php-5.6.30[[email protected] php-5.6.30]# LSACINCLUDE.M4 Configure.In Libs makerpm php.ini-production README. STREAMS stamp-h.INACLOCAL.M4 CREDITS libtool meta_ccld README. Ext_skel README. Submitting_patch stub.cbuild ext LICENSE missing README. Git-rules README. Testing testsbuildconf EXTENSIONS ltmain.sh mkinstalldirs readme.input_filter README. TESTING2 travisbuildconf.bat Footer main modules README. Mailinglist_rules README. Unix-build-system tsrmcoding_standards generated_lists makedist NetWare readme.md README. Win32-build-system upgradingconfig.guess genfiles Makefile NEWS readme.namespaces run-tests.php UPGRADING. INTERNALSconfig.log Header Makefile.frag Pear README. New-output-api SAPI Vcscleanconfig.niceinclude Makefile.fragments Php5.spec README. Parameter_parsing_api scripts win32config.status INSTALL Makefile.gcov php5.spec. In the README. REDIST. BINS server-tests-config.php zendconfig.sub install-sh makefile.global php.gif README. Release_process server-tests.phpconfigure libphp5.la makefile.objects php.ini-development README. Self-contained-extensions Snapshot[[email protected] php-5.6.  # makecleanfind.-name \*.gcno-o-name \*.gcda | xargs rm-ffind.-name \*.lo-o-name \*.o | Xargs rm-ffi nd. -name \*.la-o-name \*.a | xargs rm-f find-name \*.so | xargs rm-ffind-name. libs-a-type d|xargs RM-RF Rm-f libphp5.la sapi/cli/php sapi/cgi/php-cgi libphp5.la modules/* libs/*       
Note, if this is the first time installation, do the following:
    • Install to the specified directory cd/usr/local/src/
    • Download Source Package wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
    • Unzip the source package tar zxf php-5.6.30.tar.gz
2. Create an Account

This account is used to run the PHP-FPM service, in the LNMP environment, PHP in a service php-fpm form, independent in the Linux system, easy to manage.

[[email protected] php-5.6.30]# useradd -s /sbin/nologin php-fpm
3. Install PHP
[[email protected] php-5.6.30]# ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl  --with-openssl

Compile parameters and the previous article, there is a--enable-fpm, if you do not add this parameter, there will be no php-fpm to perform file generation, not to start the PHP-FPM service.

Error:

Workaround:

Yum Install-y libcurl-devel

Note: If you are installing PHP for the first time, there will be a lot of dependencies to install, when you look at the error message and what package is missing. 4. Compiling PHP
[[email protected] php-5.6.30]# make[[email protected] php-5.6.30]# make clean && make
Errors such as:

Workaround:

#vim Makefile//In about 105 lines,-lcrypt back with "-lpthread"

Workaround:

#make Clean && Make

5. Install PHP
[[email protected] php-5.6.30]# make install
6. Modify the configuration file:
[[email protected] php-5.6.30]# ls/usr/local/php-fpm/etc/pear.conf Php-fpm.conf.default [[email protected] php-5.6.30]# CP Php.ini-production/usr/local/php-fpm/etc/php.ini//Copy configuration file (production is used in the build environment, development is used in the development environment) [[Email Protected]ary-tao php-5.6.30]# ls/usr/local/php-fpm/etc/pear.conf Php-fpm.conf.default php.ini[[email protected ] etc]# vim/usr/local/php-fpm/etc/php-fpm.conf Add the following: [Global]//define global parameters PID =/usr/local/php-fpm/var/run/ Php-fpm.piderror_log =/usr/local/php-fpm/var/log/php-fpm.log[www]//A module's name listen =/tmp/php-fcgi.so CK//Listening address Listen.mode = 666//Listening for sock when this line is in effect, the permissions used to define sock file are 666user = PHP-FPM//user group to define services = PHP-FPM//user groups defining services PM = Dynamicpm.max_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 50 0rlimit_files = 1024x768   
7. Detection Configuration
[[email protected] etc]# /usr/local/php-fpm/sbin/php-fpm -t //报以下是正常的。[02-Jan-2018 20:02:02] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf test is successful
8. Copy the startup script
[[email protected] etc]# cd /usr/local/src/php-php-5.6.30/        php-5.6.30.tar.gz php-7.1.6/ php-7.1.6.tar.bz2 [[email protected] etc]# cd /usr/local/src/php-5.6.30/ //进入到源码包目录[[email protected] php-5.6.30]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm //拷贝启动脚本到指定目录下
9. Modify Startup script permissions and add service to boot
[Email protected] php-5.6.30]# chmod 755/ETC/INIT.D/PHP-FPM//change permissions [[email protected] php-5.6.30]# chkconfig--add php-fpm//[[email protected] php-5.6.30]# chkconfig PHP-FPM on//Set boot up [[email protected] etc]# service PHP-FPM start//start PHP command starting PHP-FPM done[[email protected] etc# PS aux |grep php-fpm//view process root583060.10.41235604968? Ss20:380:XX php-fpm:master Process (/usr/local/php-fpm/etc/php-fpm.conf) php-fpm 58307 0.0 0.4 123560 4704? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58308 0.0 0.4 123560 4704? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58309 0.0 0.4 123560 4704? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58310 0.0 0.4 123560 4704? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58311 0.0 0.4 123560 4708? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58312 0.0 0.4 123560 4708? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58313 0.0 0.4 123560 4708? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58314 0.0 0.4 123560 4708? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58315 0.0 0.4 123560 4708? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58316 0.0 0.4 123560 4708? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58317 0.0 0.4 123560 4708? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58318 0.0 0.4 123560 4708? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58319 0.0 0.4 123560 4712? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58320 0.0 0.4 123560 4712? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58321 0.0 0.4 123560 4712? S 20:38 0:00 Php-fpm:pool WWWPHP-FPM 58322 0.0 0.4 123560 4712? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58323 0.0 0.4 123560 4712? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58324 0.0 0.4 123560 4712? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58325 0.0 0.4 123560 4712? S 20:38 0:00 php-fpm:pool wwwphp-fpm 58326 0.0 0.4 123560 4712? S 20:38 0:00 php-fpm:pool wwwroot 58329 0.0 0.0 112680 976 pts/0 r+ : 0: --color=auto grep php-fpm     

Linux LNMP architecture Introduction, MySQL installation, PHP installation

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.