linuxphp网站怎么安装

linuxphp网站怎么安装,第1张

配置php服务

安饥塌装yasm汇编器(解压与编译过程已省略):

[[email protected]]cd/usr/local/src

[root@linuxprobesrc]tarzxvfyasm-1.2.0.tar.gz

[root@linuxprobesrc]cdyasm-1.2.0

[[email protected]]./configure

[[email protected]]make

[[email protected]]makeinstall

安装libmcrypt加密算法扩展库(解烂银圆压与编译过程已省略):

[[email protected]]cd/usr/local/src

[root@linuxprobesrc]tarzxvflibmcrypt-2.5.8.tar.gz

[root@linuxprobesrc]cdlibmcrypt-2.5.8

[[email protected]]./configure

[[email protected]]make

[[email protected]]makeinstall

安装libvpx视频编码器(解压与编译过程搏旦已省略):

[[email protected]]cd/usr/local/src

[root@linuxprobesrc]tarxjvflibvpx-v1.3.0.tar.bz2

[root@linuxprobesrc]cdlibvpx-v1.3.0

[[email protected]]./configure--prefix=/usr/local/libvpx--enable-shared--enable-vp9

[[email protected]]make

[[email protected]]makeinstall

安装Tiff标签图像文件格式(解压与编译过程已省略):

[[email protected]]cd/usr/local/src

[root@linuxprobesrc]tarzxvftiff-4.0.3.tar.gz

[root@linuxprobesrc]cdtiff-4.0.3

[[email protected]]./configure--prefix=/usr/local/tiff--enable-shared

[[email protected]]make

[[email protected]]makeinstall

安装libpng图片(png格式)函数库(解压与编译过程已省略):

[[email protected]]cd/usr/local/src

[root@linuxprobesrc]tarzxvflibpng-1.6.12.tar.gz

[root@linuxprobesrc]cdlibpng-1.6.12

[[email protected]]./configure--prefix=/usr/local/libpng--enable-shared

[[email protected]]make

[[email protected]]makeinstall

安装freetype字体引擎(解压与编译过程已省略):

[[email protected]]cd/usr/local/src

[root@linuxprobesrc]tarzxvffreetype-2.5.3.tar.gz

[root@linuxprobesrc]cdfreetype-2.5.3

[[email protected]]./configure--prefix=/usr/local/freetype--enable-shared

[[email protected]]make

[[email protected]]makeinstall

安装jpeg图片(jpeg格式)函数库(解压与编译过程已省略):

[[email protected]]cd/usr/local/src

[root@linuxprobesrc]tarzxvfjpegsrc.v9a.tar.gz

[root@linuxprobesrc]cdjpeg-9a

[root@linuxprobejpeg-9a]./configure--prefix=/usr/local/jpeg--enable-shared

[root@linuxprobejpeg-9a]make

[root@linuxprobejpeg-9a]makeinstall

安装libgd图像处理程序(解压与编译过程已省略):

[root@linuxprobejpeg-9a]cd/usr/local/src

[root@linuxprobesrc]tarzxvflibgd-2.1.0.tar.gz

[root@linuxprobesrc]cdlibgd-2.1.0

[[email protected]]./configure--prefix=/usr/local/libgd--enable-shared--with-jpeg=/usr/local/jpeg--with-png=/usr/local/libpng--with-freetype=/usr/local/freetype--with-fontconfig=/usr/local/freetype--with-xpm=/usr/--with-tiff=/usr/local/tiff--with-vpx=/usr/local/libvpx

[[email protected]]make

[[email protected]]makeinstall

安装t1lib图片生成函数库(解压与编译过程已省略):

[[email protected]]cd/usr/local/src

[root@linuxprobesrc]tarzxvft1lib-5.1.2.tar.gz

[root@linuxprobesrc]cdt1lib-5.1.2

[[email protected]]./configure--prefix=/usr/local/t1lib--enable-shared

[[email protected]]make

[[email protected]]makeinstall

将函数库文件放至合适的位置:

[[email protected]]cd/usr/local/src

[root@linuxprobesrc]ln-s/usr/lib64/libltdl.so/usr/lib/libltdl.so

[root@linuxprobesrc]cp-frp/usr/lib64/libXpm.so*/usr/lib/

安装php服务程序(命令比较长,请一定要复制完整!!!):

[root@linuxprobesrc]tar-zvxfphp-5.5.14.tar.gz

[root@linuxprobesrc]cdphp-5.5.14

[[email protected]]exportLD_LIBRARY_PATH=/usr/local/libgd/lib

[[email protected]]./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql-sock=/tmp/mysql.sock--with-pdo-mysql=/usr/local/mysql--with-gd--with-png-dir=/usr/local/libpng--with-jpeg-dir=/usr/local/jpeg--with-freetype-dir=/usr/local/freetype--with-xpm-dir=/usr/--with-vpx-dir=/usr/local/libvpx/--with-zlib-dir=/usr/local/zlib--with-t1lib=/usr/local/t1lib--with-iconv--enable-libxml--enable-xml--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--enable-opcache--enable-mbregex--enable-fpm--enable-mbstring--enable-ftp--enable-gd-native-ttf--with-openssl--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip--enable-soap--without-pear--with-gettext--enable-session--with-mcrypt--with-curl--enable-ctype

