登录  /  注册

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

不言
发布: 2019-01-01 10:02:22
转载
26865人浏览过

本篇文章给大家带来的内容是关于阿里云centos7.6安装php7.3的详细教程,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

新增用户 用户组

groupadd www
useradd -g www www
登录后复制
登录后复制

下载 php

wget "https://downloads.php.net/~cmb/php-7.3.0.tar.gz"
tar xzvf php-7.3.0.tar.gz
cd  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.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make && make install
登录后复制
登录后复制

off_t undefined 报错

checking libzip... yes
checking for the location of zlib... /usr
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for libzip... in default path: found in /usr/local
checking for zip_open in -lzip... yes
checking for zip_file_set_encryption in -lzip... yes
checking for zip_libzip_version in -lzip... no
checking stdbool.h usability... yes
checking stdbool.h presence... yes
checking for stdbool.h... yes
checking fts.h usability... yes
checking fts.h presence... yes
checking for fts.h... yes
checking for int8_t... (cached) yes
checking for int16_t... (cached) yes
checking for int32_t... (cached) yes
checking for int64_t... (cached) yes
checking for uint8_t... (cached) yes
checking for uint16_t... (cached) yes
checking for uint32_t... (cached) yes
checking for uint64_t... (cached) yes
checking for ssize_t... yes
checking size of short... (cached) 2
checking size of int... (cached) 4
checking size of long... (cached) 8
checking size of long long... (cached) 8
checking size of off_t... 0
configure: 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-config
Installing man pages:             /usr/local/php/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing 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.5
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You 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/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:           /usr/local/php/include/php/ext/pdo/
登录后复制
登录后复制

配置,建立目录

cp php.ini-production /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
ln -s /usr/local/php/sbin/php-fpm /usr/local/bin
登录后复制
登录后复制
cd /usr/local/php/etc/php-fpm.d
vim www.conf
登录后复制
登录后复制

输入

[www]
listen = 127.0.0.1:9080   
listen.mode = 0666      

user = www  #php代码目录权限 需要跟这个一致,
group = www #php代码目录权限 需要跟这个一致

pm = dynamic
pm.max_children = 128
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 10000

rlimit_files = 1024

slowlog = log/$pool.log.slow
登录后复制
登录后复制

加入 systemtl 服务

cd /home/flame/software/php-7.3.0/sapi/fpm
cp 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 www

Dec 27 16:13:16 iZj6cas4fyg41lxhngh1z0Z systemd[1]: Started The PHP FastCGI Process Manager.
登录后复制
登录后复制

测试

mkdir -p /home/www/webroot/php
cd /home/www/webroot/php
vim test.php
登录后复制
登录后复制

输入

<?php phpinfo();

?>
登录后复制
登录后复制

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

php 命令环境

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

export PATH=$PATH:/usr/local/php/bin
登录后复制
登录后复制

                                               







                                                   1 天前发布                                                                                            

阿里云 centos7.6 安装 php7.3

  • php

  • centos

  • linux

                                               43 次阅读                                                 ·                                                 读完需要 26 分钟                                                                                                                    



                           2                        

                                                                                                                                           


新增用户 用户组

groupadd www
useradd -g www www
登录后复制
登录后复制

下载 php

wget "https://downloads.php.net/~cmb/php-7.3.0.tar.gz"
tar xzvf php-7.3.0.tar.gz
cd  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.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make &amp;&amp; make install
登录后复制
登录后复制

off_t undefined 报错

checking libzip... yes
checking for the location of zlib... /usr
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for libzip... in default path: found in /usr/local
checking for zip_open in -lzip... yes
checking for zip_file_set_encryption in -lzip... yes
checking for zip_libzip_version in -lzip... no
checking stdbool.h usability... yes
checking stdbool.h presence... yes
checking for stdbool.h... yes
checking fts.h usability... yes
checking fts.h presence... yes
checking for fts.h... yes
checking for int8_t... (cached) yes
checking for int16_t... (cached) yes
checking for int32_t... (cached) yes
checking for int64_t... (cached) yes
checking for uint8_t... (cached) yes
checking for uint16_t... (cached) yes
checking for uint32_t... (cached) yes
checking for uint64_t... (cached) yes
checking for ssize_t... yes
checking size of short... (cached) 2
checking size of int... (cached) 4
checking size of long... (cached) 8
checking size of long long... (cached) 8
checking size of off_t... 0
configure: 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'&gt;&gt;/etc/ld.so.conf

#然后 更新配置
ldconfig -v
登录后复制
登录后复制

安装

make &amp;&amp; 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-config
Installing man pages:             /usr/local/php/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing 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.5
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You 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/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:           /usr/local/php/include/php/ext/pdo/
登录后复制
登录后复制

配置,建立目录

cp php.ini-production /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
ln -s /usr/local/php/sbin/php-fpm /usr/local/bin
登录后复制
登录后复制
cd /usr/local/php/etc/php-fpm.d
vim www.conf
登录后复制
登录后复制

输入

[www]
listen = 127.0.0.1:9080   
listen.mode = 0666      

user = www  #php代码目录权限 需要跟这个一致,
group = www #php代码目录权限 需要跟这个一致

pm = dynamic
pm.max_children = 128
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 10000

rlimit_files = 1024

slowlog = log/$pool.log.slow
登录后复制
登录后复制

加入 systemtl 服务

cd /home/flame/software/php-7.3.0/sapi/fpm
cp 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 www

Dec 27 16:13:16 iZj6cas4fyg41lxhngh1z0Z systemd[1]: Started The PHP FastCGI Process Manager.
登录后复制
登录后复制

测试

mkdir -p /home/www/webroot/php
cd /home/www/webroot/php
vim test.php
登录后复制
登录后复制

输入

<?php phpinfo();

?>
登录后复制
登录后复制

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

php 命令环境

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

export PATH=$PATH:/usr/local/php/bin
登录后复制
登录后复制

               


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




你可能感兴趣的



评论                                                    

默认排序                        时间排序



载入中...

显示更多评论



以上就是阿里云centos7.6安装php7.3的详细教程的详细内容,更多请关注php中文网其它相关文章!

智能AI问答
PHP中文网智能助手能迅速回答你的编程问题,提供实时的代码和解决方案,帮助你解决各种难题。不仅如此,它还能提供编程资源和学习指导,帮助你快速提升编程技能。无论你是初学者还是专业人士,AI智能助手都能成为你的可靠助手,助力你在编程领域取得更大的成就。
来源:segmentfault.网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号