First, before the installation of the preparatory work
1, yum update #更新系统
2, yum install gcc gcc-c++ autoconf automake cmake Bison M4 libxml2 libxml2-devel libcurl-devel libjpeg-devel libpng-devel Libicu-devel #安装php, MySQL, Nngix-dependent packages
3, download the following package #我把所有源文件都下载在root目录, readers can modify the source file storage directory
3.1 libmcrypt-2.5.8.tar.gz
3.2 mcrypt-2.6.8.tar.gz
3.3 mhash-0.9.9.9.tar.gz
3.4 zlib-1.2.8.tar.gz
Unzip and install such as:
#tar-zvxf libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure
#make && make Insatll
4, in the installation of software, if prompted what the dependency package is not installed can be executed yum install *-y (* to express the related package)
Ii. Compiling and installing Nginx
1, to the official website http://nginx.org/en/download.html Download the most nginx-1.10.1.tar.gz stable version
2, the compilation steps as follows
1, through the WINSCP upload nginx-1.10.1.tar.gz to the/root directory
1.1 Groupadd-r Nginx #新建nginx组
1.2 Useradd-r-G nginx-s/bin/false Nginx #新建无登录权限的nginx用户
1.3 ID Nginx #查看nginx组及用户
2, TAR-ZVXF nginx-1.10.1.tar.gz
3. CD nginx-1.10.1
4. You can view the compilation configuration parameters by using the./configure--help, or you can refer to the http://nginx.org/en/docs/configure.html, the following parameters to be written on one line
./configure
--prefix=/usr/local/nginx
--modules-path=/usr/local/nginx/modules
--with-http_ssl_modu Le
--pid-path=/usr/local/nginx/nginx.pid
--user=nginx
--group=nginx
5, make && make install #编译并安装
6, start Nginx
6.1 Cd/usr/local/nginx
6.2 Sbin/nginx #启动, you can use Sbin/nginx-? View nginx Related Operations Command
7, in the/usr/lib/systemd/system directory under the new Nginx.service file, so you can pass Systemctl stop|start|reload Nginx.service to operate Nginx, can also refer to https://www.nginx.com/resources/wiki/start/topics/examples/systemd/, the contents are as follows:
[Unit]
Description=the NGINX HTTP and reverse proxy server
after=syslog.target network.target remote-fs.target nss-lookup . Target
[Service]
type=forking
pidfile=/usr/local/nginx/nginx.pid
execstartpre=/usr/local/ Nginx/sbin/nginx-t
Execstart=/usr/local/nginx/sbin/nginx
execreload=/usr/local/nginx/sbin/nginx-s Reloa D
execstop=/usr/local/nginx/sbin/nginx-s Stop
privatetmp=true
[Install]
Wantedby=multi -user.target
Third, compile and install MySQL
1, to the official website http://dev.mysql.com/Downloads/MySQL-5.7/mysql-boost-5.7.14.tar.gz download with boost 5.7.14 version
2, the compilation steps as follows
1, with WINSCP upload mysql-boost-5.7.14.tar.gz to/root directory
2, Groupadd MySQL
3. Useradd-r-G mysql-s/bin/false MySQL
4, with CMake compiled MySQL, related parameters can refer to https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html, the following parameters to write in a row
CMake
-dcmake_install_prefix=/usr/local/mysql
-dmysql_unix_addr=/usr/local/mysql/mysql.sock
-DSYSC Onfdir=/usr/local/mysql/etc
-dsystemd_pid_dir=/usr/local/mysql
-ddefault_charset=utf8
-DDEFAULT_CO Llation=utf8_general_ci
-dwith_innobase_storage_engine=1
-dwith_archive_storage_engine=1
-DWITH_BL ackhole_storage_engine=1
-dwith_perfschema_storage_engine=1
-dmysql_datadir=/usr/local/mysql/data
-dwith_boost=boost
-dwith_systemd=1
5, make && make install
6, the configuration of MySQL and initialize the database
6.1 Cd/usr/local/mysql #进入编译目录
6.2 chown-r MySQL. #修改目录所有者
6.3 Chgrp-r MySQL. #修改目录组
6.4 Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld #配置mysqld服务
6.5 cp/usr/local/mysql/support-files/my-default.cnf/usr/local/mysql/my.cnf #配置my. cnf
6.5.1 Copy the following to [Mysqld] in the my.cnf file
user = MySQL
basedir =/usr/local/mysql
datadir =/usr/local/mysql/data
port = 3306
server_id =/usr/local/mysql/mysqld.pid
socket =/usr/local/mysql/mysql.sock
6.5 Chkconfig mysqld on #设置mysqld开机自启
6.6 bin/mysqld--initialize-insecure--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data #初始化数据库
6.7 bin/mysqld--user=mysql & #启动mysql, if you are sorry, read "Security" section of the manual to find out how to run mysqld As root!, add the User=root in the my.cnf to start the root user
7, modify the root user login password and allow the root user remote login
7.1 Mysql-u Root--skip-password
7.2 ALTER USER ' root ' @ ' localhost ' identified by ' 123456 ';
7.3 Allow remote login of root user
7.3.1 use MySQL;
7.3.2 Update user set host= '% ' where user= ' root ' and host= ' localhost '; #允许 (update user set host= ' localhost ' where user= ' root '; #禁用)
7.3.3 flush Privileges;
7.3.4 Service mysqld Restart
8, resolve service mysqld start|stop report MySQL server PID file could not be found! or couldn ' t find MySQL server (/usr/local/mysql/bin/ Mysqld_safe), you can actually resolve related errors by reading this file
8.1 chmod 777/usr/local/mysql #因我设置mysqld. pid file is saved in the/usr/local/mysql directory, so it is guaranteed to have writable permissions
8.2 Modifying/etc/init.d/mysqld files via WINSCP
8.2.1 Basedir=/usr/local/mysql #手动指定
8.2.2 Datadir=/usr/local/mysql/data #手动指定
8.2.3 Mysqld_pid_file_path=/usr/local/mysql/mysqld.pid #手动指定
8.2.4 replaces all annotated mysqld_safe characters in this file with Mysqld
Iv. Compiling and installing PHP
1, to the official website http://php.net/downloads.php Download php7.0.10 version
2, the compilation steps as follows
1, with WINSCP upload php-7.0.10.tar.gz to/root directory
2, TAR-ZVXF php-7.0.10.tar.gz #解压
3, configure the PHP parameters to compile, you can use the./configure--help command to view all the compilation configuration items, the following parameters to write on one line
./configure
--prefix=/usr/local/php
--exec-prefix=/usr/local/php
--datadir=/usr/local/php
--with-config-file-path=/usr/local/php/etc
--with-mysqli=mysqlnd
--with-pdo-mysql=mysqlnd
--with-f Pm-user=nginx
--with-fpm-group=nginx
--with-gd
--with-iconv
--enable-mbstring
--ENABLE-FPM
--enable-mysqlnd
4, make && make install #编译并安装
5, cd/usr/local/php #进入编译目录
6, modify the relevant configuration file
6.1 Cp/usr/local/php/etc/php.ini.default/usr/local/php/etc/php.ini #php. INI related configuration in accordance with the project needs to modify their own, configure Nginx support PHP reference http:// php.net/manual/zh/install.unix.nginx.php
6.2 cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf #去掉 [Global] before the PID;
6.3 Cp/usr/local/php/etc/php-fpm.d/www.conf.default/usr/local/php/etc/php-fpm.d/www.conf #大致在23, 24 lines Modify user and group like: User = Nginx,group = Nginx
7, chmod 777/usr/local/php/var/run #默认PID文件是写在/usr/local/php/var/run This directory, so modify directory permissions
8, SBIN/PHP-FPM #启动php, you can view the list of related operation commands by sbin/php-fpm-h
9, in the/usr/lib/systemd/system directory under the new Php-fpm.service file, so you can pass Systemctl stop|start|reload Php-fpm.service to operate the PHP-FPM, the contents are as follows:
[Unit]
Description=the PHP FastCGI Process Manager
after=syslog.target network.target
before=nginx.service
[Service]
Type=forking
pidfile=/usr/local/php/var/run/php-fpm.pid
execstart=/usr/local/php/sbin/php-fpm
Exec Stop=/bin/kill-quit ' cat/usr/local/php/var/run/php-fpm.pid '
execreload=/bin/kill-usr2 ' Cat/usr/local/php/var /run/php-fpm.pid '
privatetmp=true
[Install]
Wantedby=multi-user.target
Five, thus in my virturbox CentOS7.2 successfully built the LNMP environment
The above is a small set to introduce the CentOS 7.2 under the compilation of installation php7.0.10+mysql5.7.14+nginx1.10.1 method (mini version), I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!