Linux LNMP Environment Building

Source: Internet
Author: User
Tags fpm administrator password

System version: CentOS 6.5 software version: libmcrypt-2.5.8 mysql-5.6.26 nginx-1.8.0 pcre-8.37 php-5.6.13


LNMP platform components: Linux, Nginx, MySQl, PHP

Nginx is a high-performance, lightweight Web services software, with high stability, low system resource consumption, the ability to handle HTTP concurrent connection high characteristics


One, Nginx compiled installation

Prepare for work, resolve dependencies, install related toolkits and create Nginx program users

[Email protected] ~]# yum-y install gcc gcc-c++ autoconf automake

[Email protected] ~]# yum-y install zlib zlib-devel OpenSSL openssl-devel

[Email protected] ~]# useradd nginx-m-s/sbin/nologin


1. Unpack and extract the required software into the/usr/src/directory

650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M01/7F/A0/wKioL1cmrcnwJ742AAA0y_Wi5NQ853.jpg "title=" 1.jpg " alt= "Wkiol1cmrcnwj742aaa0y_wi5nq853.jpg"/>


2. Configuring the compilation Installation

650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M01/7F/A2/wKiom1cmrznC3MM-AACN83gEhbo247.jpg "title=" 2.jpg " alt= "Wkiom1cmrznc3mm-aacn83gehbo247.jpg"/>

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M00/7F/A0/wKioL1cmtJbygknzAAAYIpEytdA910.jpg "title=" 3.jpg " alt= "Wkiol1cmtjbygknzaaayipeytda910.jpg"/>

Description: The module support needs to consider the real environment, here just lists some

--prefix # #指定安装位置

--user # #指定程序用户

--group # #指定程序组

--with-http_stub_status_module # #启用支持状态统计模块

--with-http_dav_module # #启用支持 (add Put,delete,mkcol: Create collection, copy and Move methods) is off by default and needs to be compiled to open

--with-http_addition_module # #启用支持 (as an output filter that supports incomplete buffering, partial requests)

--with-http_sub_module # #启用支持 (allow some other text to replace some of the text in the nginx corresponding)

--with-http_flv_module # #启用支持 (support for FLV video files is supported)

--with-http_mp4_module # #启用支持 (supports MP4 video file support, provides pseudo-streaming server support)

--with-pcre=/usr/local/src/pcre-8.37 # #需要注意, here is the source code package decompression path, pcre with Nginx compile installation


3. Configuration adjustment

Related directories of Nginx

[Email protected] ~]# ll/usr/local/nginx/
Total dosage 16
Drwxr-xr-x. 2 root root 4096 April 5 06:46 conf # #Nginx相关配置文件

Drwxr-xr-x. 2 root root 4096 April 5 06:46 HTML # #网站根目录

Drwxr-xr-x. 2 root root 4096 April 5 06:46 Logs # #日志文件

Drwxr-xr-x. 2 root root 4096 April 5 06:46 sbin # #Nginx启动脚本


Create a linked file for the main program Nginx

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/7F/A0/wKioL1cmvBLBB9moAAAgrN4QMqQ748.jpg "title=" 4.jpg " alt= "Wkiol1cmvblbb9moaaagrn4qmqq748.jpg"/>


Writing Nginx Service scripts

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/7F/A0/wKioL1cmvEWCtjWEAAAT9oh5KhE588.jpg "title=" 6.jpg " alt= "Wkiol1cmvewctjweaaat9oh5khe588.jpg"/>

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/7F/A2/wKiom1cmu07B18-BAACsIoFsnPg617.jpg "title=" 5.jpg " alt= "Wkiom1cmu07b18-baacsiofsnpg617.jpg"/>


Execute permissions on the created service script and add as system service

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/7F/A2/wKiom1cmu7zj4fQ_AAApAFTetYE540.jpg "title=" 7.jpg " alt= "Wkiom1cmu7zj4fq_aaapaftetye540.jpg"/>


Configuration Nginx support PHP files, modify the main configuration file

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M00/7F/A2/wKiom1cmvurCSPx6AAAa99GMQGg496.jpg "style=" float: none; "title=" 9.jpg "alt=" Wkiom1cmvurcspx6aaaa99gmqgg496.jpg "/>

650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M00/7F/A1/wKioL1cmv72jkhqnAAB0pAnVkgE608.jpg "style=" float: none; "title=" 8.jpg "alt=" Wkiol1cmv72jkhqnaab0panvkge608.jpg "/>


4. Start Nginx, configure the firewall

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/7F/A2/wKiom1cmv9CDtVF-AACGGqmrBcs598.jpg "title=" 10.jpg "alt=" Wkiom1cmv9cdtvf-aacggqmrbcs598.jpg "/>


