首页 > 编程 > PHP > 正文

阿里云centos7.6安装php7.3的详细教程

2020-03-22 19:53:23
字体:
来源:转载
供稿:网友
本篇文章给大家带来的内容是关于阿里云centos7.6安装php7.3的详细教程,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

新增用户 用户组
groupadd wwwuseradd -g www www
下载 php
wget https://downloads.php.net/~cmb/php-7.3.0.tar.gz tar xzvf php-7.3.0.tar.gzcd php-7.3.0
编译

--with-fpm-user=www --with-fpm-group=www
这里使用www www 用户、用户组
编译出来的程序启动,就是归属这个用户、用户组

./configure --prefix=/usr/local/php --with-fpm-user=www --with-fpm-group=www --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --enable-fpm
编译错误,解决依赖

configure: error: libxml2 not found. Please check your libxml2 installation.

yum install -y libxml2-devel

configure: error: Please reinstall the BZip2 distribution

yum install -y bzip2-devel

configure: error: cURL version 7.15.5 or later is required to compile php with cURL support

yum install -y curl-devel

configure: error: jpeglib.h not found.

yum install -y libjpeg-devel

configure: error: png.h not found.

yum install -y libpng-devel

configure: error: freetype-config not found.

yum install -y freetype-devel

configure: error: xslt-config not found. Please reinstall the libxslt = 1.1.0 distribution

yum install -y libxslt-devel

configure: error: Please reinstall the libzip distribution

yum install -y libzip-devel

checking for libzip... configure: error: system libzip must be upgraded to version = 0.11

#先删除旧版本yum remove -y libzip#下载编译安装wget https://nih.at/libzip/libzip-1.2.0.tar.gztar -zxvf libzip-1.2.0.tar.gzcd libzip-1.2.0./configuremake make install

off_t undefined 报错

checking libzip... yeschecking for the location of zlib... /usrchecking for pkg-config... (cached) /usr/bin/pkg-configchecking for libzip... in default path: found in /usr/localchecking for zip_open in -lzip... yeschecking for zip_file_set_encryption in -lzip... yeschecking for zip_libzip_version in -lzip... nochecking stdbool.h usability... yeschecking stdbool.h presence... yeschecking for stdbool.h... yeschecking fts.h usability... yeschecking fts.h presence... yeschecking for fts.h... yeschecking for int8_t... (cached) yeschecking for int16_t... (cached) yeschecking for int32_t... (cached) yeschecking for int64_t... (cached) yeschecking for uint8_t... (cached) yeschecking for uint16_t... (cached) yeschecking for uint32_t... (cached) yeschecking for uint64_t... (cached) yeschecking for ssize_t... yeschecking size of short... (cached) 2checking size of int... (cached) 4checking size of long... (cached) 8checking size of long long... (cached) 8checking size of off_t... 0configure: error: off_t undefined; check your library configuration

off_t 类型是在 头文件 unistd.h中定义的,
在32位系统 编程成 long int ,64位系统则编译成 long long int ,
在进行编译的时候 是默认查找64位的动态链接库,
但是默认情况下 centos 的动态链接库配置文件/etc/ld.so.conf里并没有加入搜索路径,
这个时候需要将 /usr/local/lib64 /usr/lib64 这些针对64位的库文件路径加进去。

#添加搜索路径到配置文件echo /usr/local/lib64/usr/local/lib/usr/lib/usr/lib64 /etc/ld.so.conf#然后 更新配置ldconfig -v
安装
make make install

报错
usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory

cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h

