1.LNMP is an abbreviation for a set of free software that is typically used together to run a dynamic Web site or server:
linux+nginx+mysql+php (PHP-FPM), because Nginx has the advantage of large concurrency, now more and more enterprises
The industry LAMP platform is migrating to LNMP.
Then we began to enter the LNMP building. In a realistic production environment, different business requirements are not the same, so more
The enterprise will consider using the source code to build the LNMP environment, which can be more flexible using each function parameter to modulate performance to
Optimal state. Of course, if your company's environment is relatively simple, you can consider RPM package installation.
Note: This lab environment is basically the latest installation package downloaded from each of the major networks.
The most basic package required to install the LNMP environment
[[Email protected] ~] #yum-y install libjpeg-devel libpng-devel libtiff-devel fontconfig-devel freetype-devel Libxpm-devel gettext-devel openssl-devel libtool-ltdl-devel gcc *c++*
Ncurses-devel//Libjpeg-devel, Libpng-devel, Libtiff-devel, Fontconfig-devel,
Freetypedevel,
Libxpm-devel These are picture-and-font-related development packages, so that PHP can be better supported.
GetText is a library of language-related functions. Openssl-devel is a set of tools for generating the
Use the key, public key, and other files. Libtool is a generic library support script that will need to be used during the PHP compilation process.
To.
2. Installing the Nginx Package
[Email protected] yuanma]# TAR-XZF nginx-1.2.7.tar.gz
[Email protected] nginx-1.2.7]# Useradd nginx
[Email protected] nginx-1.2.7]#/configure--user=nginx--group=nginx--prefix=/usr/local/nginx/--with-http_stub_ Status_module--with-http_ssl_module--withsha1=/usr/lib//-with-sha1 Specify Syrah function library location, other parameters see shared document above
[[email protected] nginx-1.2.7] #make && make install
[Email protected] pcre-8.32]#/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf
Start Nginx
[Email protected] pcre-8.32]# links 192.168.17.128//appears Welcome to nginx! Description of Nginx Installation success
3. Install MySQL
# Tar XF mysql-5.1.54.tar.gz
# CD mysql-5.1.54
#./configure--prefix=/opt/mysql && make && make install
# useradd-s/sbin/nologin mysql-m
# Cd/opt/mysql
# chown Mysql.mysql. -R
#./bin/mysql_install_db--user=mysql
# chown Root. -R
# chown MySQL Var-r
# CP Share/mysql/mysql.server/etc/init.d/mysql
# service MySQL Start
# chkconfig--add MySQL
# chkconfig MySQL on
# NETSTAT-TNLP |grep:3306--Verify if it's up
TCP 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 16232/mysqld
4. Install PHP (fpm-->start-->php-->process)
#yum-y install libxml2-devel mysql-devel (mysql-php)
# TAR-XF PHP-5.5.3.TAR.BZ2
#./configure--prefix=/opt/php5--with-config-file-path=/opt/php5--enable-fpm--enable-fastcgi--with-mysql=/opt/ Mysql
--prefix=/opt/php5--specifying the installation path for PHP
--with-config-file-path=/opt/php5--specifying the configuration file storage directory for PHP
--ENABLE-FPM--enable-fastcgi--supports starting PHP in CGI mode
--with-mysql=/opt/mysql--let PHP support MySQL database
# Make && make install
CP Php.ini-production/opt/php5/php.ini
4. Start PHP in a process way through PHP-FPM
# cd/opt/php5/etc/
# CP Php-fpm.conf.default php-fpm.conf
#/OPT/PHP5/SBIN/PHP-FPM--Start PHP in a process way
# NETSTAT-TNLP | grep php
TCP 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 26789/php-fpm
# Vim Php-fpm.conf
159 Listen = 127.0.0.1:9000
225 Pm.max_children = 32
Pm.start_servers = 10
235 Pm.min_spare_servers = 10
Pm.max_spare_servers = 12
# PS aux | grep fpm
Root 26917 0.1 0.3 137704 3312? Ss 12:01 0:00 php-fpm:master process (/opt/php5/etc/php-fpm.conf)
Nobody 26918 0.0 0.2 137704 2852? S 12:01 0:00 Php-fpm:pool www
Nobody 26919 0.0 0.2 137704 2852? S 12:01 0:00 Php-fpm:pool www
Nobody 26920 0.0 0.2 137704 2852? S 12:01 0:00 Php-fpm:pool www
Nobody 26921 0.0 0.2 137704 2852? S 12:01 0:00 Php-fpm:pool www
Nobody 26922 0.0 0.2 137704 2856? S 12:01 0:00 Php-fpm:pool www
Nobody 26923 0.0 0.2 137704 2856? S 12:01 0:00 Php-fpm:pool www
Nobody 26924 0.0 0.2 137704 2856? S 12:01 0:00 Php-fpm:pool www
Nobody 26925 0.0 0.2 137704 2856? S 12:01 0:00 Php-fpm:pool www
Nobody 26926 0.0 0.2 137704 2856? S 12:01 0:00 Php-fpm:pool www
Nobody 26927 0.0 0.2 137704 2856? S 12:01 0:00 Php-fpm:pool www
Logic
Nginx<--tcp/socket-->php<--/usr/lib64/mysql/libmysqlclient.so-->mysqld
5. Test whether PHP files are parsed
To create a test file:
vim/usr/local/nginx/html/test.php
The contents are as follows:
<?php echo phpinfo ();? >
Test:
[Email protected] nginx]# Curl localhost/test.php
Or use your browser to open http://YourServerIPAddress/test.php
Important: If you do not resolve, check the log found not connected to PHP, my PHP version is 5.5.23, compare the new version, need to add in the php/etc/php-fpm.conf file
Listen.owner = Nobody
Listen.group = Nobody
These two lines, and then restart the service will be able to use PHP
The reason is/tmp/php-fcgi.sock this file does not have Read permission
At this point, the latest version of the LNMP Environment source code compilation and installation is complete.
6, integrated Nginx/php/mysql
[email protected] conf]# cat nginx.conf
User Nginx Nginx;
Worker_processes 2;
Error_log/usr/local/nginx/logs/error.log notice;
PID Logs/nginx.pid;
Worker_rlimit_nofile 5120;
Events {
Use Epoll;
Worker_connections 5120;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
Server_names_hash_bucket_size 128;
Client_header_buffer_size 32k;
Large_client_header_buffers 4 32k;
Client_max_body_size 8m;
#limit_zone one $binary _remote_addr 32k;
Sendfile on;
Tcp_nopush on;
Keepalive_timeout 60;
Tcp_nodelay on;
gzip on;
Gzip_min_length 1k;
Gzip_buffers 4 16k;
Gzip_http_version 1.0;
Gzip_comp_level 2;
Gzip_types text/plain application/x-javascript text/css application/xml;
Gzip_vary on;
Log_format wwwlogs ' $remote _addr-$remote _user [$time _local] $request $status $body _bytes_sent $http _referer $http _user _agent $http _x_forwarded_for ';
server {
Listen 80;
server_name www.bbs.com;
Location/{
Root/data/webroot/html/discuz;
Index index.php;
}
Location ~ \.php$ {
Root/data/webroot/html/discuz;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param Script_filename/data/webroot/html/discuz$fastcgi_script_name;
Include Fastcgi_params;
}
}
}
7 Detecting Nginx Syntax correctness
#/usr/local/nginx/sbin/nginx-t
Nginx:the configuration file/usr/local/nginx/conf/nginx.conf syntax is OK
Nginx:configuration file/usr/local/nginx/conf/nginx.conf Test is successful
Restart Nginx Service
Service Nginx Restart
8. Install Discuz Forum
Download Related packages: http://download.comsenz.com/DiscuzX/
#mkdir/data/webroot/html
# Unzip Discuz_x3.2_sc_utf8.zip
# MV Upload/data/webroot/html/discuz
# Chown-r Nginx.nginx/data/webroot/html/discuz
Add the following record in the local Hosts file:
C:\Windows\System32\Drivers\etc\hosts #打开此文件添加如下内容
192.168.17.128 www.bbs.com
9. Browser open 192.168.17.128/install start installation!!!
This article from "intentions to create value, late coffee" blog, declined reprint!
LNMP to build Discuz Forum---practical explanation