5. View Nginx test page

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M00/7F/A2/wKiom1cmwHuTUsWHAADXQqwGi1M142.jpg "title=" 11.jpg "alt=" Wkiom1cmwhutuswhaadxqqwgi1m142.jpg "/>


Second, compile and install MySQL

Prepare for work, resolve dependencies, install related packages and create MySQL program users

650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M02/7F/A2/wKiom1cmwaPRilg0AAAZCioirhk752.jpg "title=" 12.jpg "alt=" Wkiom1cmwaprilg0aaazcioirhk752.jpg "/>650) this.width=650; src=" http://s4.51cto.com/wyfs02/M00/7F/A2/ Wkiom1cmwdmcu5xhaaay5xme84y841.jpg "title=" 13.jpg "alt=" Wkiom1cmwdmcu5xhaaay5xme84y841.jpg "/>


1. Unpacking, configuring, compiling, installing

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/7F/A1/wKioL1cmyDSBUDe4AACyT6UfwN0153.jpg "title=" 14.jpg "alt=" Wkiol1cmydsbude4aacyt6ufwn0153.jpg "/>

650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M01/7F/A1/wKioL1cm0siT-GWCAAAZOWRX7B8299.jpg "title=" 15.jpg "alt=" Wkiol1cm0sit-gwcaaazowrx7b8299.jpg "/>


2. Configure MySQL

Set directory and file owner and owner groups

650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M02/7F/A1/wKioL1cm1JizMOCeAAAhXI8hXgA808.jpg "title=" 16.jpg "alt=" Wkiol1cm1jizmoceaaahxi8hxga808.jpg "/>

Overwrite the original configuration file

650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M00/7F/A3/wKiom1cm1AaT6_enAAAzV-uSJrM815.jpg "title=" 17.jpg "alt=" Wkiom1cm1aat6_enaaazv-usjrm815.jpg "/>

Create a service startup script and specify the MySQL location in the startup script

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M00/7F/A3/wKiom1cm2e2BxPPnAABBz4bTT7I253.jpg "title=" 18.jpg "alt=" Wkiom1cm2e2bxppnaabbz4btt7i253.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/7F/A3/wKiom1cm20jw7GwcAAASwQvfi4o725.jpg "style=" float: none; "title=" 20.jpg "alt=" Wkiom1cm20jw7gwcaaaswqvfi4o725.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/7F/A1/wKioL1cm3BqyYzRaAAAcg5BYLJ0307.jpg "style=" float: none; "title=" 19.jpg "alt=" Wkiol1cm3bqyyzraaaacg5bylj0307.jpg "/>

Initializing the database

650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M01/7F/A1/wKioL1cm3KKD8nIdAABM8J1HKIM065.jpg "title=" 21.jpg "alt=" Wkiol1cm3kkd8nidaabm8j1hkim065.jpg "/>

Setting environment variables

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/7F/A3/wKiom1cm3C-h0tfpAAAt0gBX2VI803.jpg "title=" 22.jpg "alt=" Wkiom1cm3c-h0tfpaaat0gbx2vi803.jpg "/>


3. Start MySQL, set firewall 650) this.width=650; "Src=" http://s4.51cto.com/wyfs02/M00/7F/A1/ Wkiol1cm3zthyetvaacslhux9v8207.jpg "title=" 23.jpg "alt=" Wkiol1cm3zthyetvaacslhux9v8207.jpg "/>


4. Set MySQL administrator password, test login

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/7F/A1/wKioL1cm3wXzeSUbAAAWyxcQXFE311.jpg "style=" float: none; "title=" 24.jpg "alt=" Wkiol1cm3wxzesubaaawyxcqxfe311.jpg "/>

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M00/7F/A3/wKiom1cm3jOx7vCRAAD1InMM87Q727.jpg "style=" float: none; "title=" 25.jpg "alt=" Wkiom1cm3jox7vcraad1inmm87q727.jpg "/>


Third, compile and install PHP

Prepare for work, resolve dependencies, install related packages

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/7F/A2/wKioL1cnDzrx3NJEAAA1XGxpPIM818.jpg "title=" 32.jpg "alt=" Wkiol1cndzrx3njeaaa1xgxppim818.jpg "/>

1. Add libmcrypt encryption Algorithm library extension

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M01/7F/A1/wKioL1cm4dHA4_YgAABfTUfnaQk556.jpg "title=" 26.jpg "alt=" Wkiol1cm4dha4_ygaabftufnaqk556.jpg "/>

Since the system is only looking for the library file under/lib,/lib64,/lib/lib64 by default, you need to add this library path and MySQL library path to/etc/ld.so.conf, then load the library file and configure it to turn on startup

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/7F/A4/wKiom1cnDHWSXZIMAABv_X5KLic397.jpg "title=" 31.jpg "alt=" Wkiom1cndhwsxzimaabv_x5klic397.jpg "/>


