Centos8编译安装php8

yum -y install epel-release
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y --enablerepo=remi install libzip-last-devel                                                                                                                                                               
yum -y install gcc vim-enhanced gcc-c++ libtool-libs libtool autoconf subversion zip unzip  wget crontabs iptables file bison patch mlocate flex diffutils automake imake make cmake kernel-devel cpp zlib-devel \
libevent-devel libxml2-devel freetype-devel  gd gd-devel libjpeg-devel libpng-devel ncurses-devel  \
curl-devel readline-devel openssl-devel  glibc-devel  glib2-devel bzip2-devel e2fsprogs-devel libidn-devel  gettext-devel expat-devel libcap-devel  libtool-ltdl-devel pam-devel \
libxslt-devel libc-client-devel freetds-devel unixODBC-devel  libXpm-devel krb5-devel libicu-devel icu sqlite-devel libsodium-devel oniguruma-devel

 

wget https://www.php.net/distributions/php-8.0.11.tar.gz -O - | tar xz
cd  php-8.*
prefix="/opt/php8";
# --with-zip  
 ./configure --quiet --prefix=$prefix/usr --with-config-file-path=$prefix/etc --sysconfdir=$prefix/etc --sbindir=$prefix/sbin --bindir=$prefix/bin --localstatedir=$prefix/var --enable-fpm --enable-bcmath --enable-exif --enable-ftp --enable-mbstring --enable-soap --enable-sockets  --with-curl --with-gettext --with-openssl  --with-mhash  --with-mysql-sock=/var/lib/mysql/mysql.sock --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-imap --with-imap-ssl --with-kerberos --with-zlib --enable-intl=shared --enable-xml --disable-rpath --enable-shmop --enable-sysvsem --enable-mbregex  --enable-pcntl --enable-opcache --enable-exif  --with-sqlite3 --with-pdo-sqlite --enable-calendar --with-freetype --with-jpeg --enable-gd --with-sodium --with-zip --with-libdir=lib64 ;
make -j `grep name /proc/cpuinfo|wc -l`
make install
sed -i 's#expose_php = On#expose_php = Off#'  				php.ini-production
sed -i 's#;date.timezone =#date.timezone=Asia/Shanghai#g'  		php.ini-production
sed -i 's#;cgi.fix_pathinfo=1#cgi.fix_pathinfo=0#g' 			php.ini-production
sed -i 's#enable_dl = Off#enable_dl = On#' 				php.ini-production
sed -i 's#register_argc_argv = Off#register_argc_argv = On#'            php.ini-production
sed -i 's#short_open_tag = Off#short_open_tag = On#'  			php.ini-production
sed -i 's#output_buffering = Off#output_buffering = On#'  		php.ini-production
sed -i 's/memory_limit = 32M/memory_limit = 128M/g' 			php.ini-production
sed -i 's/post_max_size = 8M/post_max_size = 32M/g' 			php.ini-production
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 128M/g' 	php.ini-production
sed -i 's#allow_call_time_pass_reference = Off#allow_call_time_pass_reference = On#' 	php.ini-production
sed -i 's/disable_functions =/disable_functions="passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen"/g' php.ini-production

mkdir -p $prefix/etc/php-fpm.d
ln -s $prefix/bin/ph* /usr/bin/
ln -s $prefix/sbin/ph* /usr/sbin/
#cp ./sapi/fpm/php-fpm /etc/init.d/php-fpm      #弃用init.d
install -p -D -m 0644 sapi/fpm/php-fpm.service /usr/lib/systemd/system/
install -p -D -m 0644 php.ini-production  $prefix/etc/php.ini

#Set fpm.conf
cat>$prefix/etc/php-fpm.conf<<EOF
[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = warning
emergency_restart_threshold = 30
emergency_restart_interval = 60s
process_control_timeout = 5s
daemonize = yes
include=$prefix/etc/php-fpm.d/*.conf
EOF
cat>$prefix/etc/php-fpm.d/default.conf<<EOF
[default]
;listen=127.0.0.1:9006
listen=/dev/shm/php-fpm.sock
listen.mode=0666
user=nobody
group=nobody
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=51200
slowlog=log/\$pool.log.slow
env[PATH] = /usr/local/bin:/usr/bin:/bin:$prefix/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
EOF

systemctl enable php-fpm
systemctl start php-fpm




centos8执行yum报错 unable to detect release version (use '--releasever' to specify release version)

解决办法

 yum install --releasever=8  centos-linux-release

阅读剩余部分...