成功输出

Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/Installing PHP CLI binary: /usr/local/php/bin/Installing PHP CLI man page: /usr/local/php/php/man/man1/Installing PHP FPM binary: /usr/local/php/sbin/Installing PHP FPM defconfig: /usr/local/php/etc/Installing PHP FPM man page: /usr/local/php/php/man/man8/Installing PHP FPM status page: /usr/local/php/php/php/fpm/Installing phpdbg binary: /usr/local/php/bin/Installing phpdbg man page: /usr/local/php/php/man/man1/Installing PHP CGI binary: /usr/local/php/bin/Installing PHP CGI man page: /usr/local/php/php/man/man1/Installing build environment: /usr/local/php/lib/php/build/Installing header files: /usr/local/php/include/php/Installing helper programs: /usr/local/php/bin/ program: phpize program: php-configInstalling man pages: /usr/local/php/php/man/man1/ page: phpize.1 page: php-config.1Installing PEAR environment: /usr/local/php/lib/php/Warning: continue targeting switch is equivalent to break . Did you mean to use continue 2 ? in phar:///home/flame/software/php-7.3.0/pear/install-pear-nozlib.phar/PEAR/PackageFile/v2/Validator.php on line 1933[PEAR] Archive_Tar - installed: 1.4.3[PEAR] Console_Getopt - installed: 1.4.1[PEAR] Structures_Graph- installed: 1.1.1[PEAR] XML_Util - installed: 1.4.2[PEAR] PEAR - installed: 1.10.5Wrote PEAR system config file at: /usr/local/php/etc/pear.confYou may want to add: /usr/local/php/lib/php to your php.ini include_path/home/flame/software/php-7.3.0/build/shtool install -c ext/phar/phar.phar /usr/local/php/binln -s -f phar.phar /usr/local/php/bin/pharInstalling PDO headers: /usr/local/php/include/php/ext/pdo/
配置,建立目录
cp php.ini-production /usr/local/php/lib/php.inicp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confln -s /usr/local/php/sbin/php-fpm /usr/local/bin
cd /usr/local/php/etc/php-fpm.dvim www.conf

输入

[www]listen = 127.0.0.1:9080 listen.mode = 0666 user = www #php代码目录权限 需要跟这个一致,group = www #php代码目录权限 需要跟这个一致pm = dynamicpm.max_children = 128pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 10000rlimit_files = 1024slowlog = log/$pool.log.slow
加入 systemtl 服务
cd /home/flame/software/php-7.3.0/sapi/fpmcp php-fpm.service /usr/lib/systemd/system/
启动
systemctl start php-fpm
#查看状态systemctl status php-fpm#得到输出● php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled) Active: active (running) since Thu 2018-12-27 16:13:16 CST; 2s ago Main PID: 16835 (php-fpm) CGroup: /system.slice/php-fpm.service ├─16835 php-fpm: master process (/usr/local/php/etc/php-fpm.conf) ├─16836 php-fpm: pool www ├─16837 php-fpm: pool www ├─16838 php-fpm: pool www ├─16839 php-fpm: pool www ├─16840 php-fpm: pool www ├─16841 php-fpm: pool www ├─16842 php-fpm: pool www ├─16843 php-fpm: pool www ├─16844 php-fpm: pool www ├─16845 php-fpm: pool www ├─16846 php-fpm: pool www ├─16847 php-fpm: pool www ├─16848 php-fpm: pool www ├─16849 php-fpm: pool www ├─16850 php-fpm: pool www ├─16851 php-fpm: pool www ├─16852 php-fpm: pool www ├─16853 php-fpm: pool www ├─16854 php-fpm: pool www └─16855 php-fpm: pool wwwDec 27 16:13:16 iZj6cas4fyg41lxhngh1z0Z systemd[1]: Started The PHP FastCGI Process Manager.
测试
mkdir -p /home/www/webroot/phpcd /home/www/webroot/phpvim test.php

输入

 ?phpphpinfo();? 

访问
xxx.xxx.xxx.xxx:8080/test.php

php 命令环境

在$HOME/.profile里新增内容为

export PATH=$PATH:/usr/local/php/bin

专栏

文章详情








flamefatex


flamefatex 21%201%20天前发布%20%20

阿里云%20centos7.6%20安装%20php7.3


php

centos

linux

