php7 devel_PHP7 编译安装

准备工作

安装gcc和make##安装make,已安装,可省略

$ yum -y install gcc automake autoconf libtool make

##安装gcc g++ glibc库

$ yum -y install gcc gcc-c++ glibc

##安装所需的包

$ yum -y install libmcrypt-devel mhash-devel libxslt-devel

libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel

zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel

ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel

krb5 krb5-devel libidn libidn-devel openssl openssl-devel readline-devel gmp-devel

以上安装可分批或者单个进行,如yum -y install libmcrypt-devel,一般来说均可安装成功,如果失败可多试几次。# 添加搜索路径到配置文件

echo '/usr/local/lib64

/usr/local/lib

/usr/lib

/usr/lib64'>>/etc/ld.so.conf

# 更新配置

ldconfig -v

PHP下载$ wget https://www.php.net/distributions/php-7.4.5.tar.gz

$ tar -xzvf php-7.4.5.tar.gz #解压

$ cd php-7.4.5 #cd

$ ./configure #php configure

Configure参数

config参数根据个人需要而确定--prefix=/usr/local/php --with-config-file-path=/etc --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-xmlrpc --with-openssl --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache

7.3./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-xmlrpc --with-openssl --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache

安装$ make && make install #make

安装位置

--prefix=/usr/local/php

配置文件存储路径:

--with-config-file-path=/etc

也即 php.ini 位置,默认为 /etc

fpm用户&用户组配置

--enable-fpm --with-fpm-user=www --with-fpm-group=www

编完了别忘了make test

虽然经常会报一大堆warning,但是如果有严重error的还是可以发现的。

编译安装完成后配置文件

复制到with-config-file-path 指定的目录中,可使用 phpinfo 或者 php -i 查看相应位置。##php.ini,编译配置时配在php7/etc目录下

$cp php-7.2.2/php.ini-development ../etc/php.ini

##php-fpm.conf

$cp ../etc/php-fpm.conf.default ../etc/php-fpm.conf

##www.conf

$cp ../etc/php-fpm.d/www.conf.default ../etc/php-fpm.d/www.conf

修改配置php.ini

原cgi.force_redirect = 1被注释,需要放开且修改为cgi.force_redirect = 0

使用composer时还需要开放 disable_functions=的proc_open和proc_get_status

php-fpm.conf

修改错误日志路径error_log = log/php-fpm.log

www.conf

修改用户和用户组选项user = nginx、group = nginx

设置php全局环境变量

/etc/profile 全局环境变量$vim /etc/profile

##加上下面这句话

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

$source /etc/profile

$php -v

PHP 7.3.14 (cli) (built: Feb 15 2020 00:22:13) ( NTS )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.3.14, Copyright (c) 1998-2018 Zend Technologies

启动phpnginx 8000 1.7 0.4 236976 32380 ? S Apr27 4:14 php-fpm: pool www

root 8001 0.0 0.0 140016 6884 ? Ss Mar21 2:24 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)

nginx 12606 1.5 0.4 239268 33656 ? S Apr27 2:45 php-fpm: pool www

nginx 14299 1.5 0.4 160968 32368 ? S Apr27 2:18 php-fpm: pool www

安装composercd /usr/local/php #先进入php目录

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

php composer-setup.php

php -r "unlink('composer-setup.php');"

在目录内会生成composer.phar,移动到/usr/local/bin或者/usr/bin or /usr/sbin让他全局生效。

注意:指定的with-fpm-user的用户对网站目录必须有读写权限;最好chown设定下,让权限都保持统一

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值