CentOS7 install LNMP (Linux + Nginx + MySQL + PHP) and centos7lnmp

Source: Internet
Author: User
Tags install perl automake

CentOS7 install LNMP (Linux + Nginx + MySQL + PHP) and centos7lnmp

Install make:

 

Yum-y install gcc automake autoconf libtool make

 

Install g ++:

 

Yum install gcc-c ++

1.Select source code directory
This document selects/usr/local/src.

 

Cd/usr/local/src

 

2.Install the PCRE Library
Ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ download the latest PCRE source package, use the following command to download the compilation and installation of PCRE package:

 

Cd/usr/local/src

Wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz

Tar-zxvf pcre-8.40.tar.gz

Cd pcre-8.40

./Configure

Make

Make install

 

3.Install zlib libraryWww.zlib.net/zlib-1.2.11.tar.gz
Http://zlib.net/zlib-1.2.8.tar.gz to download the latest zlib source package, use the following command to download the compilation and installation of zlib package:

 

Cd/usr/local/src

 

Wget http://zlib.net/zlib-1.2.11.tar.gz

Tar-zxvf zlib-1.2.11.tar.gz

Cd zlib-1.2.8

./Configure

Make

Make install

 

4.Install ssl (ssl is not installed in some vps by default)

 

Cd/usr/local/src

Wget http://www.openssl.org/source/openssl-1.0.2c.tar.gz

Tar-zxvf openssl-1.0.2c.tar.gz

./Config

Make

Make install

 

5. Install nginx

Nginx generally has two versions: stable version and development version. You can select one of these two versions based on your purpose, the following describes how to install Nginx in the/usr/local/nginx directory:

Cd/usr/local/src

Wget http://nginx.org/download/nginx-1.4.2.tar.gz

Tar-zxvf nginx-1.4.2.tar.gz

Cd nginx-1.4.2

 

./Configure -- sbin-path =/usr/local/nginx

-- Conf-path =/usr/local/nginx. conf

-- Pid-path =/usr/local/nginx. pid

With-http_ssl_module

-- With-pcre =/usr/local/src/pcre-8.38

-- With-zlib =/usr/local/src/zlib-1.2.8

-- With-openssl =/usr/local/src/openssl-1.0.1c

 

Make

Make install

Note:

-- With-pcre =/usr/src/pcre-8.34 refers to the source code path of the pcre-8.34.
-- With-zlib =/usr/src/zlib-1.2.8 refers to the source code path of the zlib-1.2.8.

 

After the installation is successful, the/usr/local/nginx directory is as follows:

Fastcgi. conf koi-win nginx. conf. default

Fastcgi. conf. default logs scgi_params

Fastcgi_params mime. types scgi_params.default

Fastcgi_params.default mime. types. default uwsgi_params

Html nginx uwsgi_params.default

Koi-utf nginx. conf win-utf

 

 

6. Start
Ensure that port 80 of the system is not occupied by other programs. Run the/usr/local/nginx command to start Nginx,

Netstat-ano | grep 80

 

Start nginx

/Usr/local/nginx

 

 

 

Install PHP-FPM

 

Preparations before installation
Run in centos

Yum-y install gcc automake autoconf libtool make

Yum-y install gcc-c ++ glibc

 

Yum-y install libmcrypt-devel mhash-devel libxslt-devel

Libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel

Zlib-devel glibc-devel glib2 glib2-devel bzip2 bzip2-devel

Ncurses-devel curl-devel e2fsprogs e2fsprogs-devel

Krb5 krb5-devel libidn-devel openssl-devel

 

Http://www.linuxidc.com/Linux/2011-04/34622.htm

 

 

 

New version of php-fpm installation (Recommended Installation Method)

Wget http://cn2.php.net/distributions/php-5.6.18.tar.gz

Tar zvxf php-5.6.18.tar.gz

Cd php-5.6.18

./Configure -- prefix =/usr/local/php -- enable-fpm -- with-mcrypt

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

 

Make all install

 

Below are the settings for php-fpm running users

Cd/usr/local/php

Cp etc/php-fpm.conf.default etc/php-fpm.conf

Vi etc/php-fpm.conf

Modify
User = www-data
Group = www-data

If the www-data user does not exist, add the www-data user first.
Groupadd www-data
Useradd-g www-data

 

Modify the nginx configuration file to support php-fpm

After nginx is installed, change the nginx configuration file to nginx. conf.

Http://www.nginx.cn/wp-content/uploads/2012/09/nginx.conf_.txt

