Nginx + php7 + mysql is installed under centos7.3, nginxphp7
1. Install Nginx yum
1) Add Nginx to YUM Source
Add the CentOS 7 Nginx yum resource library, open the terminal, and run the following command:
Sudo rpm-Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2) install Nginx
Use in your CentOS 7 serveryumCommand to install Nginx from the Nginx source server:
sudo yum install -y nginx
3) Start Nginx
Enable nginx in nginx-c/etc/nginx/Nginx. conf
Modify the nginx-s reload configuration and then reload it to take effect.
Nginx-s reopen: re-open the log file
Nginx-t-c/path/to/nginx. conf to test whether the nginx configuration file is correct
Nginx-s stop: stop nginx quickly
4) set Nginx to start automatically
sudo systemctl enable nginx.service
5) Nginx configuration file directory
/Etc/nginx/conf. d/
2. php 7 Compilation and Installation
1) cd/usr/local/src/
2) wget http://cn2.php.net/distributions/php-7.0.2.tar.gz
3) tar-xzxvf php-7.0.2.tar.gz
4) cd php-7.0.2
5) do not compile after decompression. Check whether gcc is installed. If not, run yum install gcc.
6) Check whether libxml2 is installed, if not, execute yum install libxml2 7) check whether the libxml2-devel is installed, if not, execute the yum install libxml2-devel Note: because it is changed to nginx, so the -- with-apxs2 =/usr/bin/apxs in the compilation parameter is removed. If you want to configure apache, install apache before installing PHP. 8) Compile parameter configuration '. /configure ''-- prefix =/usr/local/php'' -- with-pdo-pgsql'' -- with-zlib-dir'' -- with-freetype-dir ''-- enable-mbstring ''-- with-libxml-dir =/usr'' -- enable-soap ''-- enable-calendar'' -- with-curl ''-- with-mcrypt'' -- with-gd ''-- with-pgsql'' -- disable-rpath'' -- enable-inline-optimization'' -- with-bz2 ''-- with-zlib'' -- enable-sockets ''-- enable-sysvsem'' -- enable-sysvshm'' -- enable-pcntl ''-- e Nable-mbregex ''-- enable-exif'' -- enable-bcmath ''-- with-mhash'' -- enable-zip ''-- with-pcre-regex'' --- pdo-mysql ''-- with-mysqli'' -- with-jpeg-dir =/usr'' -- with-png-dir =/usr'' -- enable-gd-native- ttf ''-- with-openssl'' -- with-fpm-user = www-data ''-- with-fpm-group = www-data'' -- with-libdir =/lib /x86_64-linux-gnu/''-- enable-ftp'' -- with-gettext ''-- with-xmlrpc'' -- with-xsl ''-- enable-opcache'' -- en Able-fpm'' -- with-iconv'' -- with-xpm-dir =/usr '9) the error Cannot find OpenSSL's <evp. h> RUN yum install openssl-devel 10.) the following error occurs: Please reinstall the libcurl distribution, and yum-y install curl-devel 11.) jpeglib is reported. if h not found, execute yum install libjpeg. x86_64 libpng. x86_64 freetype. x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64-y and execute yum install libjpeg-devel 12) checking fo R BZip2 in default path... not found configure: error: Please reinstall the BZip2 distribution this is the bzip2 package not installed solution yum install bzip2-devel.x86_64-y 13) configure: error: xpm. h not found. yum install libXpm-devel 14) error: Unable to locate gmp. h Fix: yum install gmp-devel 15) symptom: Unable to detect ICU prefix or/usr // bin/icu-config failed. please verify ICU install prefix and make sure icu-config works Solution: yum install-y icu libicu-devel 16) error: mcrypt. h not found. please reinstall libmcrypt. solution: yum install php-mcrypt libmcrypt-devel 17) error: configure: error: Cannot find libpq-fe.h. please specify correct PostgreSQL installation path solution: yum install postgresql-devel 18) error: configure: error: xslt-config not found. please reinstall the libxslt> = 1.1.0 distribution solution: yum inst All libxslt-devel 19) after the checking configuration is completed, run: make clean & make install (if an error occurs: -- execute export LD_LIBRARY_PATH =/usr/local/mysql/lib or export LD_LIBRARY_PATH =/lib/:/usr/local/lib) 20 when ENABLE-OPCACHE = NO) after installation, copy the configuration file in the source code package to the PHP installation directory. The source code package contains two configurations: php. ini-development php. ini-production: You can see the name. One is the development environment and the other is the production environment. Here we will copy the cp php In the development environment. ini-development/usr/local/php/lib/php. ini 21) You also need to set the environment variable: Modify vim/etc/ The profile file permanently takes effect for all system users. Add the following two lines of code PATH = $ PATH at the end of the file: /usr/local/php/bin export PATH and then execute the command source/etc/profile 22) php-v to view the PHP version information. 23) You also need to configure PHP-fpm: cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf cp/usr/local/php/etc/php-fpm.d/www. conf. default/usr/local/php/etc/php-fpm.d/www. conf cp/usr/local/src/php-7.0.2/sapi/fpm/init. d. php-fpm/etc/init. d/php-fpm chmod + x/etc/init. d/php-fpm 24) Start php-fpm:/usr/local/php/sbin/php-fpm3, MySQL yum installation 1) download MySQL source wget http://dev.MySQL.com/get/mysql57-community-release-el7-7.noarch.rpm
2) install MySQL source sudo rpm-ivh mysql57-community-release-el7-7.noarch.rpm
3) install mysql-community-server sudo yum install mysql-community-server-y
4) restart MySQL systemctl restart mysqld Note: systemctl enable mysql is used to automatically start the service.