First, the preparation of pre-installation work
1. Yum Update #更新系统
2. Yum install gcc gcc-c++ autoconf automake cmake Bison M4 LIBXML2 libxml2-devellibcurl-devel libjpeg-devel libpng-devel libicu-devel #安装php、MySQL、Nngix所依赖的包
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 as:
#tar-ZVXF libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure
#make && make Insatll
4. If you are prompted to install the software, you can perform yum install *-Y (* indicates the related package) if you have any dependencies that are not installed.
Second, compile and install Nginx
1, to the official website http://nginx.org/en/download.html Download the most nginx-1.10.1.tar.gz stable version
2. Compile the steps as follows
1. Upload nginx-1.10.1.tar.gz to/root directory via WINSCP
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, can pass the./configure--help to view the compilation configuration parameters, also can refer to http://nginx.org/en/docs/configure.html, the following parameters to write in one line
./configure
--prefix=/usr/local/nginx
--modules-path=/usr/local/nginx/modules
--with-http_ssl_module
--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 #启动, can use Sbin/nginx-? View Nginx related operation commands
7. Create a new Nginx.service file in the/usr/lib/systemd/system directory so that it can be 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 Reload
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. Compile the steps as follows
1, upload mysql-boost-5.7.14.tar.gz to/root directory with WINSCP
2, Groupadd MySQL
3, Useradd-r-G mysql-s/bin/false MySQL
4, compile MySQL with cmake, relevant parameters can refer to https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html, the following parameters should be written in one line
CMake
-dcmake_install_prefix=/usr/local/mysql
-dmysql_unix_addr=/usr/local/mysql/mysql.sock
-dsysconfdir=/usr/local/mysql/etc
-dsystemd_pid_dir=/usr/local/mysql
-ddefault_charset=utf8
-ddefault_collation=utf8_general_ci
-dwith_innobase_storage_engine=1
-dwith_archive_storage_engine=1
-dwith_blackhole_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. Configure 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 in the "Security" section of the manual to the find out what to run MYSQ LD as root!, adding user=root to the my.cnf, means to start with the root user
7. Modify the root user login password and allow the root user to log in remotely
7.1 Mysql-u Root--skip-password
7.2 ALTER USER ' root ' @ ' localhost ' identified by ' 123456 ';
7.3 Allow root users to log on remotely
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 the error by reading this file
8.1 chmod 777/usr/local/mysql #因我设置mysqld. pid files are saved in the/usr/local/mysql directory, so that they have writable permissions
8.2 Modifying/etc/init.d/mysqld files by 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 Replace all non-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. Compile the steps as follows
1, upload php-7.0.10.tar.gz to/root directory with WINSCP
2, TAR-ZVXF php-7.0.10.tar.gz #解压
3, the configuration compiled PHP parameters, you can use the./configure--help command to view all compiled configuration items, the following parameters are written in 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-fpm-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 configuration according to the project needs to modify, configuration Nginx support PHP/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] in front of 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 Rows Modify user and group such as: User = Nginx,group = Nginx
7, chmod 777/usr/local/php/var/run #默认PID文件是写在/usr/local/php/var/run This directory, so modify the directory permissions
8, SBIN/PHP-FPM #启动php, you can view the list of related operation commands through sbin/php-fpm-h
9. Create a new Php-fpm.service file in the/usr/lib/systemd/system directory so that it can be 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
Execstop=/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, at this point in my Virturbox CentOS7.2 successfully built LNMP environment
Compile and install php7.0.10+mysql5.7.14+nginx1.10.1 in CentOS 7.2mini version