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

主机环境 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

如果出现如下错误

[[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

如果出现如下错误

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

[[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

如果出现如下错误

[[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

如果出现如下错误

[[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

如果出现如下错误

[[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

如果出现如下错误

[[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

如果出现如下错误

[[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/

[[email protected] etc]# ls

php-fpm.conf.default

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

[[email protected] etc]# ls

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

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

[[email protected]server1 etc]# ls

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] conf]# cd ..

[[email protected] nginx]# cd html

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

<?php

phpinfo()

?>

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

Starting httpd:                                           [  OK  ]

3.测试  172.25.29.1

时间: 2024-10-29 19:10:28

php源码安装、简单配置、测试及连接数据库的相关文章

Mysql源码安装、配置、初始化及启动

[在此处输入文章标题] 主机环境redhat6.5 实验环境服务端 ip 172.25.29.1  mysql 安装包  mysql-boost-5.7.11.tar.gz   cmake-2.8.12.2-4.el6.x86_64.rpm 1.mysql的源码安装 1.解压压缩包 [[email protected] mnt]# tar zxfmysql-boost-5.7.11.tar.gz  #解压gz包 [[email protected] mnt]# yum installcmake-

mysql-proxy源码安装及配置mysql读写分离

安装Mysql-proxy关联系统包 libevent libevent-devel glib2 glib2-devel lua 5.1.x lua-devel-5.1.x pkg-config mysql-devel openssl openssl-devel gcc* 2安装MySQL-proxy 0.8.5 下载源码包并解压 在源码包路径下安装 ./configure –prefix=/u01/mysql-proxy make make install 3.配置mysql-proxy.cn

PHP源码安装及配置——以fastCGI的方式与httpd整合

在前一篇博文中介绍了LAMP的安装及配置.这里专门介绍PHP以fastCGI的方式与httpd整合的情况下,具体如何编译及配置.而且假定httpd.mysql均如前一篇博文介绍的安装配置完毕.php也采取一样版本的源码包php-5.6.1.tar.bz2. 1.  编译安装php # tar xf php-5.6.1.tar.bz2 # cd php-5.6.1 # ./configure --prefix=/usr/local/php --enable-sockets --enable-mbs

Memcached 源码安装 与 配置

主机环境: CentOS 6.6 x86_64 一,安装memcached 1,由于memcached依赖libevent 库,用它做Socket的处理,因此,我们需要安装libevent库,我这里就用yum来安装了. yum install libevent 2,到官网下载memcached 的源码包.   http://memcached.org 最新版是 v1.4.24 #wget  #tar xf   memcached-1.4.24.tar.gz  #cd memcached-1.4.

Linux下源码安装并配置Nginx

实验环境 一台最小化安装的CentOS 7.3 虚拟机 安装nginx 安装nginx依赖包 yum install -y pcre-devel zlib-devel openssl-devel wget gcc tree vim Nginx依赖于pcre.zlib.openssl,在编译前配置时如果有问题 可以使用yum方式安装三个包(pcre-devel.zlib-devel.openssl-devel) 从Nginx官网下载Nginx源码包 wget http://nginx.org/do

Centos下Nginx源码安装与配置并附shell编程实现自动化安装

一.首先安装必要的库 nginx 中gzip模块需要 zlib 库,rewrite模块需要 pcre 库,ssl 功能需要openssl库.选定/usr/local为安装目录,以下具体版本号根据实际改变. 1.安装PCRE库 $ cd /usr/local/ $ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz $ tar -zxvf pcre-8.36.tar.gz $ cd pcre-8.3

php源码安装常用配置参数和说明

常用的配置参数1. --prefix=/usr/local/php 指定 php 安装目录 install architecture-independent files in PREFIX 默认/usr/local2.--with-config-file-path=PATH php.ini的存放位置 Set the path in which to look for php.ini [PREFIX/lib] --with-config-file-scan-dir=PATH php.ini的扩展目

PHP 源码安装常用配置参数和说明

常用的配置参数1. --prefix=/usr/local/php指定 php 安装目录install architecture-independent files in PREFIX 默认/usr/local2.--with-config-file-path=PATHphp.ini的存放位置Set the path in which to look for php.ini [PREFIX/lib]--with-config-file-scan-dir=PATHphp.ini的扩展目录Set t

《一个操作系统的实现》学习笔记(一) bochs源码安装及配置

前言:本机环境ubuntu 14.04 bochs 2.4.5 一.下载 官网 http://bochs.sourceforge.net/ 二.安装 1.将下载好的压缩包解压并进入该目录 tar vxzf bochs-2.4.5.tar.gz cd bochs-2.4.5 2.安装编译程序依赖的包 sudo apt-get install build-essential 3.检测环境,打开调试功能的开关 ./configure --enable-debugger --enable-disasm

LNMP架构的搭建(nginx+mysql+php源码安装 )+Discuz论坛的搭建

主机环境 redhat6.5 64位 实验环境 服务端 ip172.25.29.1  nginx+mysql+php 安装包   nginx-1.10.1.tar.gz         mysql-boost-5.7.11.tar.gz    cmake-2.8.12.2-4.el6.x86_64.rpm php-5.6.20.tar.bz2         re2c-0.13.5-1.el6.x86_64.rpm         libmcrypt-2.5.8-9.el6.x86_64.rpm