%2043%20次阅读%20读完需要%2026%20分钟%20%20




%20

%20


新增用户%20用户组
groupadd%20wwwuseradd%20-g%20www%20www
下载%20php
wget%20https://downloads.php.net/~cmb/php-7.3.0.tar.gz%20tar%20xzvf%20php-7.3.0.tar.gzcd%20php-7.3.0
编译


--with-fpm-user=www%20--with-fpm-group=www
这里使用www%20www%20用户、用户组
编译出来的程序启动,就是归属这个用户、用户组

./configure%20--prefix=/usr/local/php%20--with-fpm-user=www%20--with-fpm-group=www%20--with-curl%20--with-freetype-dir%20--with-gd%20--with-gettext%20--with-iconv-dir%20--with-kerberos%20--with-libdir=lib64%20--with-libxml-dir%20--with-mysqli%20--with-openssl%20--with-pcre-regex%20--with-pdo-mysql%20--with-pdo-sqlite%20--with-pear%20--with-png-dir%20--with-jpeg-dir%20--with-xmlrpc%20--with-xsl%20--with-zlib%20--with-bz2%20--with-mhash%20--enable-fpm%20--enable-bcmath%20--enable-libxml%20--enable-inline-optimization%20--enable-mbregex%20--enable-mbstring%20--enable-opcache%20--enable-pcntl%20--enable-shmop%20--enable-soap%20--enable-sockets%20--enable-sysvsem%20--enable-sysvshm%20--enable-xml%20--enable-zip%20--enable-fpm
编译错误,解决依赖

configure:%20error:%20libxml2%20not%20found.%20Please%20check%20your%20libxml2%20installation.

yum%20install%20-y%20libxml2-devel

configure:%20error:%20Please%20reinstall%20the%20BZip2%20distribution

yum%20install%20-y%20bzip2-devel

configure:%20error:%20cURL%20version%207.15.5%20or%20later%20is%20required%20to%20compile%20php%20with%20cURL%20support

yum%20install%20-y%20curl-devel

configure:%20error:%20jpeglib.h%20not%20found.

yum%20install%20-y%20libjpeg-devel

configure:%20error:%20png.h%20not%20found.

yum%20install%20-y%20libpng-devel

configure:%20error:%20freetype-config%20not%20found.

yum%20install%20-y%20freetype-devel

configure:%20error:%20xslt-config%20not%20found.%20Please%20reinstall%20the%20libxslt%20=%201.1.0%20distribution

yum%20install%20-y%20libxslt-devel

configure:%20error:%20Please%20reinstall%20the%20libzip%20distribution

yum%20install%20-y%20libzip-devel

checking%20for%20libzip...%20configure:%20error:%20system%20libzip%20must%20be%20upgraded%20to%20version%20=%200.11

#先删除旧版本yum%20remove%20-y%20libzip#下载编译安装wget%20https://nih.at/libzip/libzip-1.2.0.tar.gztar%20-zxvf%20libzip-1.2.0.tar.gzcd%20libzip-1.2.0./configuremake%20make%20install

off_t%20undefined%20报错

checking%20libzip...%20yeschecking%20for%20the%20location%20of%20zlib...%20/usrchecking%20for%20pkg-config...%20(cached)%20/usr/bin/pkg-configchecking%20for%20libzip...%20in%20default%20path:%20found%20in%20/usr/localchecking%20for%20zip_open%20in%20-lzip...%20yeschecking%20for%20zip_file_set_encryption%20in%20-lzip...%20yeschecking%20for%20zip_libzip_version%20in%20-lzip...%20nochecking%20stdbool.h%20usability...%20yeschecking%20stdbool.h%20presence...%20yeschecking%20for%20stdbool.h...%20yeschecking%20fts.h%20usability...%20yeschecking%20fts.h%20presence...%20yeschecking%20for%20fts.h...%20yeschecking%20for%20int8_t...%20(cached)%20yeschecking%20for%20int16_t...%20(cached)%20yeschecking%20for%20int32_t...%20(cached)%20yeschecking%20for%20int64_t...%20(cached)%20yeschecking%20for%20uint8_t...%20(cached)%20yeschecking%20for%20uint16_t...%20(cached)%20yeschecking%20for%20uint32_t...%20(cached)%20yeschecking%20for%20uint64_t...%20(cached)%20yeschecking%20for%20ssize_t...%20yeschecking%20size%20of%20short...%20(cached)%202checking%20size%20of%20int...%20(cached)%204checking%20size%20of%20long...%20(cached)%208checking%20size%20of%20long%20long...%20(cached)%208checking%20size%20of%20off_t...%200configure:%20error:%20off_t%20undefined;%20check%20your%20library%20configuration