2. Compiling and installing PHP

650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M00/7F/A2/wKioL1cm68ejVcoBAAEy38i4zqM400.jpg "title=" 28.jpg "alt=" Wkiol1cm68ejvcobaaey38i4zqm400.jpg "/>

Description

--with-config-file-path # #设置 the php.ini search path. Default is Prefix/lib

--with-mysql # #mysql安装目录, support for MySQL

--with-mysqli # #mysqli扩展技术不仅可以调用MySQL的存储过程, handles MySQL transactions, and also makes access to the database more stable. is a database-driven

--with-iconv-dir # #种字符集间的转换

--with-freetype-dir # #打开对freetype字体库的支持

--with-jpeg-dir # #打开对jpeg图片的支持

--with-png-dir # #打开对png图片的支持

--with-zlib # #打开zlib库的支持, enabling gzip compression output

--WITH-LIBXML-DIR=/USR # #打开libxml2库的支持, Libxml is a library of functions used to parse XML documents

--enable-xml # #支持xml文档

--disable-rpath # #关闭额外的运行库文件

--enable-bcmath # #打开图片大小调整, this module was used for Zabbix surveillance.

--ENABLE-SHMOP # #shmop共享内存操作函数, can communicate with C + +

--enable-sysvsem # #加上上面shmop so that your PHP system can handle the relevant IPC functions (active at the kernel level).

--enable-inline-optimization # #优化线程

--with-curl # #打开curl浏览工具的支持

--with-curlwrappers # #运用curl工具打开url流, new PHP5.6 deprecated

--enable-mbregex # #支持多字节正则表达式

--ENABLE-FPM # #CGI方式安装的启动程序, PHP-FPM service

--enable-mbstring # #多字节, string support

--WITH-GD # #打开gd库的支持, is the PHP processing graphics extension Library, the GD library provides a series of APIs for processing pictures, using the GD library can process pictures, or generate pictures.

--enable-gd-native-ttf # #支持TrueType字符串函数库

--WITH-OPENSSL # #打开ssl支持

--with-mhash # #支持mhash算法扩展

--enable-pcntl # #freeTDS需要用到的, Pcntl extension can support multi-threaded operation of PHP

--enable-sockets # #打开 Sockets support

--WITH-XMLRPC # #打开xml The C language of-RPC

--enable-zip # #打开对zip的支持

--enable-soap # #扩展库通过soap协议实现了客服端与服务器端的数据交互操作

--with-mcrypt # #mcrypt算法扩展

Compiling the installation

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M01/7F/A2/wKioL1cnEBLQ0B1pAAAUe_kfE2M667.jpg "title=" 33.jpg "alt=" Wkiol1cneblq0b1paaaue_kfe2m667.jpg "/>


3. Post-Installation adjustments

Creating a PHP configuration file

650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M02/7F/A3/wKioL1cnGoXSNbjqAAAfEUKi7nY290.jpg "title=" 34.jpg "alt=" Wkiol1cngoxsnbjqaaafeuki7ny290.jpg "/>

Create a PHP-FPM configuration file and its startup script

650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M01/7F/A3/wKioL1cnGrfQFsYDAACFPzZrl8E141.jpg "title=" 35.jpg "alt=" Wkiol1cngrfqfsydaacfpzzrl8e141.jpg "/>


4. Start PHP-FPM, if Nginx and PHP are deployed on both hosts, be careful to modify the php-fpm.conf configuration file's listening address and its attention to the firewall

650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M00/7F/A5/wKiom1cnGs3iigItAACbXm-w9m8427.jpg "title=" 36.jpg "alt=" Wkiom1cngs3iigitaacbxm-w9m8427.jpg "/>


5. Write a dynamic PHP Web page that connects to the database and then use the browser to see if you can connect

650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M02/7F/A3/wKioL1cnH5HjW5cNAAAR4U9-sNg639.jpg "style=" float: none; "title=" 39.jpg "alt=" Wkiol1cnh5hjw5cnaaar4u9-sng639.jpg "/>

650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M00/7F/A5/wKiom1cnHsCzvzuzAAA4WEe-y7g556.jpg "style=" float: none; "title=" 38.jpg "alt=" Wkiom1cnhsczvzuzaaa4wee-y7g556.jpg "/>


650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M00/7F/A3/wKioL1cnH5PCcw_OAACVW8ekngA050.jpg "style=" float: none; "title=" 40.jpg "alt=" Wkiol1cnh5pccw_oaacvw8eknga050.jpg "/>


To this end, the LNMP environment is set up, production environment, is generally nginx, MySQL and PHP are deployed on different hosts, you need to be aware of the different host listening address and its corresponding firewall rules

Linux LNMP Environment Building

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.