The following configuration is added to the server segment. Pay attention to the configuration in red; otherwise, No input file specified will occur.

# Pass the PHP scripts to FastCGI server listening on Fig: 9000
#
Location ~ . Php $ {
Root html;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Include fastcgi_params;
}

Create a PHP Test File

Create a PHP File

Create the index. php file in/usr/local/nginx/html and enter the following content:

<? Php

Echo phpinfo ();

?>

 

 

 

 

Start the service

Ngnix:

/Usr/local/nginx port: 80

Php:

/Usr/local/php/sbin/php-fpm port: 9000

 

 

 

 

Install mysql5.6 from the source code in CentOS7.0

1. Install the dependency package.

1. yum install gcc-c ++ ncurses-devel

2. Download The cmakesource code package cmake-2.8.5.tar.gz

Decompress tar zxvf cmake-2.8.5.tar.gz

 

./Bootstrap

Gmake or make can be used here

Make install

Ii. decompress the source code package

1. tar-zxvf mysql-5.6.18.tar.gz

2.

In the source code package, edit the cmd-line-utils/libedit/terminal. c file.
Comment on the char buf [TC_BUFSIZE] In the terminal_set method and change area = buf to area = NULL;
The changes are as follows:

Protected int terminal_set (EditLine * el, const char * term) {int I;/* char buf [TC_BUFSIZE]; */char * area; const struct termcapstr * t; sigset_t oset, nset; int values, cols; --phpfensi.com (void) sigemptyset (& nset); (void) sigaddset (& nset, SIGWINCH); (void) sigprocmask (SIG_BLOCK, & nset, & oset); area = NULL;

Then re-compile.

 

Iii. Compilation + Installation

1. run cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql5.6/-DMYSQL_DATADIR =/usr/local/mysql5.6/data-DSYSCONFDIR =/usr/local/mysql5.6/-Hangzhou = 1-Hangzhou = 1-DWITH_BLACKHOLE_STORAGE_ENGINE = 1-DWITH_FEDERATED_STORAGE_ENGINE = 1-DWITH_PARTITION_STORAGE_ENGINE = 1-DMYSQL_UNIX_ADDR =/usr/local/mysql5.6/mysqld. sock-DMYSQL_TCP_PORT = 3306-DENABLED_LOCAL_INFILE = 1-DEXTRA_CHARSETS = all-DMYSQL_USER = mysql

2. make

3. make install

4. Create a mysql user

Useradd mysql

Iv. Change the configuration file path

Go to the mysql5.4 source package:

# Conf

Cpsupport-files/my-default.cnf/usr/local/mysql5.6/my. cnf


V. Permission list for installing mysql

Go to the/usr/local/mysql5.6/scripts/directory and run

5.1 chmod 777 mysql_install_db

5.2 yum install perl-Module-Install.noarch

. /Mysql_install_db -- basedir =/usr/local/mysql5.6/-- datadir =/usr/local/mysql5.6/data -- defaults-file =/usr/local/mysql5.6/my. cnf -- user = mysql

# Be sure to specify the configuration file path -- defaults-file =/usr/local/mysql5.6/my. cnf

6. Change directory permissions
Chown-R mysql. mysql/usr/local/mysql5.6


VII. MySQL startup

7.1 cp support-files/mysql. server/etc/init. d/mysql

7.2 chmod 777/etc/init. d/mysql

7.3 rename mv/etc/my. cnf my. cnf. bak

7.4 service mysql start

7.5 boot self-start

/Sbin/chkconfig mysql on

8. log on
/Usr/local/mysql5.6/bin/mysql press enter to execute

 

9

Use mysql;

 

1) Next, modify the mysql password (no password by default)

 

 

Mysql> UPDATE user SET

Password = PASSWORD ('000000 ')

WHERE user = 'root ';

2 ). Allow arbitrary connection

Host field to %

 

Mysql> UPDATE user SET

Host = '%'

WHERE user = 'root ';

 

 

 

Mysql> flush privileges;

 

 

 

 

 

 

PDO Module

 

/Usr/local/php/bin/phpize

./Configure -- with-php-config =/usr/local/php/bin/php-config

 

./Configure -- with-php-config =/usr/local/php/bin/php-config -- with-freetype-dir =/usr/local/freetype

 

Use the following command to create the pdo_mysql module:

./Configure -- with-php-config =/usr/local/php/bin/php-config -- with-pdo-mysql =/usr/local/mysql5.6

 

 

Extension = pdo. so

Extension = pdo_mysql.so

 

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.