Source code Compile Install LNMP environment and configure multi-virtual host based on domain name access

Source: Internet
Author: User
Tags install openssl mcrypt

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


One, shut down the firewall: service iptables stop

Chkconfig iptables off

Second, close selinux:sed-i ' s/selinux=disabled/selinux=enforcing/g '/etc/selinux/config

Init 6 reboot system must be!

Three, Nginx installation

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 Pcre-devel

D. openssl:yum-y install OpenSSL Openssl-devel


2. Installing 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.[[email protected] nginx-1.6.2]# echo $?

0 represents compilation without any errors

E.make

F.make Install

G.[[email protected] nginx-1.6.2]# echo $?

0 represents compilation without any 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 user name on line 2nd, the user group name is: Nginx Nginx, save exit.

3. Start Nginx

[Email protected] 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 prompts, on behalf of Nginx installation configuration, grammar, etc. right!

[Email protected] tools]#/application/nginx/sbin/nginx

[Email protected] tools]# Netstat-lntup|grep Nginx

TCP 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3685/nginx

[Email protected] 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, on behalf of Nginx has been successfully run!

[Email protected] tools]# Curl 192.168.0.111

If there is content after curl, it means that Nginx is running normally!


Iv. Source Code Installation Mysql-5.6.23

Please visit: http://linuxzkq.blog.51cto.com/9379412/1584642, not here description


V. Installation of PHP

1. Installation dependencies:

Yum install zlib libxml libjpeg freetype libpng gd Curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel L Ibpng-devel Gd-devel curl-devel-y

#确保devel安装上X Software Development

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

CD libltdl/

./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.8

Ln-s/USR/LOCAL/LIB64/LIBMHASH.A/USR/LIB64/LIBMHASH.A

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.php Installation

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


An error occurred: Don ' t know how to define the struct flock on the This system, set--enable-opcache=no

This is the error when installing PHP 5.5, the same applies to 5.6.3

The solution is as follows:

Edit/etc/ld.so.conf Join/usr/local/lib

Then execute the ldconfig.


Error: Prompt does not install LIBXSLT, please install LIBXSLT

Yum-y Install libxslt*


Warning: configure:WARNING:unrecognized options:--enable-safe-mode,--with-curlwrappers,--enable-zend-multibyte


The above warning is said: The above parameters have been removed, indicating that these parameters are deprecated, php-5.6.3 has removed the option, compile can #./configure--help | grep "Safe-mode" to see, there is no information output, indicating that it is not supported!


Error occurred: Make: * * * [sapi/cli/php] Error 1


Solution method: 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. Integration of 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 user name inside, user group name: Nginx nginx (user=nobody group=nobody changed to User=nginx Group=nginx), save exit.

Key Note: php-fpm.conf file inside the user name, user group name must and nginx.conf file inside the user name, user group name unified, otherwise error!

/application/php/sbin/php-fpm-t

/application/php/sbin/php-fpm

[Email protected] ~]# Netstat-lntup|grep PHP-FPM

TCP 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 14801/php-fpm ============== Success Flag ============ ======

9. Join the boot-up

Cat >>/etc/rc.local<<eof

/etc/init.d/mysqld start

/application/php/sbin/php-fpm

/application/nginx/sbin/nginx

Eof


Six. define the virtual machine:

1. cd/application/nginx/conf

mkdir Vhost

CD Vhost

VI www.etiantian.org.conf

Add the following content:

server {

Listen 80;

server_name www.etiantian.org;

root/web/www;

Index 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 exit, the other two virtual host definitions are similar to the above and are no longer written.

Edit nginx.conf:

VI nginx.conf

Include vhost/*.conf to open nginx virtual machine function before the first server tag inside the HTTP module

Create virtual machine root directory at root: mkdir/web/{bbs,blog,www}

To grant Nginx permission to read the permissions to perform the virtual machine root directory: Chown-r nginx:root/web


2. Test whether the LNMP is successful:

Cd/web/www

VI phpinfo.php

<?php

Phpinfo ();

?>

Save exit, give virtual machine permission to read run phpinfo.php file

Chown-r Nginx:root/web

In the Windows client's hosts file to do the IP and Domain name Mapping, access to www.etiantian.org, if there is a PHP purple configuration interface, access to normal, if not normal, the following troubleshooting methods and procedures are given:

Windows browser access:

Three steps in the wrong line:

1) Ping 192.168.0.111 Physical network does not pass

2) Telnet 192.168.0.111 80 browser to Web service does not pass

3) Server local Curl 192.168.0.111 Web service not open


I hope to give you some help, through my shared notes, such as missing places welcome to row bricks!

This article is from the "Lanzhou Linux operation and Maintenance" blog, please be sure to keep this source http://linuxzkq.blog.51cto.com/9379412/1630217

Source code Compile Install LNMP environment and configure multi-virtual host based on domain name access

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.