资讯专栏INFORMATION COLUMN

阿里云 centos7.6 安装 php7.3

mylxsw / 3302人阅读

摘要:添加搜索路径到配置文件然后更新配置安装报错成功输出配置,建立目录输入代码目录权限需要跟这个一致,代码目录权限需要跟这个一致加入服务启动查看状态得到输出测试输入访问命令环境在里新增内容为

新增用户 用户组

</>复制代码

  1. groupadd www
  2. useradd -g www www
下载 php

</>复制代码

  1. wget "https://downloads.php.net/~cmb/php-7.3.0.tar.gz"
  2. tar xzvf php-7.3.0.tar.gz
  3. cd php-7.3.0
编译

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

</>复制代码

  1. ./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.

</>复制代码

  1. yum install -y libxml2-devel

configure: error: Please reinstall the BZip2 distribution

</>复制代码

  1. yum install -y bzip2-devel

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

</>复制代码

  1. yum install -y curl-devel

configure: error: jpeglib.h not found.

</>复制代码

  1. yum install -y libjpeg-devel

configure: error: png.h not found.

</>复制代码

  1. yum install -y libpng-devel

configure: error: freetype-config not found.

</>复制代码

  1. yum install -y freetype-devel

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

</>复制代码

  1. yum install -y libxslt-devel

configure: error: Please reinstall the libzip distribution

</>复制代码

  1. yum install -y libzip-devel

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

</>复制代码

  1. #先删除旧版本
  2. yum remove -y libzip
  3. #下载编译安装
  4. wget https://nih.at/libzip/libzip-1.2.0.tar.gz
  5. tar -zxvf libzip-1.2.0.tar.gz
  6. cd libzip-1.2.0
  7. ./configure
  8. make && make install

off_t undefined 报错

</>复制代码

  1. checking libzip... yes
  2. checking for the location of zlib... /usr
  3. checking for pkg-config... (cached) /usr/bin/pkg-config
  4. checking for libzip... in default path: found in /usr/local
  5. checking for zip_open in -lzip... yes
  6. checking for zip_file_set_encryption in -lzip... yes
  7. checking for zip_libzip_version in -lzip... no
  8. checking stdbool.h usability... yes
  9. checking stdbool.h presence... yes
  10. checking for stdbool.h... yes
  11. checking fts.h usability... yes
  12. checking fts.h presence... yes
  13. checking for fts.h... yes
  14. checking for int8_t... (cached) yes
  15. checking for int16_t... (cached) yes
  16. checking for int32_t... (cached) yes
  17. checking for int64_t... (cached) yes
  18. checking for uint8_t... (cached) yes
  19. checking for uint16_t... (cached) yes
  20. checking for uint32_t... (cached) yes
  21. checking for uint64_t... (cached) yes
  22. checking for ssize_t... yes
  23. checking size of short... (cached) 2
  24. checking size of int... (cached) 4
  25. checking size of long... (cached) 8
  26. checking size of long long... (cached) 8
  27. checking size of off_t... 0
  28. 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位的库文件路径加进去。

</>复制代码

  1. #添加搜索路径到配置文件
  2. echo "/usr/local/lib64
  3. /usr/local/lib
  4. /usr/lib
  5. /usr/lib64">>/etc/ld.so.conf
  6. #然后 更新配置
  7. ldconfig -v
安装

</>复制代码

  1. make && make install

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

</>复制代码

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

成功输出

