欢迎来到山村网

centos系统编译安装nginx+php环境另加独立mysql教程

2019-03-09 13:30:06浏览:531 来源:山村网   
核心摘要:  前端(nginx+php)ip:192.168.10.8  后端(独立mysql)ip:192.168.10.5  软件版本:libiconv-1.14.tar.gz mysql-5.1.63.tar.g

  前端(nginx+php)ip:192.168.10.8

  后端(独立mysql)ip:192.168.10.5

  软件版本: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.先在后端安装mysql

  在192.168.10.5上只安装mysql.方法可以去看centos编译安装nginx+php-fpm+mysql里的mysql安装.

  2.在前端安装php-fpm nginx和mysql-client

  这里只说下安装mysql-client和php的编译安装.

代码如下 tar zxf mysql-5.1.63.tar.gz && cd mysql-5.1.63
./configure --prefix=/usr/local/mysql --without-server

  这里只需要加上--without-server就可以让mysql变成客户端了.

  如果出现/bin/rm: cannot remove `libtoolt': No such file or directory,可以去看这篇文章Mysql安装:/bin/rm: cannot remove `libtoolt': No such file or directory.

  没有问题后,执行命令:

代码如下 make && make install

  编译php的时候只需要加上--with-mysql=mysql客户端安装目录就可以了.这里我给出编译参数:

代码如下 ./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=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --without-pear

  nginx的编译没有什么好说的了,我前面centos编译安装nginx+php-fpm+mysql这篇文章里已经有讲过了.

  3.进行测试验证

  当上面的一切都安装好之后,在后端的mysql里给出远程权限,如下:

代码如下 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';

  然后iptables上只允许192.168.10.8访问mysql端口,其他都拒绝.如:

代码如下 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

  然后在192.168.10.8上进行测试,是否可以远程连上mysql

  mysql -h 192.168.10.5 -u root -p

  如果可以连上,就继续下一步的操作,不能连上的话请检查上面是否有错误的地方.

  现在我们加个php页面来测试php是否可以连上mysql,脚本如下:

代码如下 <?php
$link=mysql_connect("192.168.10.5","root","123456");
if(!$link) echo "bad!" ;
else echo "ok!" ;
mysql_close();
?>

  成功的话是ok!的输出,失败的话是bad!的输出,我这里是成功的

  mysql 5.5.x的只安装客户端.

  需要的软件:libiconv-1.14.tar.gz mysql-5.5.25a.tar.gz

  1.安装前的准备

  安装前的准备,可以去看这篇文章centos编译安装nginx+php-fpm+mysql

  2.安装libiconv

代码如下 ./configure --prefix=/usr/local/libiconv
make && make install

  3.只安装mysql客户端

代码如下 cmake . && make mysqlclient libmysql
make install

  这样就只安装了mysql客户端,然后可以输入whereis mysql来查看mysql安装位置.

  whereis mysql

  好了,可以看到跟yum安装的差不多.

  4.安装php

  以前mysql是5.1的时候,只需要加上--with-mysql=mysql客户端安装目录就可以了,但在mysql 5.5.x这个参数就要改变下了,下面是php的编译参数:

代码如下 ./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

  大家可以看最后一行,--with-mysql=shared,/usr --with-mysqli=shared,/usr/bin/mysql_config这就是跟以前不同的行.好了,剩下的就不写了

(责任编辑:豆豆)
下一篇:

nginx rewrite规则怎么配置?

上一篇:

云主机选32位还是64位

  • 信息二维码

    手机看新闻

  • 分享到
打赏
免责声明
• 
本文仅代表作者个人观点,本站未对其内容进行核实,请读者仅做参考,如若文中涉及有违公德、触犯法律的内容,一经发现,立即删除,作者需自行承担相应责任。涉及到版权或其他问题,请及时联系我们 xfptx@outlook.com