LNMP Environment Construction

Source: Internet
Author: User
Tags mcrypt
1. Check and install the components

Yum-y install gcc automake autoconf libtool make gcc-c++ glibc

2. Installation Library

Yum-y Install libxslt-devel \libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \zli b zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \ncurses ncurses-devel Curl curl-devel e2fsprogs E2FSPR Ogs-devel \krb5-devel libidn libidn-devel OpenSSL openssl-devel

3, Installation Libmcrypt

Cd/usr/local/srcwget Ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gztar ZXVF LIBMCRYPT-2.5.7.TAR.GZCD libmcrypt-2.5.7./configure--prefix=/usr/local/libmcryptmake && make Installvi/etc /ld.so.conf.d/local.conf Add "/usr/local/libmcrypt/lib" ldconfig-v

4. Install PHP

wget Http://cn2.php.net/get/php-5.6.11.tar.gz/from/this/mirrortar zxvf php-5.6.11.tar.gzcd php-5.6.11./configure-- prefix=/usr/local/php  --enable-fpm--with-mcrypt=/usr/local/libmcrypt \--enable-mbstring--disable-pdo-- With-curl--disable-debug  --disable-rpath \--enable-inline-optimization--with-bz2  --with-zlib-- Enable-sockets \--enable-sysvsem--enable-sysvshm--enable-pcntl--enable-mbregex \--with-mhash--enable-zip-- With-pcre-regex--with-mysql--with-mysqli \--with-gd--with-jpeg-dir--with-opensslmake && make install

Installation succeeded:

Configure PHP-FPM

CD/USR/LOCAL/PHP/ETCCP php-fpm-default.conf php-fpm.conf

Modify php-fpm.conf

VI php-fpm.conf

Modify user = Nobody group = Nobody to user = Phpz Group = Phpz

Create user Phpz and user groups Phpz

Groupadd phpzuseradd-g Phpz Phpz

Create PHP.ini


Set Php-fpm.pid

VI php-fpm.conf

Remove the semicolon from the front of the PID = Run/php-fpm.pid.

Note: Restart the php-fpm command: KILL-USR2 ' cat var/run/php-fpm.pid '

4. Installing Nginx


Download and unzip pcre-8.36.tar.gz:

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz tar zxvf pcre-8.36.tar.gz

Download and unzip zlib-1.2.8.tar.gz:

wget Http://zlib.net/zlib-1.2.8.tar.gztar ZXVF zlib-1.2.8.tar.gz

Download and unzip openssl-1.0.1g.tar.gz:

wget Http://www.openssl.org/source/openssl-1.0.1g.tar.gztar ZXVF openssl-1.0.1g.tar.gz

Download and unzip nginx-1.4.7.tar.gz:

wget Http://nginx.org/download/nginx-1.4.7.tar.gztar ZXVF nginx-1.4.7.tar.gz

Installing Nginx

Vi/usr/bin/pod2man #注释第69行cd/usr/local/src/nginx-1.4.7./configure--prefix=/usr/local/nginx \--with-http_ssl_ Module \--with-pcre=/usr/local/src/pcre-8.36 \--with-zlib=/usr/local/src/zlib-1.2.8 \--with-openssl=/usr/local/ src/openssl-1.0.1g

Start Nginx


Browser access: http://localhost

Configure nginx.conf, let nginx processing request through PHP fastcgi, first to Nginx installation directory Cd/usr/local/nginx, modify VI conf/nginx.conf file, find the following:

Uncomment, and then modify/scripts$fastcgi_script_name to $document _root$fastcgi_script_name

Create a new PHP file

Cd/usr/local/nginx/htmlvi index.php


Start PHP-FPM, restart Nginx

/usr/local/php/sbin/php-fpm/usr/local/nginx/sbin/nginx-s Reload

Browser Access

5. Install MySQL


Cd/usr/local/srcwget http://mirrors.sohu.com/mysql/MySQL-Cluster-7.4/mysql-cluster-gpl-7.4.7.tar.gz

Install CMake First:

Yum-y Install CMake

To add a user and group named "mysql":

Groupadd mysqluseradd-r-G MySQL MySQL

Decompression mysql-cluster-gpl-7.4.7.tar.gz:

Tar zxvf mysql-cluster-gpl-7.4.7.tar.gz

The CMake command is as follows:

CMake \-dcmake_install_prefix=/usr/local/mysql \-ddefault_charset=utf8 \-ddefault_collation=utf8_general_ci \- dmysql_tcp_port=3306 \-dmysql_unix_addr=/usr/local/mysql/run/mysql.sock \-dwith_innobase_storage_engine=1 \-DWITH _ssl=yes

Install MySQL:

Make && make install

Installation takes a while, can have a cup of tea

To initialize the database, first switch directories to the MySQL installation directory:


Then change the user and group of all files in the installation directory to MySQL

Chown-r MySQL. chgrp-r MySQL.

Initialize the database:


Then change the owning user of all files of the directory to "root", and then change the owning user of directory "data" to "mysql" (this step is important, otherwise the database may not operate on this directory):

Chown-r root. chown-r mysql datachown-r mysql data/mysqlchown-r mysql.mysql/usr/local/mysql/data

Copy the MySQL configuration file to the profile directory "/etc/", and ask if you want to overwrite the source file input "yes":


To set up MySQL

I set myself as the "run/" folder in the installation directory, so I want to set the user of this folder to "mysql":

Chown-r MySQL./run

The next most iconic step is to run the MySQL daemon:

Bin/mysqld_safe--user=mysql &

Set the password for the "root" account in the MySQL database:

./bin/mysqladmin-u root password ' 123456 '

Use the "root" account to enter the MySQL management system:

./bin/mysql-u Root-p

Enter your password when prompted. The interface after entry should look something like this:

Congratulations, the LNMP environment has been successfully built.






If you have any questions, please submit them in the original comments. Reprint please indicate the source (original URL): http://home.php-z.com/blog-1-39.html

The above describes the LNMP environment, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.