Front End (nginx+php) ip:192.168.10.8
Back end (independent MySQL) ip:192.168.10.5
Software version: libiconv-1.14.tar.gz mysql-5.1.63.tar.gz php-5.2.17.tar.gz php-5.2.17-fpm-0.5.14.diff.gz Php-5.2.17-max-input-vars.patch
1. Install MySQL on the back end first
Only MySQL is installed on the 192.168.10.5. Method can go to see CentOS compile installation nginx+php-fpm+mysql MySQL installation.
2. Install php-fpm Nginx and mysql-client on the front end
Here only the installation of mysql-client and PHP compiler installation.
The code is as follows |
|
Tar zxf mysql-5.1.63.tar.gz && CD mysql-5.1.63 ./configure--prefix=/usr/local/mysql--without-server |
Here you just need to add--without-server to get MySQL to become a client.
If/bin/rm:cannot remove ' libtoolt ': No such file or directory, you can see this article MySQL installation:/bin/rm:cannot remove ' libtoolt ': no suc h file or directory.
When there is no problem, execute the command:
The code is as follows |
|
Make && make install |
When compiling PHP, you just need to add the--with-mysql=mysql client installation directory. Here I give the compilation parameters:
The code is as follows |
|
./configure--prefix=/usr/local/php--enable-fastcgi--enable-fpm--with-fpm-log=/var/log/php-fpm.log\ --with-fpm-conf=/etc/php-fpm.conf--with-fpm-pid=/var/run/php-fpm.pid--with-config-file-path=/etc\ --WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D--with-openssl--with-zlib--enable-bcmath--with-bz2--with-curl\ --enable-ftp--with-gd--enable-gd-native-ttf--with-jpeg-dir--with-png-dir--with-gettext --enable-mbstring--with-mcrypt--enable-soap--enable-zip--with-iconv=/usr/local/libiconv\ --with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--without-pear |
Nginx compiler There is nothing to say, I centos the previous compilation of the installation Nginx+php-fpm+mysql This article has been said.
3. Perform test verification
When everything above is installed, remote permissions are given in MySQL on the back end, as follows:
The code is as follows |
|
GRANT all privileges in *.* to ' root ' @ '% ' identified by ' 123456 '; |
Then iptables only allow 192.168.10.8 access to the MySQL port, the other refused.
The code is as follows |
|
Iptables-a rh-firewall-1-input-s 192.168.10.8-p tcp-m tcp--dport 3306-j ACCEPT Iptables-a rh-firewall-1-input-p TCP--dport 3306-j DROP Services Iptables Save Services Iptables Restart |
Then test on the 192.168.10.8, whether MySQL can be connected remotely
Mysql-h 192.168.10.5-u Root-p
If you can connect, continue to the next step, can not connect the words please check if there is a wrong place.
Now we add a PHP page to test whether PHP can connect to MySQL, the script is as follows:
The code is as follows |
|
<?php $link =mysql_connect ("192.168.10.5", "root", "123456"); if (! $link) echo "bad!"; else echo "ok!"; Mysql_close (); ?> |
Successful words are ok! output, failure is the output of bad!, I am here to be successful
MySQL 5.5.x only installs the client.
Required Software: libiconv-1.14.tar.gz mysql-5.5.25a.tar.gz
1. Pre-Installation Preparation
Before installing, you can go to see this article CentOS compile installation Nginx+php-fpm+mysql
2. Install Libiconv
The code is as follows |
|
./configure--prefix=/usr/local/libiconv Make && make install |
3. Install only MySQL client
The code is as follows |
|
CMake. && make Mysqlclient Libmysql Make install |
This will only install the MySQL client, and then you can enter Whereis MySQL to view the MySQL installation location.
Whereis MySQL
OK, you can see the same as the Yum installation.
4. Install PHP
MySQL was 5.1 before the time, just add the--with-mysql=mysql client installation directory on it, but in the MySQL 5.5.x this parameter will be changed, the following is the PHP compiler parameters:
The code is as follows |
|
./configure--prefix=/usr/local/php--enable-fastcgi--enable-fpm--with-fpm-log=/var/log/php-fpm.log- with-fpm-conf=/etc/php-fpm.conf\ --with-fpm-pid=/var/run/php-fpm.pid--with-config-file-path=/etc--with-config-file-scan-dir=/etc/php.d\ --with-openssl--with-zlib--enable-bcmath--with-bz2--with-curl--enable-ftp\ --WITH-GD--enable-gd-native-ttf--with-jpeg-dir--with-png-dir--with-gettext--with-mhash\ --enable-mbstring--with-mcrypt--enable-soap--enable-zip--with-iconv=/usr/local/libiconv\ --WITH-MYSQL=SHARED,/USR--with-mysqli=shared,/usr/bin/mysql_config |
You can see the last line,--with-mysql=shared,/usr--with-mysqli=shared,/usr/bin/mysql_config This is a different line from the previous one. All right, the rest will not be written.