Compile and install php7.0.10 + MySQL5.7.14 + Nginx1.10.1 and 7.2miniphp7.0.10 in CentOS 7.2mini
I. Preparations before installation
1. yum update # update the system
2. yum install gcc-c ++ autoconf automake cmake bison m4 libxml2 libxml2-develLibcurl-devel libjpeg-devel libpng-devel libicu-devel # install packages on which php, MySQL, and Nngix depend
3. download the following package # download all the source files to the root directory. You can modify the directory where the source files are stored.
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
Decompress and install the tool as follows:
# Tar-zvxf libmcrypt-2.5.8.tar.gz
# Cd libmcrypt-2.5.8
#./Configure
# Make & make insatll
4. When installing the software, if you prompt that any dependent package is not installed, You can execute yum install *-y (* indicates the related package)
2. Compile and install Nginx
1. Go to the official website http://nginx.org/en/download.htmlto download the latest stable version of nginx-1.10.1.tar.gz.
2. The compilation procedure is as follows:
1. Upload nginx-1.10.1.tar.gz to the/root directory through winscp.
1.1 groupadd-r nginx # create an nginx Group
1.2 useradd-r-g nginx-s/bin/false nginx # create an nginx user without logon Permissions
1.3 id nginx # view nginx groups and users
2. tar-zvxf nginx-1.10.1.tar.gz
3. cd nginx-1.10.1
4. You can use./configure -- help to view the compilation configuration parameters. You can also refer to http://nginx.org/en/docs/configure.html to write the values in the lower column in the same line.
./Configure
-- Prefix =/usr/local/nginx
-- Modules-path =/usr/local/nginx/modules
With-http_ssl_module
-- Pid-path =/usr/local/nginx. pid
-- User = nginx
-- Group = nginx
5. make & make install # compile and install
6. Start nginx
6.1 cd/usr/local/nginx
6.2 sbin/nginx # Start, you can use sbin/nginx -? View nginx commands
7. Create an nginx. service file in the/usr/lib/systemd/system directory. You can use systemctl stop | start | reload nginx. service to operate nginx. For more information, see configure:
[Unit]
Description = The nginx http and reverse proxy server
After1_syslog.tar get network.tar get remote-fs.target nss-lookup.target
[Service]
Type = forking
PIDFile =/usr/local/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]
Wantedbypolicmulti-user.tar get
Iii. Compile and install MySQL
1. Go to the official website
2. The compilation procedure is as follows:
1. Use winscpto upload mysql-boost-5.7.14.tar.gz to the/root directory.
2. groupadd mysql
3. useradd-r-g mysql-s/bin/false mysql
4. Use cmake to compile mysql. For more information about the parameters, see compile.
Cmake
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql
-DMYSQL_UNIX_ADDR =/usr/local/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_1_emd = 1
5. make & make install
6. Configure mysql and initialize the database
6.1 cd/usr/local/mysql # enter the compilation directory
6.2 chown-R mysql. # modify the directory owner
6.3 chgrp-R mysql. # modify a directory group
6.4 cp/usr/local/mysql/support-files/mysql. server/etc/init. d/mysqld # configure the mysqld service
6.5 cp/usr/local/mysql/support-files/my-default.cnf/usr/local/mysql/my. cnf # Configure my. cnf
6.5.1 copy the following content 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. sock
6.5 chkconfig mysqld on # Set mysqld to start automatically upon startup
6.6 bin/mysqld -- initialize-insecure -- user = mysql -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data # initialize the database
6.7 bin/mysqld -- user = mysql & # Start mysql. If Please read "Security" section of the manual to find out how to run mysqld as root is reported !, Add user = root to my. cnf, which indicates starting with the root user.
7. Modify the root user logon password and allow the root user to log on remotely.
7.1 mysql-u root -- skip-password
7.2 alter user 'root' @ 'localhost' identified by '123 ';
7.3 allow the root user to log on remotely
7.3.1 use mysql;
7.3.2 update user set host = '%' where user = 'root' and host = 'localhost'; # Allow
(Update user set host = 'localhost' where user = 'root'; # disable)
7.3.3 flush privileges;
7.3.4 service mysqld restart
8. Solve service mysqld start | stop and report MySQL server PID file cocould not be found! Or Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe). You can read this file to solve the related errors.
8.1 chmod 777/usr/local/mysql # because the mysqld. pid file is saved in the/usr/local/mysql directory, ensure that the file has the write permission.
8.2 modify the/etc/init. d/mysqld file through winSCP
8.2.1 basedir =/usr/local/mysql # manually specify
8.2.2 datadir =/usr/local/mysql/data # manually specify
8.2.3 mysqld_pid_file_path =/usr/local/mysql/mysqld. pid # manually specify
8.2.4 replace all uncommented mysqld_safe characters in this file with mysqld
4. Compile and install php
1. Go to the official website http://php.net/downloads.php to download php7.0.10.
2. The compilation procedure is as follows:
1. Use winscpto upload php-7.0.10.tar.gz to the/root directory.
2. tar-zvxf php-7.0.10.tar.gz # Extract
3. configure the php compilation parameters. You can run the./configure -- help Command to view all the compilation configuration items. The following parameters must be 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 # compile and install
5. cd/usr/local/php # enter the compilation directory.
6. Modify related configuration files
6.1 cp/usr/local/php/etc/php. ini. default/usr/local/php/etc/php. ini # php. the configuration in ini needs to be modified according to the project, configure nginx to 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 # Remove the pid under the [global] item;
6.3 cp/usr/local/php/etc/php-fpm.d/www. conf. default/usr/local/php/etc/php-fpm.d/www. conf # modify the user and group in lines 23 and 24, for example, user = nginx and group = nginx.
7. chmod 777/usr/local/php/var/run # The default PID file is written in the/usr/local/php/var/run directory, So modify the directory permission.
8. sbin/php-fpm # Start php. You can use sbin/php-fpm-h to view the list of related operation commands.
9, in the/usr/lib/systemd/system directory to create a new php-fpm.service file, you can through systemctl stop | start | reload php-fpm.service to operate php-fpm, the content is as follows:
[Unit]
Description = The PHP FastCGI Process Manager
After1_syslog.tar get network.tar get
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]
Wantedbypolicmulti-user.tar get
5. Now the LNMP environment has been successfully established under CentOS7.2 in my javasurbox.