off_t%20类型是在%20头文件%20unistd.h中定义的,
在32位系统%20编程成%20long%20int%20,64位系统则编译成%20long%20long%20int%20,
在进行编译的时候%20是默认查找64位的动态链接库,
但是默认情况下%20centos%20的动态链接库配置文件/etc/ld.so.conf里并没有加入搜索路径,
这个时候需要将%20/usr/local/lib64%20/usr/lib64%20这些针对64位的库文件路径加进去。

#添加搜索路径到配置文件echo%20/usr/local/lib64/usr/local/lib/usr/lib/usr/lib64%20/etc/ld.so.conf#然后%20更新配置ldconfig%20-v
安装
make%20make%20install

报错
usr/local/include/zip.h:59:21:%20fatal%20error:%20zipconf.h:%20No%20such%20file%20or%20directory

cp%20/usr/local/lib/libzip/include/zipconf.h%20/usr/local/include/zipconf.h

成功输出

Installing%20shared%20extensions:%20/usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/Installing%20PHP%20CLI%20binary:%20/usr/local/php/bin/Installing%20PHP%20CLI%20man%20page:%20/usr/local/php/php/man/man1/Installing%20PHP%20FPM%20binary:%20/usr/local/php/sbin/Installing%20PHP%20FPM%20defconfig:%20/usr/local/php/etc/Installing%20PHP%20FPM%20man%20page:%20/usr/local/php/php/man/man8/Installing%20PHP%20FPM%20status%20page:%20/usr/local/php/php/php/fpm/Installing%20phpdbg%20binary:%20/usr/local/php/bin/Installing%20phpdbg%20man%20page:%20/usr/local/php/php/man/man1/Installing%20PHP%20CGI%20binary:%20/usr/local/php/bin/Installing%20PHP%20CGI%20man%20page:%20/usr/local/php/php/man/man1/Installing%20build%20environment:%20/usr/local/php/lib/php/build/Installing%20header%20files:%20/usr/local/php/include/php/Installing%20helper%20programs:%20/usr/local/php/bin/%20program:%20phpize%20program:%20php-configInstalling%20man%20pages:%20/usr/local/php/php/man/man1/%20page:%20phpize.1%20page:%20php-config.1Installing%20PEAR%20environment:%20/usr/local/php/lib/php/Warning:%20continue%20targeting%20switch%20is%20equivalent%20to%20break%20.%20Did%20you%20mean%20to%20use%20continue%202%20?%20in%20phar:///home/flame/software/php-7.3.0/pear/install-pear-nozlib.phar/PEAR/PackageFile/v2/Validator.php%20on%20line%201933[PEAR]%20Archive_Tar%20-%20installed:%201.4.3[PEAR]%20Console_Getopt%20-%20installed:%201.4.1[PEAR]%20Structures_Graph-%20installed:%201.1.1[PEAR]%20XML_Util%20-%20installed:%201.4.2[PEAR]%20PEAR%20-%20installed:%201.10.5Wrote%20PEAR%20system%20config%20file%20at:%20/usr/local/php/etc/pear.confYou%20may%20want%20to%20add:%20/usr/local/php/lib/php%20to%20your%20php.ini%20include_path/home/flame/software/php-7.3.0/build/shtool%20install%20-c%20ext/phar/phar.phar%20/usr/local/php/binln%20-s%20-f%20phar.phar%20/usr/local/php/bin/pharInstalling%20PDO%20headers:%20/usr/local/php/include/php/ext/pdo/
配置,建立目录
cp%20php.ini-production%20/usr/local/php/lib/php.inicp%20/usr/local/php/etc/php-fpm.conf.default%20/usr/local/php/etc/php-fpm.confln%20-s%20/usr/local/php/sbin/php-fpm%20/usr/local/bin
cd%20/usr/local/php/etc/php-fpm.dvim%20www.conf

