How to compile and install PHP7.0.10 + MySQL5.7.14 + Nginx1.10.1 in CentOS 7.2 (mini version) and centosphp7.0.10

Source: Internet
Author: User
Tags syslog upload php

How to compile and install PHP7.0.10 + MySQL5.7.14 + Nginx1.10.1 in CentOS 7.2 (mini version) and centosphp7.0.10

I. Preparations before installation

1. yum update # update the system

2. yum install gcc-c ++ autoconf automake cmake bison m4 libxml2 libxml2-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel # install php, MySQL, Nngix dependent packages

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

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

5. Now the LNMP environment has been successfully established under CentOS7.2 in my javasurbox.

The above section describes how to compile and install PHP7.0.10 + MySQL5.7.14 + Nginx1.10.1 (mini version) in CentOS 7.2. I hope it will be helpful to you, if you have any questions, please leave a message and the editor will reply to you in time. Thank you very much for your support for the help House website!

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.