Objective
The first time to write Bo, although the predecessors have written a lot, but I still hope to write a deeper impression, there are mistakes please correct me (communication is progress).
As a two-year-old Java programmer, decided to record some of the things done, so that after a few years to review the past, the whole person is confused, do not know what they did, the deployment is because the company gave me a PHP project a few days ago to let me deploy online, I listen very ignorant, I am a Java, PHP I did not do it, but, the command came down, still have to roll up the sleeves, a roll.
Anyway
The server already has Nginx and MySQL, so decided to adopt Php+nginx+mysql This combination, on the internet over a lot of information, because of Linux and PHP do not understand, do not know how PHP and Nginx and MySQL is related, Encountered a variety of reasons (not PHP loaded wrong, is the package is not installed,), spent a lot of time, and then found that after deployment, the three are installed separately (the amount ~ ~ can also be installed together), only need to install after the PHP configuration, nginx configuration (and the Association of PHP) directly can run. As for MySQL, as long as the Open, PHP project inside the connection database configuration, you can directly connect up. so this article is mainly for the installation of PHP.
This article mainly refer to this link Bo main (mingzhiyu): http://www.cnblogs.com/kyuang/p/6801942.html
For Nginx and MySQL installation, it is necessary to install some of the Linux development libraries before starting the installation, which is also included in the reference link.
PHP Version: 5.6.30
Nginx Version: 1.7.3
MySQL version: 5.7.3-m13
PHP Installation Configuration
Nginx itself cannot handle PHP, it is just a Web server, when the request is received, if it is a PHP request, then sent to the PHP interpreter processing, and return the results to the client.
Nginx generally sends the request to the FASTCGI management process processing, the FASTCGI management process chooses the CGI child process processing result and returns NGINX.
What is PHP-FPM? PHP-FPM is a PHP fastcgi manager, only for PHP, the new version is integrated PHP-FPM, PHP-FPM provides better PHP process management, can effectively control memory and process, can be smooth overloaded PHP configuration. In the Configure, with-ENABLE-FPM parameters can be opened php-fpm, other parameters can be seen here, as to what is fastcgi, and php-fpm what relationship, reference links https://segmentfault.com/q/1010000000256516
Pre-Installation Preparation
Add Epel Source
RPM-UVH http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Installation dependencies
Yum Install GCCBison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-develbzip2-devel Readline-devel Libedit-devel sqlite-develYum-YInstall GCC GCC-c++glibcYum-YInstallLibmcrypt-devel Mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-develbzip2 bzip2-devel ncurses ncurses-devel Curl Curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel OpenSSL openssl-devel
cd/usr/local/srcwgethttp//Php.net/get/php-5.6.30.tar.gz/from/this/mirrorTar-ZVXF php-5.6. -.Tar. GZCD php-5.6. -./configure--prefix=/usr/local/php--enable-fpm--with-MCrypt--enable-mbstring--enable-pdo--with-curl--disable-debug--disable-rpath--enable-inline-optimization--with-bz2--with-zlib--enable-Sockets--enable-sysvsem--enable-sysvshm--enable-pcntl--enable-Mbregex--with-mhash--enable-Zip--with-pcre-regex--with-mysql--with-mysqli--WITH-GD--with-jpeg-dir--with-freetype-dir--enable-Calendar Make&& Make Install
If php-5.6.30.tar.gz is not downloaded, you can copy the link directly: Http://php.net/get/php-5.6.30.tar.gz/from/this/mirror to the browser, manual download.
The above completed the installation of PHP-FPM, the installation process will take some time.
About PHP Configuration
1. Provide configuration files for PHP
CP Php.ini-production/usr/local/php/etc/php.ini
Note: Php.ini-production is still in the/usr/local/src/php-5.6.30 directory just now.
2. Provide configuration files for PHP-FPM
cd/usr/local/phpcp etc/php-fpm.conf.default etc/php-fpm.confvim etc/php-fpm.conf
Modify Php-fpm.conf
user = www
Group = www
If the WWW user does not exist, add the WWW user first (the user nobody is run by default)
-G www www
Modify Pm.max_children = 150pm.start_servers = 8pm.min_spare_servers = 5pm.max_spare_servers = 10pid =/usr/local/php/var/run /php-fpm.pid
3. Start PHP-FPM
Perform
/usr/local/php/sbin/php-fpm
Use the following command to verify if the command output has several PHP-FPM processes that indicate that the boot was successful:
PS grep php-fpm
Results such as:
3, Nginx and PHP-FPM integration
Edit Nginx configuration file
Vim/usr/local/nginx/conf/nginx.conf
Modify the following:
Reload the Nginx configuration file:
/usr/local/nginx/sbin/nginx-s Reload
4. Test PHP files
Under/usr/local/nginx/html, create the index.php file and enter the following:
<? php phpinfo ();? >
5. Browser access
Visit http://Your server ip/index.php, you can see the PHP information.
You can also access the address of your project directly, such as http://My server address/admin.php
Success.
6. Cause of error in installation process
When I press the process installation, there are a few errors, one is: Make: * * * There is no rule to create "default" required target "build", this is because the Pcre is not installed on the issue, install it OK. The other is: Mcrypt.h not found. Please reinstall Libmcrypt
Because Php-mcrypt libmcrypt libmcrypt-devel These packages are not installed, the error is generally missing library or package, installation can be.
Deploying PHP projects on the CENTOS7 server