[[email protected]]make

[[email protected]]makeinstall

复制php服务程序的配置文件到安装目录:

[[email protected]]cpphp.ini-proction/usr/local/php/etc/php.ini

删除默认的php配置文件:

[[email protected]]rm-rf/etc/php.ini

创建php配置文件的软连接到/etc/目录中:

[[email protected]]cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf

[[email protected]]ln-s/usr/local/php/etc/php-fpm.conf/etc/php-fpm.conf

[[email protected]]ln-s/usr/local/php/etc/php.ini/etc/php.ini

编辑php服务程序的配置文件:

[[email protected]]vim/usr/local/php/etc/php-fpm.conf

//将第25行参数前面的分号去掉。

pid=run/php-fpm.pid

//修改第148和149行,将user与group修改为www。

user=www

group=www

添加php-fpm服务程序到开机启动项:

[[email protected]]cpsapi/fpm/init.d.php-fpm/etc/rc.d/init.d/php-fpm

[[email protected]]chmod+x/etc/rc.d/init.d/php-fpm

[[email protected]]chkconfigphp-fpmon

为了保障网站的安全性,禁用掉不安全的功能:

[[email protected]]vim/usr/local/php/etc/php.ini

//修改第305行的disable_functions参数,追加参数为:

disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname

配置nginx服务程序支持php:

[[email protected]]vim/usr/local/nginx/conf/nginx.conf

//将第2行前面的号去掉并修改为userwwwwww

//将第45行参数修改为indexindex.htmlindex.htmindex.php

//将第65-71行前面的号去掉,修改为:

location~.php${

roothtml

fastcgi_pass127.0.0.1:9000

fastcgi_indexindex.php

fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name

includefastcgi_params

}

重启nginx与php-fpm服务程序:

[[email protected]]systemctlrestartnginx

[[email protected]]systemctlrestartphp-fpm

我一般会选用源码安装 php,安装 php 的过程指定要安装的扩展,但是避免不了缺少某个扩展未安装导致程序运行报错的问题。以 fileinfo 为例,介绍一下怎么添加 php 扩展。

1. 准备

通常遇到报错:xxx function undefined,而这个函数是系统函数的话,那一定是你缺少某个扩展。添加扩展也非常简单。首选要确认当前的 php 是哪个版本,不同版本的 php 扩展会有些许出入。然后找到 Php 源码目录,也就是从网上下载下来并且解压的 php 文件包。添加扩展的时候需要在源码包里面去执行命令。

2. 安装 fileinfo 扩展

1. 确认 php 版本

php -v

# PHP 7.4.4 (cli)

2. 找到 php 可执行文件的位置

whereis php

# php: /usr/local/php /usr/local/php/bin/php

可以看出 php 执行文件在 /usr/local/php/bin 目录里面

那么尝试执行 phpize,保证这个文件存在,phpize 命令在添加扩展的时候需要用到

/usr/local/php/bin/phpize -v

# Configuring for:

# PHP Api Version: 20190902

# Zend Module Api No: 20190902

# Zend Extension Api No: 320190902

3.进入php源码目录

我的习神亩悉惯是网络下载的软件会放在 /usr/local/src 下面,耐丛

cd /usr/local/src/php-7.4.4

cd /etc

cd fileinfo

扩展都在源游乎码目录的 etc 下面,里面有 curl,gd,ftp 等等扩展目录,我要安装 fileinfo,所以到 fileinfo 目录里面

4.开始安装

确定目录下面有 config.m4 文件,如果没有,应该会有 config0.m4 文件,把 config0.m4 复制一份为 config.m4,如果没有这个文件,会报错:can not found config.m4

/usr/local/php/bin/phpize

./configure

make &&make install

如果这几行命令运行下来都没有报错,那么说明扩展文件已经生成,并且已经自动移入相应位置。接下来就是修改 php.ini,追加 extension=fileinfo.so 到 php.ini 中。

5.修改php.ini,加载扩展文件

查看 php.ini 的位置

php -i | grep php.ini

#Configuration File (php.ini) Path =>/usr/local/php/etc

#Loaded Configuration File =>/usr/local/php/etc/php.ini

可以看到 php.ini 的位置: /usr/local/php/etc/php.ini

vim /usr/local/php/etc/php.ini

#添加extension=fileinfo.so,保存

php -m | grep fileinfo

#fileinfo

看到输出 fileinfo,至此,fileinfo 扩展安装完毕!另外可以使用 pecl 命令安装,更方便快捷!

(1) 下吵闭载php源码吵碰乎包->解压->make 编译->install 安装

(2)如果linux系统支持apt-get 命令,则升悉在终端输入: apt-get install php


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/8240685.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-14
下一篇 2023-04-14

发表评论

登录后才能评论

评论列表(0条)

保存