Install the LNMP environment by source code compilation and configure multiple virtual hosts Based on Domain Name access
Lab environment and software version:
CentOS version: 6.6 (2.6.32.-504. el6.x86 _ 64)
Apache version: nginx-1.6.2
Mysql version: Mysql-5.6.23
Php version: php-5.6.3
1. Disable firewall: service iptables stop
Chkconfig iptables off
Ii. Disable selinux: sed-I's/SELINUX = disabled/SELINUX = enforcing/G'/etc/selinux/config
Init 6 is required to restart the system!
3. Install nginx
1. Installation preparation
A. mv/etc/yum. repos. d/CentOS-Base.repo/etc/yum. repos. d/CentOS-Base.repo.backup
B. wget-O/etc/yum. repos. d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
C. pcre: yum-y install pcre-devel
D. openssl: yum-y install openssl-devel
2. Install nginx
A.tar xf nginx-1.6.2.tar.gz
B. cd nginx-1.6.2, useradd nginx-s/sbin/nologin-M
C ../configure -- prefix =/application/nginx-1.6.2 -- with-http_stub_status_module -- with-http_ssl_module -- user = nginx -- group = nginx
D. [root @ LNMP nginx-1.6.2] # echo $?
0 indicates that the compilation has no errors.
E. make
F. make install
G. [root @ LNMP nginx-1.6.2] # echo $?
0 indicates that the compilation has no errors.
H. cd-, ln-s/application/nginx-1.6.2/application/nginx
I. Edit nginx. conf
Cd/application/nginx/conf
Vi nginx. conf
Modify the username of row 2nd. the user group name is nginx. Save and exit.
3. Start nginx
[Root @ LNMP tools] #/application/nginx/sbin/nginx-t
Nginx: the configuration file/application/nginx-1.6.2/conf/nginx. conf syntax is OK
Nginx: configuration file/application/nginx-1.6.2/conf/nginx. conf test is successful
The above prompt indicates that nginx installation configuration and syntax are correct!
[Root @ LNMP tools] #/application/nginx/sbin/nginx
[Root @ LNMP tools] # netstat-lntup | grep nginx
Tcp 0 0 0.0.0.0: 80 0.0.0.0: * LISTEN 3685/nginx
[Root @ LNMP tools] # lsof-I: 80
Command pid user fd type device size/OFF NODE NAME
Nginx 3685 root 6u IPv4 13603 0t0 TCP *: http (LISTEN)
Nginx 3686 nginx 6u IPv4 13603 0t0 TCP *: http (LISTEN)
The above prompt indicates that nginx has been successfully run!
[Root @ LNMP tools] # curl 192.168.0.111
If there is any content after curl, nginx is running normally!
4. Source Code installation Mysql-5.6.23
Please refer to the following link for more information: http://linuxzkq.blog.51cto.com/9425412/1584642.
V. php installation
1. Install dependencies:
Yum install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel-y
# Ensure that X software development is installed on devel
2. tar zxf libiconv-1.14.tar.gz
Cd libiconv-1.14
./Configure -- prefix =/usr/local/libiconv
Make
Make install
3. libmcrypt
Wget http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz
Tar zxf libmcrypt-2.5.8.tar.gz
Cd libmcrypt-2.5.8
./Configure
Make
Make install
4. libltdl
Cdlibltdl/
./Configure -- enable-ltdl-install
Make
Make install
5. mhash
Wget http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz
Tar zxf mhash-0.9.9.9.tar.gz
Cd mhash-0.9.9.9/
./Configure
Make
Make install
Rm-f/usr/lib64/libmcrypt .*
Rm-f/usr/lib64/libmhash *
Ln-s/usr/local/lib64/libmcrypt. la/usr/lib64/libmcrypt. la
Ln-s/usr/local/lib64/libmcrypt. so/usr/lib64/libmcrypt. so
Ln-s/usr/local/lib64/libmcrypt. so.4/usr/lib64/libmcrypt. so.4
Ln-s/usr/local/lib64/libmcrypt. so.4.4.8/usr/lib64/libmcrypt. so.4.4.4.8
Ln-s/usr/local/lib64/libmhash. a/usr/lib64/libmhash.
Ln-s/usr/local/lib64/libmhash. la/usr/lib64/libmhash. la
Ln-s/usr/local/lib64/libmhash. so/usr/lib64/libmhash. so
Ln-s/usr/local/lib64/libmhash. so.2/usr/lib64/libmhash. so.2
Ln-s/usr/local/lib64/libmhash. so.2.0.1/usr/lib64/libmhash. so.2.0.1
Ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
6. mcrypt
Centos6.5/6.6 x86_64
Wget http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz
Tar zxf mcrypt-2.6.8.tar.gz
Cd mcrypt-2.6.8/
./Configure LD_LIBRARY_PATH =/usr/local/lib
Make
Make install
Cd ../
7. install php
Tar xf php-5.6.3.tar.gz
Cd php-5.6.3
./Configure \
-- Prefix =/application/php-5.6.3 \
-- With-mysql =/application/mysql \
-- With-iconv-dir =/usr/local/libiconv \
-- With-freetype-dir \
-- With-jpeg-dir \
-- With-png-dir \
-- With-zlib \
-- With-libxml-dir =/usr \
-- Enable-xml \
-- Disable-rpath \
-- Enable-safe-mode \
-- Enable-bcmath \
-- Enable-shmop \
-- Enable-sysvsem \
-- Enable-inline-optimization \
-- With-curl \
-- With-curlwrappers \
-- Enable-mbregex \
-- Enable-fpm \
-- Enable-mbstring \
-- With-mcrypt \
-- With-gd \
-- Enable-gd-native-ttf \
-- With-openssl \
-- With-mhash \
-- Enable-pcntl \
-- Enable-sockets \
-- With-xmlrpc \
-- Enable-zip \
-- Enable-soap \
-- Enable-short-tags \
-- Enable-zend-multibyte \
-- Enable-static \
-- With-xsl \
-- With-fpm-user = nginx \
-- With-fpm-group = nginx \
-- Enable-ftp
Error: Don't know how to define struct flock on this system, set -- enable-opcache = no
This is an error when installing php 5.5, which also applies to 5.6.3
The solution is as follows:
Add/etc/ld. so. conf to/usr/local/lib.
Run ldconfig again.
Error: the error message "libxslt is not installed. Please install libxslt ".
Yum-y install libxslt *
WARNING: configure: WARNING: unrecognized options: -- enable-safe-mode, -- with-curlwrappers, -- enable-zend-multibyte
The above warning prompt is: The above parameter has been removed, indicating that the above parameters are discarded, The php-5.6.3 has removed this option, can be compiled #. /configure -- help | grep "safe-mode". No information is output, indicating that it is not supported!
Error: make: *** [sapi/cli/php] Error 1
Solution: make ZEND_EXTRA_LIBS = '-liconv'
Ln-s/application/mysql/lib/libmysqlclient. so.18/usr/lib64/
Make install
Ln-s/application/php5.6.3 // application/php
Cp php. ini-production/application/php/lib/php. ini
8. Integrate nginx and php
Cd/application/php/etc/
Mv php-fpm.conf.default php-fpm.conf
Edit php-fpm.conf
Cd/application/php/etc
Vi php-fpm.conf
Modify the username in the username. The username is nginx (user = nobody group = nobody is changed to user = nginx group = nginx). Save and exit.
Important Note: the user name in the php-fpm.conf file, user group name must be and nginx. conf file in the user name, user group name unified, otherwise it will be wrong!
/Application/php/sbin/php-fpm-t
/Application/php/sbin/php-fpm
[Root @ LNMP ~] # Netstat-lntup | grep php-fpm
Tcp 0 0 127.0.0.1: 9000 0.0.0.0: * LISTEN 14801/php-fpm ===================================================== =
9. Add auto-start upon startup
Cat>/etc/rc. local <EOF
/Etc/init. d/mysqld start
/Application/php/sbin/php-fpm
/Application/nginx/sbin/nginx
EOF
6. Define virtual machines:
1. cd/application/nginx/conf
Mkdir vhost
Cd vhost
Viwww.etiantian.org. conf
Add the following content:
Server {
Listen 80;
Server_name www.etiantian.org;
Root/web/www;
Index. php index.html index.htm;
Location ~ * \. Php $ {
Fastcgi_index index. php;
Fastcgi_pass 127.0.0.1: 9000;
Include fastcgi_params;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Fastcgi_param SCRIPT_NAME $ fastcgi_script_name;
}
}
Save and exit. The other two virtual hosts are defined in the same way as those above.
Edit nginx. conf:
Vi nginx. conf
Add include vhost/*. conf to the first server label in the http module to enable the nginx VM function.
Create the root directory of the VM in the root directory: mkdir/web/{bbs, blog, www}
Authorize nginx to read and execute the root directory of the VM: chown-R nginx: root/web
2. Test whether LNMP is successful:
Cd/web/www
Vi phpinfo. php
<? Php
Phpinfo ();
?>
Save and exit, and grant the virtual machine the permission to read and run the phpinfo. php file.
Chown-R nginx: root/web
Map the IP address and domain name in the hosts file of the windows client. After accessing www.etiantian.org, if the PHP purple configuration interface appears, access is normal. If not, the following troubleshooting methods and steps are provided:
Windows browser access:
Three steps to troubleshooting:
1) ping 192.168.0.111 physical network connection failure
2) telnet 192.168.0.111 80 browsers to web Services
3) the local server curl 192.168.0.111 web Service is unavailable
I hope to help you. If you have any omissions through my notes, please arrange them!