为了使已安装的PHP7在Ubuntu上单独编译mysqli扩展,首先需要确保编译工具如autoconf和m4已经安装,如果遇到缺失提示,可通过执行"apt-get install autoconf m4"命令进行安装。
接着,在终端中切换到PHP7安装目录下,执行以下命令以配置mysqli扩展的编译过程:./configure --with-php-config=/usr/local/php7/bin/php-config --with-mysqli。这一步骤会生成必要的构建文件。
确保当前目录正确后,使用make && make install命令来执行编译和安装过程。此操作会在PHP的扩展目录生成mysqli.so文件,完成mysqli扩展的安装。
若需安装其他PHP扩展如pdo或pdo_mysql,只需进入对应的ext目录下,按照同样的步骤执行配置,但需将命令中的参数调整为与目标扩展相关的选项,比如将--with-mysqli更改为--with-pdo或--with-pdo-mysql,以此来适应不同的扩展需求。
通过上述步骤,Ubuntu环境下的PHP7能够成功单独编译并安装mysqli等扩展,提升PHP的数据库访问能力,满足不同的应用需求。
② phpinfo怎么用
显示PHP的当前信息,其中包括PHP扩展和编译版本,服务器信息和环境,PHP环境中,路径,主机和本地配置选项,HTTP头,PHP许可等等(详细信息可参考PHP手册)。要得到这些信息,不仅可以从浏览器中查看,还可以使用命令行在服务器上查看。
使用浏览器查看很简单,:只需要在网站目录创建一个PHP文件,使用上面提到的phpinfo()函数,如:
1:<?php
2:phpinfo();
3:?>
然互在浏览器中输入此文件路径即可查看。
在linux服务器上,还可以使用如下命令,不用浏览网页同样可以查看PHP信息,如:
php -r 'phpinfo();'
此命令同样可以得到网页形式的结果。
(2)linuxphp编译参数扩展阅读:
phpinfo使用说明:
boolphpinfo([ int$what = INFO_ALL ] )
输出PHP当前状态的大量信息,包含了 PHP 编译选项、启用的扩展、PHP 版本、服务器信息和环境变量(如果编译为一个模块的话)、PHP环境变量、操作系统版本信息、path 变量、配置选项的本地值和主值、HTTP 头和PHP授权信息(License)。
因为每个系统安装得有所不同,phpinfo()常用于在系统上检查 配置设置和 预定义变量。
phpinfo()同时是个很有价值的、包含所有 EGPCS(Environment, GET, POST, Cookie, Server) 数据的调试工具。
③ php调用linux可执行文件
PHP调用可执行程序的语法例子:
system("ls /usr");
使用system调用,结果直接显示才网页上,参数通过字符串传递
调用注意:
PHP的进程要对可执行程序有相关的权限。
④ linux源码包安装php中的./configure选项详解
1、Linux下,默认是在/usr/local/bin/,假如你设置--prefix=/usr/local/php那么就在/usr/local/php/bin/
2、sbin道理相同。sbin的意思就是server bin
3、EPREFIX没用过
4、如果要用2套版本,用prefix区分开不同的安装目录。php.ini默认在/usr/local/php/etc/
⑤ 怎样开启php的gd库
Windows下开启PHP的GD库支持
找到php.ini,打开内容,找到:
;extension=php_gd2.dll
把最前面的分号“;”去掉,再保存即可,如果本来就没有分号,那就是已经开启了。
Linux下开启PHP的GD库支持
#开启GD库支持有以下几种方法
##检测GD库是否安装命令
php5 -m | grep -i gd
或者
php -i | grep -i --color gd
##如未安装GD库,则为服务器安装,方法如下
### 如果是源码安装,则加入参数
--with-gd
### 如果是debian系的linux系统,用apt-get安装,如下
apt-get install php5-gd
### 如果是CentOS系的系统,用yum安装,如下
yum install php-gd
### 如果是suse系的linux系统,用yast安装,如下
yast -i php5_gd
### 如果嫌这个世界不够蛋疼呢,可以在原先编译PHP不支持GD的情况下附加
先下zlib源码,libpng源码,gd源码
解压后到源码目录
zlib目录
./configure --prefix=/usr/local/zlib
make ; make install
make clean
libpng目录
cp scripts/makefile.linux ./makefile
./configure --prefix=/usr/local/libpng
make ; make install
make clean
gd目录
./configure --prefix=/usr/local/libgd --with-png=/usr/local/libpng
make ; make install
make clean
最后在php.ini中,搜到[gd]后,在下面加一行
extension=/usr/local/libgdgd.so
然后重启php服务,如果不行,试试reboot
好了,不过最后提醒一下,要知道这个世界很多意外的,源码安装,只添加gd库这一个情况下,PHP版本和库的版本各异
,所以:
- 不保证这么付出了这么多后有回报
- 不保证能够成功加载gd.so
- 不保证不怀孕
所以如果是源码安装,最好还是在编译PHP的时候加参数--with-gd
GD库函数
GetImageSize
作用:取得图片的大小[即长与宽] 用法:array GetImageSize(string filename, array [imageinfo]);
ImageArc
作用:画弧线 用法:int ImageArc(int im, int cx, int cy, int w, int h, int s, int e, int col);
ImageChar
作用:写出横向字符 用法:int ImageChar(int im, int font, int x, int y, string c, int col);
ImageCharUp
作用:写出竖式字符 用法:int ImageCharup(int im, int font, int x, int y, string c, int col);
ImageColorAllocate
作用:匹配颜色 用法:int ImageColorAllocate(int im, int red, int green, int blue);
ImageColorTransparent
作用:指定透明背景色 用法:int ImageColorTransparent(int im, int [col]);
ImageCopyResized
作用:复制新图并调整大小 用法:int ImageCopyResized(int dst_im, int src_im, int dstX, int dstY, int srcX,
int srcY, int dstW, int dstH, int srcW, int srcH);
ImageCreate
作用:建立新图 用法:int ImageCreate(int x_size, int y_size);
ImageDashedLine
作用:绘虚线 用法:int ImageDashedLine(int im, int x1, int y1, int x2, int y2, int col);
ImageDestroy 作用:结束图形 用法解释:int ImageDestroy(int im);
ImageFill
作用:图形着色 用法:int ImageFill(int im, int x, int y, int col);
ImageFilledPolygon作用:多边形区域着色 用法:int ImageFilledPolygon(int im, array points, int num_points,
int col);
ImageFilledRectangle作用:矩形区域着色 用法:int ImageFilledRectangle(int im, int x1, int y1, int x2, int
y2, int col);
ImageFillToBorder作用:指定颜色区域内着色 用法:int ImageFillToBorder(int im, int x, int y, int border,
int col);
ImageFontHeight
作用:取得字型的高度 用法:int ImageFontHeight(int font);
ImageFontWidth作用:取得字型的宽度 用法:int ImageFontWidth(int font);
ImageInterlace作用:使用交错式显示与否 用法:int ImageInterlace(int im, int [interlace]);
ImageLine作用:绘实线 用法:int ImageLine(int im, int x1, int y1, int x2, int y2, int col);
ImageLoadFont作用:载入点阵字型 用法:int ImageLoadFont(string file);
ImagePolygon作用:绘多边形 用法:int ImagePolygon(int im, array points, int num_points, int col);
ImageRectangle作用:绘矩形 用法:int ImageRectangle(int im, int x1, int y1, int x2, int y2, int col);
ImageSetPixel作用:绘点 用法:int ImageSetPixel(int im, int x, int y, int col); ImageString 作用:绘横式
字符串 用法:int ImageString(int im, int font, int x, int y, string s, int col);
ImageStringUp作用:绘直式字符串 用法:int ImageStringUp(int im, int font, int x, int y, string s, int
col);
ImageSX
作用:取得图片的宽度 用法:int ImageSX(int im);
ImageSY
作用:取得图片的高度 用法:int ImageSY(int im);
ImageTTFBBox
作用:计算 TTF 文字所占区域 用法:array ImageTTFBBox(int size, int angle, string fontfile, string text);
ImageTTFText作用:写 TTF 文字到图中 用法:array ImageTTFText(int im, int size, int angle, int x, int y,
int col, string fontfile, string text); ImageColorAt 作用:取得图中指定点颜色的索引值 用法:int
ImageColorAt(int im, int x, int y);
ImageColorClosest
作用:计算色表中与指定颜色最接近者 用法:int ImageColorClosest(int im, int red, int green, int blue);
ImageColorExact
作用:计算色表上指定颜色索引值 用法:int ImageColorExact(int im, int red, int green, int blue);
ImageColorResolve
作用:计算色表上指定或最接近颜色的索引值 用法:int ImageColorResolve(int im, int red, int green, int
blue);
ImageColorSet
作用:设定色表上指定索引的颜色 用法:boolean ImageColorSet(int im, int index, int red, int green, int
blue); ImageColorsForIndex 作用:取得色表上指定索引的颜色 用法:array ImageColorsForIndex(int im, int
index);
ImageColorsTotal
作用:计算图的颜色数 用法:int ImageColorsTotal(int im); ImagePSLoadFont 作用:载入 PostScript 字型 用法
:int ImagePSLoadFont(string filename);
ImagePSFreeFont
作用:卸下 PostScript 字型 用法:void ImagePSFreeFont(int fontindex);
ImagePSEncodeFont
作用:PostScript 字型转成向量字 用法:int ImagePSEncodeFont(string encodingfile);
ImagePSText作用:写 PostScript 文字到图中 用法:array ImagePSText(int image, string text, int font, int
size, int foreground, int background, int x, int y, int space, int tightness, float angle, int
antialias_steps);
ImagePSBBox作用:计算 PostScript 文字所占区域 用法: array ImagePSBBox(string text, int font, int size,
int space, int width, float angle);
ImageCreateFromPNG作用:取出 PNG 图型 用法:int ImageCreateFromPng(string filename);
ImagePNG作用:建立 PNG 图型 用法:int ImagePng(int im, string [filename]);
ImageCreateFromGIF作用:取出 GIF 图型 用法:int ImageCreateFromGif(string filename);
ImageGIF作用:建立 GIF 图型 用法:int ImageGif(int im, string [filename]);