阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

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

364次阅读
没有评论

共计 7443 个字符,预计需要花费 19 分钟才能阅读完成。

主机环境 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. 解压
[root@server1 mnt# tar jxf php-5.6.20.tar.bz2    #解压
[root@server1 php-5.6.20]# rpm -vih libmcrypt-*  #安装 libmcrypt 库
[root@server1 php-5.6.20]# yum installre2c-0.13.5-1.el6.x86_64.rpm –y  #安装 re2c
 
2. 软件配置
[root@server1 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
 
如果出现如下错误

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

[root@server1 php-5.6.20]# yum install libxml2-devel -y
 
重新配置
[root@server1 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
 
如果出现如下错误

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

[root@server1 php-5.6.20]# yum provides */easy.h

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

[root@server1 php-5.6.20]# yum install -ylibcurl-devel-7.19.7-37.el6_4.x86_64
 
重新配置
[root@server1 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
 
如果出现如下错误

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

[root@server1 php-5.6.20]# yum provides */jpeglib.h
[root@server1 php-5.6.20]# yum install -ylibjpeg-turbo-devel-1.2.1-1.el6.x86_64
 
重新配置
[root@server1 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
 
如果出现如下错误

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

[root@server1 php-5.6.20]# yum provides */png.h
[root@server1 php-5.6.20]# yum install -ylibpng-devel-1.2.49-1.el6_2.x86_64
 
重新配置
[root@server1 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
 
如果出现如下错误

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

[root@server1 php-5.6.20]# yum install -y freetype-devel
 
重新配置
[root@server1 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
 
如果出现如下错误

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

[root@server1 php-5.6.20]# yum provides */gmp.h
[root@server1 php-5.6.20]# yum install -y gmp-devel-4.3.1-7.el6_2.2.x86_64
 
重新配置
[root@server1 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
 
如果出现如下错误

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

[root@server1 php-5.6.20]# yum install -y net-snmp-devel
 
重新配置
[root@server1 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. 编译、链接、安装
[root@server1 php-5.6.20]# make #编译
[root@server1 php-5.6.20]# make install  #安装
 
2.php 的简单配置
[root@server1 php-5.6.20]# cd /usr/local/lnmp/php/etc/
[root@server1 etc]# ls
php-fpm.conf.default
[root@server1 etc]# cp php-fpm.conf.default php-fpm.conf  #备份 php 的文件
[root@server1 etc]# ls
php-fpm.conf php-fpm.conf.default
[root@server1 etc]# cp /mnt/php-5.6.20/php.ini-production php.ini  #php 的配置文件
[root@server1 etc]# ls
php-fpm.conf php-fpm.conf.default  php.ini

如果要连接数据库,就做以下修改
[root@server1 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  #同上
[root@server1 etc]# vim php-fpm.conf
25 pid = run/php-fpm.pid          #将 pid 的标记去掉
 
[root@server1 etc]# cd /mnt/php-5.6.20/sapi/fpm/
[root@server1 fpm]# cp init.d.php-fpm /etc/init.d/php-fpm  #添加启动命令
[root@server1 fpm]# chmod +x /etc/init.d/php-fpm      #添加可执行权限
[root@server1 fpm]# ll /etc/init.d/php-fpm
-rwxr-xr-x 1 root root 2359 Sep 18 00:18 /etc/init.d/php-fpm
[root@server1 fpm]# /etc/init.d/php-fpm start        #开启 php 服务
Starting php-fpm  done
 
[root@server1 fpm]# cd /usr/local/lnmp/nginx/conf/
[root@server1 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        }
 
[root@server1 conf]# nginx –t      #检测
[root@server1 conf]# nginx          #开启
[root@server1 conf]# cd ..
[root@server1 nginx]# cd html
[root@server1 html]# vim index.php      #写一个简单的测试文件
<?php
phpinfo()
?>
[root@server1 html]# /etc/init.d/httpd start      #开启 httpd
Starting httpd:                                          [OK]
 
3. 测试  172.25.29.1

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

PHP 7 革新与性能优化 http://www.linuxidc.com/Linux/2015-09/123136.htm

PHP 7,你值得拥有  http://www.linuxidc.com/Linux/2015-06/118847.htm 

在 CentOS 7.x / Fedora 21 上面体验 PHP 7.0  http://www.linuxidc.com/Linux/2015-05/117960.htm 

CentOS 6.3 安装 LNMP (PHP 5.4,MyySQL5.6) http://www.linuxidc.com/Linux/2013-04/82069.htm 

在部署 LNMP 的时候遇到 Nginx 启动失败的 2 个问题 http://www.linuxidc.com/Linux/2013-03/81120.htm 

Ubuntu 安装 Nginx php5-fpm MySQL(LNMP 环境搭建) http://www.linuxidc.com/Linux/2012-10/72458.htm 

《细说 PHP》高清扫描 PDF+ 光盘源码 + 全套教学视频 http://www.linuxidc.com/Linux/2014-03/97536.htm 

CentOS 6 中配置 PHP 的 LNMP 的开发环境  http://www.linuxidc.com/Linux/2013-12/93869.htm 

PHP 的详细介绍:请点这里
PHP 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-10/135977.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计7443字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中

星哥玩云

星哥玩云
星哥玩云
分享互联网知识
用户数
4
文章数
19350
评论数
4
阅读量
7960825
文章搜索
热门文章
星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛 NAS-6:抖音视频同步工具,视频下载自动下载保存 前言 各位玩 NAS 的朋友好,我是星哥!...
星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛 NAS-3:安装飞牛 NAS 后的很有必要的操作 前言 如果你已经有了飞牛 NAS 系统,之前...
我把用了20年的360安全卫士卸载了

我把用了20年的360安全卫士卸载了

我把用了 20 年的 360 安全卫士卸载了 是的,正如标题你看到的。 原因 偷摸安装自家的软件 莫名其妙安装...
再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见 zabbix!轻量级自建服务器监控神器在 Linux 的完整部署指南 在日常运维中,服务器监控是绕不开的...
飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛 NAS 中安装 Navidrome 音乐文件中文标签乱码问题解决、安装 FntermX 终端 问题背景 ...
阿里云CDN
阿里云CDN-提高用户访问的响应速度和成功率
随机文章
星哥带你玩飞牛NAS-11:咪咕视频订阅部署全攻略

星哥带你玩飞牛NAS-11:咪咕视频订阅部署全攻略

星哥带你玩飞牛 NAS-11:咪咕视频订阅部署全攻略 前言 在家庭影音系统里,NAS 不仅是存储中心,更是内容...
【开源神器】微信公众号内容单篇、批量下载软件

【开源神器】微信公众号内容单篇、批量下载软件

【开源神器】微信公众号内容单篇、批量下载软件 大家好,我是星哥,很多人都希望能高效地保存微信公众号的文章,用于...
飞牛NAS玩转Frpc并且配置,随时随地直连你的私有云

飞牛NAS玩转Frpc并且配置,随时随地直连你的私有云

飞牛 NAS 玩转 Frpc 并且配置,随时随地直连你的私有云 大家好,我是星哥,最近在玩飞牛 NAS。 在数...
星哥带你玩飞牛 NAS-10:备份微信聊天记录、数据到你的NAS中!

星哥带你玩飞牛 NAS-10:备份微信聊天记录、数据到你的NAS中!

星哥带你玩飞牛 NAS-10:备份微信聊天记录、数据到你的 NAS 中! 大家对「数据安全感」的需求越来越高 ...
仅2MB大小!开源硬件监控工具:Win11 无缝适配,CPU、GPU、网速全维度掌控

仅2MB大小!开源硬件监控工具:Win11 无缝适配,CPU、GPU、网速全维度掌控

还在忍受动辄数百兆的“全家桶”监控软件?后台偷占资源、界面杂乱冗余,想查个 CPU 温度都要层层点选? 今天给...

免费图片视频管理工具让灵感库告别混乱

一言一句话
-「
手气不错
每年0.99刀,拿下你的第一个顶级域名,详细注册使用

每年0.99刀,拿下你的第一个顶级域名,详细注册使用

每年 0.99 刀,拿下你的第一个顶级域名,详细注册使用 前言 作为长期折腾云服务、域名建站的老玩家,星哥一直...
自己手撸一个AI智能体—跟创业大佬对话

自己手撸一个AI智能体—跟创业大佬对话

自己手撸一个 AI 智能体 — 跟创业大佬对话 前言 智能体(Agent)已经成为创业者和技术人绕...
把小米云笔记搬回家:飞牛 NAS 一键部署,小米云笔记自动同步到本地

把小米云笔记搬回家:飞牛 NAS 一键部署,小米云笔记自动同步到本地

把小米云笔记搬回家:飞牛 NAS 一键部署,小米云笔记自动同步到本地 大家好,我是星哥,今天教大家在飞牛 NA...
星哥带你玩飞牛 NAS-10:备份微信聊天记录、数据到你的NAS中!

星哥带你玩飞牛 NAS-10:备份微信聊天记录、数据到你的NAS中!

星哥带你玩飞牛 NAS-10:备份微信聊天记录、数据到你的 NAS 中! 大家对「数据安全感」的需求越来越高 ...
星哥带你玩飞牛NAS硬件02:某鱼6张左右就可拿下5盘位的飞牛圣体NAS

星哥带你玩飞牛NAS硬件02:某鱼6张左右就可拿下5盘位的飞牛圣体NAS

星哥带你玩飞牛 NAS 硬件 02:某鱼 6 张左右就可拿下 5 盘位的飞牛圣体 NAS 前言 大家好,我是星...