php源码修改数据库配置,php源码安装、简单配置、测试及连接数据库

该博客详细记录了在Red Hat Enterprise Linux 6.5环境下手动编译安装PHP5.6的步骤,包括解决依赖问题、配置选项、编译安装以及配置PHP-FPM和Nginx以支持PHP。博主还提供了一个简单的PHP测试文件,并展示了如何启动相关服务。
摘要由CSDN通过智能技术生成

主机环境 redhat6.5 64位

实验环境 服务端 ip172.25.29.1  php

安装包   php-5.6.20.tar.bz2

re2c-0.13.5-1.el6.x86_64.rpm

libmcrypt-2.5.8-9.el6.x86_64.rpm

libmcrypt-devel-2.5.8-9.el6.x86_64.rpm

Discuz_X3.2_SC_UTF8.zip

1.安装php

1.解压

[[email protected] mnt# tar jxf php-5.6.20.tar.bz2    #解压

[[email protected] php-5.6.20]# rpm -vih libmcrypt-*   #安装libmcrypt库

[[email protected] php-5.6.20]# yum installre2c-0.13.5-1.el6.x86_64.rpm –y   #安装re2c

2.软件配置

[[email protected] php-5.6.20]# ./configure --prefix=/usr/local/lnmp/php--with-config-file-path=/usr/local/lnmp/php/etc --with-openssl --with-snmp--with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir--with-jpeg-dir --with-freetype-dir --with-gettext --without-pear --with-gmp--enable-inline-optimization --enable-soap --enable-ftp --enable-sockets--enable-mbstring --with-mysqli --with-mysql --with-pdo-mysql --enable-fpm--with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash

如果出现如下错误

cfe926b12ce42b5bbcf01798c4f2e162.png

[[email protected] php-5.6.20]# yum install libxml2-devel -y

重新配置

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash

如果出现如下错误

b5748db034abb8ce2eba8f08c7329416.png

[[email protected] php-5.6.20]# yum provides */easy.h

7517d231730be7c2335b63e75599d09e.png

[[email protected] php-5.6.20]# yum install -ylibcurl-devel-7.19.7-37.el6_4.x86_64

重新配置

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash

如果出现如下错误

763ee84dfa20df14f0ab8fe4a154db0f.png

[[email protected] php-5.6.20]# yum provides */jpeglib.h

[[email protected] php-5.6.20]# yum install -ylibjpeg-turbo-devel-1.2.1-1.el6.x86_64

重新配置

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash

如果出现如下错误

139445acafbf3aa5f337f1545f1c09e4.png

[[email protected] php-5.6.20]# yum provides */png.h

[[email protected] php-5.6.20]# yum install -ylibpng-devel-1.2.49-1.el6_2.x86_64

重新配置

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash

如果出现如下错误

f2095940cf2515e35c6b761e1a6e78e7.png

[[email protected] php-5.6.20]# yum install -y freetype-devel

重新配置

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash

如果出现如下错误

16db6b607820fbb2a25a7761aa25c8f2.png

[[email protected] php-5.6.20]# yum provides */gmp.h

[[email protected] php-5.6.20]# yum install -y gmp-devel-4.3.1-7.el6_2.2.x86_64

重新配置

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-openssl--with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir--with-jpeg-dir --with-freetype-dir --with-gettext --without-pear --with-gmp--enable-inline-optimization --enable-soap --enable-ftp --enable-sockets--enable-mbstring --with-mysqli --with-mysql --with-pdo-mysql --enable-fpm--with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash

如果出现如下错误

b9282a7920130f1fc8cb9447f5a90e26.png

[[email protected] php-5.6.20]# yum install -y net-snmp-devel

重新配置

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash

3.编译、链接、安装

[[email protected] php-5.6.20]# make #编译

[[email protected] php-5.6.20]# make install   #安装

2.php的简单配置

[[email protected] php-5.6.20]# cd /usr/local/lnmp/php/etc/

php-fpm.conf.default

[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf   #备份php的文件

php-fpm.conf php-fpm.conf.default

[[email protected] etc]# cp /mnt/php-5.6.20/php.ini-production php.ini   #php的配置文件

php-fpm.conf php-fpm.conf.default  php.ini

如果要连接数据库,就做以下修改

[[email protected] etc]# vim php.ini

925 date.timezone = Asia/Shanghai          #修改时区

1001 pdo_mysql.default_socket=/usr/local/lnmp/mysql/data/mysql.sock   #指定连接数据库的sock文件的路径

1150 mysql.default_socket = /usr/local/lnmp/mysql/data/mysql.sock   #同上

1209 mysqli.default_socket =/usr/local/lnmp/mysql/data/mysql.sock   #同上

[[email protected] etc]# vim php-fpm.conf

25 pid = run/php-fpm.pid          #将pid的标记去掉

[[email protected] etc]# cd /mnt/php-5.6.20/sapi/fpm/

[[email protected] fpm]# cp init.d.php-fpm /etc/init.d/php-fpm   #添加启动命令

[[email protected] fpm]# chmod +x /etc/init.d/php-fpm       #添加可执行权限

[[email protected] fpm]# ll /etc/init.d/php-fpm

-rwxr-xr-x 1 root root 2359 Sep 18 00:18 /etc/init.d/php-fpm

[[email protected] fpm]# /etc/init.d/php-fpm start        #开启php服务

Starting php-fpm  done

[[email protected] fpm]# cd /usr/local/lnmp/nginx/conf/

[[email protected] conf]# vim nginx.conf

51             root   html;

52             index  index.php index.html index.htm;     #在nginx里添加默认访问目录为php优先

50         location / {

53         }

75         location ~ \.php$ {

76             root           html;

77             fastcgi_pass   127.0.0.1:9000;

78             fastcgi_index  index.php;

79             fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

80             include        fastcgi.conf;         #设置成已存在的文件

81         }

[[email protected] conf]# nginx –t       #检测

[[email protected] conf]# nginx           #开启

[[email protected] html]# vim index.php       #写一个简单的测试文件

phpinfo()

?>

[[email protected] html]# /etc/init.d/httpd start      #开启httpd

Starting httpd:                                           [  OK  ]

3.测试172.25.29.1

56d66a6a046efaa55f66b70046d31b55.png

原文:http://12087746.blog.51cto.com/12077746/1854495

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值