</>复制代码

  1. Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/
  2. Installing PHP CLI binary: /usr/local/php/bin/
  3. Installing PHP CLI man page: /usr/local/php/php/man/man1/
  4. Installing PHP FPM binary: /usr/local/php/sbin/
  5. Installing PHP FPM defconfig: /usr/local/php/etc/
  6. Installing PHP FPM man page: /usr/local/php/php/man/man8/
  7. Installing PHP FPM status page: /usr/local/php/php/php/fpm/
  8. Installing phpdbg binary: /usr/local/php/bin/
  9. Installing phpdbg man page: /usr/local/php/php/man/man1/
  10. Installing PHP CGI binary: /usr/local/php/bin/
  11. Installing PHP CGI man page: /usr/local/php/php/man/man1/
  12. Installing build environment: /usr/local/php/lib/php/build/
  13. Installing header files: /usr/local/php/include/php/
  14. Installing helper programs: /usr/local/php/bin/
  15. program: phpize
  16. program: php-config
  17. Installing man pages: /usr/local/php/php/man/man1/
  18. page: phpize.1
  19. page: php-config.1
  20. Installing PEAR environment: /usr/local/php/lib/php/
  21. 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
  22. [PEAR] Archive_Tar - installed: 1.4.3
  23. [PEAR] Console_Getopt - installed: 1.4.1
  24. [PEAR] Structures_Graph- installed: 1.1.1
  25. [PEAR] XML_Util - installed: 1.4.2
  26. [PEAR] PEAR - installed: 1.10.5
  27. Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
  28. You may want to add: /usr/local/php/lib/php to your php.ini include_path
  29. /home/flame/software/php-7.3.0/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
  30. ln -s -f phar.phar /usr/local/php/bin/phar
  31. Installing PDO headers: /usr/local/php/include/php/ext/pdo/
配置,建立目录

</>复制代码

  1. cp php.ini-production /usr/local/php/lib/php.ini
  2. cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
  3. ln -s /usr/local/php/sbin/php-fpm /usr/local/bin

</>复制代码

  1. cd /usr/local/php/etc/php-fpm.d
  2. vim www.conf

输入

</>复制代码

  1. [www]
  2. listen = 127.0.0.1:9080
  3. listen.mode = 0666
  4. user = www #php代码目录权限 需要跟这个一致,
  5. group = www #php代码目录权限 需要跟这个一致
  6. pm = dynamic
  7. pm.max_children = 128
  8. pm.start_servers = 20
  9. pm.min_spare_servers = 5
  10. pm.max_spare_servers = 35
  11. pm.max_requests = 10000
  12. rlimit_files = 1024
  13. slowlog = log/$pool.log.slow
加入 systemtl 服务

</>复制代码

  1. cd /home/flame/software/php-7.3.0/sapi/fpm
  2. cp php-fpm.service /usr/lib/systemd/system/
启动

</>复制代码

  1. systemctl start php-fpm

</>复制代码

  1. #查看状态
  2. systemctl status php-fpm
  3. #得到输出
  4. php-fpm.service - The PHP FastCGI Process Manager
  5. Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
  6. Active: active (running) since Thu 2018-12-27 16:13:16 CST; 2s ago
  7. Main PID: 16835 (php-fpm)
  8. CGroup: /system.slice/php-fpm.service
  9. ├─16835 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
  10. ├─16836 php-fpm: pool www
  11. ├─16837 php-fpm: pool www
  12. ├─16838 php-fpm: pool www
  13. ├─16839 php-fpm: pool www
  14. ├─16840 php-fpm: pool www
  15. ├─16841 php-fpm: pool www
  16. ├─16842 php-fpm: pool www
  17. ├─16843 php-fpm: pool www
  18. ├─16844 php-fpm: pool www
  19. ├─16845 php-fpm: pool www
  20. ├─16846 php-fpm: pool www
  21. ├─16847 php-fpm: pool www
  22. ├─16848 php-fpm: pool www
  23. ├─16849 php-fpm: pool www
  24. ├─16850 php-fpm: pool www
  25. ├─16851 php-fpm: pool www
  26. ├─16852 php-fpm: pool www
  27. ├─16853 php-fpm: pool www
  28. ├─16854 php-fpm: pool www
  29. └─16855 php-fpm: pool www
  30. Dec 27 16:13:16 iZj6cas4fyg41lxhngh1z0Z systemd[1]: Started The PHP FastCGI Process Manager.
测试

</>复制代码

  1. mkdir -p /home/www/webroot/php
  2. cd /home/www/webroot/php
  3. vim test.php

输入

</>复制代码

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

php 命令环境

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

</>复制代码

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

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/29860.html

相关文章

发表评论

0条评论

mylxsw

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<