从0开始的禅道二次开发-php环境搭建

感谢公司给我压力,给我 php从入门到放弃的机会

环境搭建

php8.0+Linux+Apache+mysql

php8.0搭建

  • 下载php的包到linux环境中
wget https://www.php.net/distributions/php-8.1.7.tar.gz
  • 解压压缩包
tar -xvf php-8.1.7.tar.gz
  • 执行配置命令
./configure --prefix=/usr/local/install/php8 --with-config-file-path=/usr/local/install/php8/etc --with-curl --with-freetype --enable-gd --with-jpeg  --with-gettext --with-kerberos --with-libdir=lib64 --with-libxml --with-mysqli --with-openssl --with-pdo-mysql  --with-pdo-sqlite --with-pear --enable-sockets --with-mhash --with-ldap-sasl --with-xsl --with-zlib --with-zip -with-bz2 --with-iconv  --enable-fpm --enable-pdo  --enable-bcmath  --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl  --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-sysvsem --enable-cli --enable-opcache --enable-intl --enable-calendar --enable-static --enable-mysqlnd
  • 执行命令后我遇到的报错
  1. configure编译提示no acceptable C compiler found in $PATH,这种错误一般就是缺失gcc导致的


    报错
yum install gcc
  1. configure: error: Package requirements (libxml-2.0 >= 2.9.0) were not met:
    No package 'libxml-2.0' found


    报错
configure: error: Package requirements (libxml-2.0 >= 2.9.0) were not met:
No package 'libxml-2.0' found

运行命令

yum install dnf
dnf install libxml2-devel
  1. configure: error: Package requirements (krb5-gssapi krb5) were not met


    报错

解决办法

yum -y install krb5-devel
  1. No package 'openssl' found


    报错

    解决办法

yum install openssl openssl-devel
  1. No package 'sqlite3' found


    image.png
configure: error: Package requirements (sqlite3 >= 3.7.7) were not met:

No package 'sqlite3' found

解决办法

yum install sqlite-devel
  1. checking for BZip2 in default path... not found


    报错

    解决办法

yum install bzip2 bzip2-devel
  1. configure: error: Package requirements (libcurl >= 7.29.0) were not met:


    报错
checking for libcurl >= 7.29.0... no
configure: error: Package requirements (libcurl >= 7.29.0) were not met:

No package 'libcurl' found

解决办法

yum install libcurl-devel
  1. configure: error: Package requirements (libpng) were not met:


    报错
configure: error: Package requirements (libpng) were not met:

No package 'libpng' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

解决办法

yum install libpng-devel

9.configure: error: Package requirements (libjpeg) were not met:


报错
configure: error: Package requirements (libjpeg) were not met:

No package 'libjpeg' found

解决办法

yum install -y libjpeg-devel
  1. configure: error: Package requirements (freetype2) were not met:


    报错
configure: error: Package requirements (freetype2) were not met:

No package 'freetype2' found

解决办法

yum -y install freetype freetype-devel
  1. configure: error: Package requirements (icu-uc >= 50.1 icu-io icu-i18n) were not met:


    报错
checking for icu-uc >= 50.1 icu-io icu-i18n... no
configure: error: Package requirements (icu-uc >= 50.1 icu-io icu-i18n) were not met:

No package 'icu-uc' found
No package 'icu-io' found
No package 'icu-i18n' found

解决办法

yum install libicu-devel

12.configure: error: in `/opt/php/php-8.1.7':


image.png
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking for clang++... no
checking whether the compiler supports GNU C++... no
checking whether g++ accepts -g... no
checking for g++ option to enable C++11 features... none needed
checking how to run the C++ preprocessor... /lib/cpp
configure: error: in `/opt/php/php-8.1.7':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details

解决办法

yum install gcc-c++
  1. configure: error: Package requirements (oniguruma) were not met:
configure: error: Package requirements (oniguruma) were not met:

No package 'oniguruma' found

解决办法

wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz
tar -zxf oniguruma-6.9.4.tar.gz
cd cd oniguruma-6.9.4
./autogen.sh && ./configure --prefix=/usr
// 如果报错则执行 ./autogen.sh: line 6: autoreconf: command not found
dnf install autoconf automake libtool
make
sudo make install

14 configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:

checking for libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0... no
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:

Requested 'libzip >= 0.11' but version of libzip is 0.10.1

解决办法

https://blog.csdn.net/ljh101/article/details/108531725
  • 编译和安装
make
make
make install
make install
  • 查看php安装的情况
    切换到configure指定的安装路径的bin目录,执行版本查看:
/usr/local/install/php8/bin/php --version
  • 管理各种配置文件
    1、生成php.ini配置文件(在php源码压缩包目录下):
cp php.ini-production /usr/local/install/php8/etc/php.ini

2、生成www配置文件:

cd /usr/local/install/php8/etc/php-fpm.d/
cp www.conf.default www.conf

3、生成php-fpm配置文件:

cd /usr/local/install/php8/etc/
cp php-fpm.conf.default php-fpm.conf

4、生成php-fpm可执行文件:

-- 创建存放配置文件的目录
mkdir /usr/local/install/php8/fpm

-- 从源码中复制一份fpm可执行脚本
cp /opt/php/php-8.0.0/sapi/fpm/init.d.php-fpm /usr/local/install/php8/fpm/php-fpm

-- 将php-fpm修改为可执行文件
chmod 740 /usr/local/install/php8/fpm/php-fpm
  • 管理php
    说明:本文推荐使用php-fpm进行管理php程序,php-fpm(FastCGI Process Manager:FastCGI进程管理器)是一个PHPFastCGI管理器,旨在将FastCGI进程管理整合进PHP包中(来源:百度百科)。

优点:相对Spawn-FCGI,php-fpm在CPU和内存方面的控制都更胜一筹,而且前者很容易崩溃,必须用crontab进行监控,而php-fpm则没有这种烦恼。

1、启动php-fpm:

/usr/local/install/php8/fpm/php-fpm start

2、查看php-fpm进程是否启动成功

ps aux | grep php | grep -v grep

3、查看pfp-fpm占用的端口

ss -lntp | grep php

4、执行php --version出现php command not found异常,解决步骤

// 1、修改配置文件
vim /etc/profile
 
//2、添加php环境变量(即configure脚本时指定的安装路径下的bin目录)
PATH=$PATH:/usr/local/install/php8/bin
export PATH
    
// 刷新配置文件
source /etc/profile

5、大功告成


完成
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,544评论 6 501
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,430评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,764评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,193评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,216评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,182评论 1 299
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,063评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,917评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,329评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,543评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,722评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,425评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,019评论 3 326
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,671评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,825评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,729评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,614评论 2 353

推荐阅读更多精彩内容