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

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

本篇文章给大家带来的内容是关于阿里云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 libpng-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


#先删除旧版本
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


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


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


目录
打赏
0
0
0
0
19
分享
相关文章
CentOS 7系统下详细安装MySQL 5.7的步骤:包括密码配置、字符集配置、远程连接配置
以上就是在CentOS 7系统下安装MySQL 5.7的详细步骤。希望这个指南能帮助你顺利完成安装。
134 26
CentOS 7.8下使用kubeadm安装Kubernetes 1.26
这就是所有的前线报告,冒险家们,你们已经做好准备,开始在CentOS 7.8上通过Kubeadm安装Kubernetes 1.26的挑战了吗?走上这段旅程,让你的代码飞翔吧。
57 16
在Linux(CentOS和AWS)上安装更新的git2的方法并配置github-ssh
经过以上这些步骤,你现在就能在GitHub上顺利往返,如同海洋中的航海者自由驰骋。欢迎你加入码农的世界,享受这编程的乐趣吧!
48 10
VMware隐藏黑科技!CentOS安装这个神器效率翻倍 文件互传竟比U盘还快?
### 安装VMtools的作用及步骤 安装VMtools可以实现Windows与CentOS之间的字符串和命令粘贴、文件夹共享等操作。在CentOS中,通过VMware菜单栏选择“VMware Tools”,将下载的压缩包拷贝到`/opt`目录并解压。接着进入终端,使用`./vmware-install.pl`命令完成安装。安装后重启系统,即可实现Windows与CentOS之间的字符和文件共享。具体步骤包括解压文件、启动命令行终端、安装VMtools以及配置文件共享。
95 16
VMware隐藏黑科技!CentOS安装这个神器效率翻倍 文件互传竟比U盘还快?
在CentOS 7.9中安装sshpass教程
如果在控制台显示出sshpass的使用方法,那就说明我们的大餐已经准备好,sshpass已经成功安装。 以上就是在 CentOS 7.9 中安装 sshpass 的彩色步骤,专业而生动,就像大厨在厨房一样顺利。
54 8
|
19天前
|
利用PHP压缩音频:Linux环境下的ffmpeg简易安装指南
希望这个指南能为你的编程之旅提供帮助。只需记住,每一行代码都像音乐的音符,组合在一起,创造出美妙的旋律。祝你编程愉快!
66 6
零基础保姆级教程!手把手教你免费玩转Linux CentOS安装+学习环境搭建(附避坑指南)
本文详细介绍了在VMware虚拟机中安装CentOS 6.8的全过程。首先,需确保已安装VMware并开启V-CPU虚拟化功能,可通过BIOS设置或使用LeoMoon CPU-V工具检测。接着,下载CentOS镜像文件,并在VMware中新建虚拟机,配置CPU、内存、硬盘等参数。最后,加载ISO镜像启动虚拟机,按照提示完成CentOS的安装,包括语言、键盘、存储方式、地区、密码设置及硬盘分区等步骤。安装完成后,以root用户登录即可进入系统桌面,开始学习Linux命令和操作。
158 12
零基础保姆级教程!手把手教你免费玩转Linux CentOS安装+学习环境搭建(附避坑指南)
如何从CentOS7升级到8?CentOS8最新安装教程
从CentOS 7升级到8只需三步:清理系统、更换软件包及存储库、安装新内核与发布版本。首先确保系统最新并清理冗余包,接着替换基础系统包为CentOS 8版本,最后通过DNF工具完成内核更新与系统同步。整个过程需在终端执行,建议升级前备份VPS快照以防数据丢失。此方法可避免重装系统导致的数据清除问题,实现平滑升级。
114 6
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
通过本文,我们详细了解了 `yum`、`rpm`、`apt-get`和 `wget`的区别、常用命令以及在CentOS和Ubuntu中安装 `wget`的方法。`yum`和 `apt-get`是高层次的包管理器,分别用于RPM系和Debian系发行版,能够自动解决依赖问题;而 `rpm`是低层次的包管理工具,适合处理单个包;`wget`则是一个功能强大的下载工具,适用于各种下载任务。在实际使用中,根据系统类型和任务需求选择合适的工具,可以大大提高工作效率和系统管理的便利性。
256 25
|
2月前
|
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
101 20
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等