输入

[www]listen%20=%20127.0.0.1:9080%20listen.mode%20=%200666%20user%20=%20www%20#php代码目录权限%20需要跟这个一致,group%20=%20www%20#php代码目录权限%20需要跟这个一致pm%20=%20dynamicpm.max_children%20=%20128pm.start_servers%20=%2020pm.min_spare_servers%20=%205pm.max_spare_servers%20=%2035pm.max_requests%20=%2010000rlimit_files%20=%201024slowlog%20=%20log/$pool.log.slow
加入%20systemtl%20服务
cd%20/home/flame/software/php-7.3.0/sapi/fpmcp%20php-fpm.service%20/usr/lib/systemd/system/
启动
systemctl%20start%20php-fpm
#查看状态systemctl%20status%20php-fpm#得到输出●%20php-fpm.service%20-%20The%20PHP%20FastCGI%20Process%20Manager%20Loaded:%20loaded%20(/usr/lib/systemd/system/php-fpm.service;%20disabled;%20vendor%20preset:%20disabled)%20Active:%20active%20(running)%20since%20Thu%202018-12-27%2016:13:16%20CST;%202s%20ago%20Main%20PID:%2016835%20(php-fpm)%20CGroup:%20/system.slice/php-fpm.service%20├─16835%20php-fpm:%20master%20process%20(/usr/local/php/etc/php-fpm.conf)%20├─16836%20php-fpm:%20pool%20www%20├─16837%20php-fpm:%20pool%20www%20├─16838%20php-fpm:%20pool%20www%20├─16839%20php-fpm:%20pool%20www%20├─16840%20php-fpm:%20pool%20www%20├─16841%20php-fpm:%20pool%20www%20├─16842%20php-fpm:%20pool%20www%20├─16843%20php-fpm:%20pool%20www%20├─16844%20php-fpm:%20pool%20www%20├─16845%20php-fpm:%20pool%20www%20├─16846%20php-fpm:%20pool%20www%20├─16847%20php-fpm:%20pool%20www%20├─16848%20php-fpm:%20pool%20www%20├─16849%20php-fpm:%20pool%20www%20├─16850%20php-fpm:%20pool%20www%20├─16851%20php-fpm:%20pool%20www%20├─16852%20php-fpm:%20pool%20www%20├─16853%20php-fpm:%20pool%20www%20├─16854%20php-fpm:%20pool%20www%20└─16855%20php-fpm:%20pool%20wwwDec%2027%2016:13:16%20iZj6cas4fyg41lxhngh1z0Z%20systemd[1]:%20Started%20The%20PHP%20FastCGI%20Process%20Manager.
测试
mkdir%20-p%20/home/www/webroot/phpcd%20/home/www/webroot/phpvim%20test.php

输入

%20?phpphpinfo();?%20

访问
xxx.xxx.xxx.xxx:8080/test.php

php%20命令环境

在$HOME/.profile里新增内容为

export%20PATH=$PATH:/usr/local/php/bin

%20



举报





你可能感兴趣的





评论%20

默认排序%20时间排序



载入中...

显示更多评论


以上就是阿里云centos7.6安装php7.3的详细教程的详细内容,PHP教程

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表