centos7 安装 php8
添加依赖
1 |
yum -y install libxml2-devel sqlite-devel bzip2-devel libcurl-devel libpng-devel libjpeg-devel freetype-devel libicu-devel oniguruma-devel libxslt-devel |
编译安装libzip-devel依赖包
1 2 3 4 5 6 7 8 |
wget https://nih.at/libzip/libzip-1.2.0.tar.gz tar xf libzip-1.2.0.tar.gz cd libzip-1.2.0 ./configure make&&make install vim /etc/profile.d/libzip.sh export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH source /etc/profile |
编译php
1 2 3 4 |
wget https://www.php.net/distributions/php-8.1.7.tar.gz tar -zxvf php-8.1.7.tar.gz ./configure --enable-xml --enable-fpm --enable-pdo --enable-bcmath --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --with-openssl --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --prefix=/usr/local/php-8 make && make install |
其他配置
1 |
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --with-mcrypt --with-libmbfl --enable-ftp --with-gd --enable-gd-jis-conv --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-pear --enable-maintainer-zts --with-ldap=shared --without-gdbm |
给php服务,服务名称是fpm创建服务配置文件
1 2 |
cd /usr/local/php-8/etc cp php-fpm.conf.default php-fpm.conf |
开启 php-fpm
1 2 3 4 5 6 7 |
vim /usr/local/php-8/etc/php-fpm.conf #找到如下内容: #;pid = run/php-fpm.pid #去除;分号修改为: pid = run/php-fpm.pid # 最后一行 include=/usr/local/php-8/etc/php-fpm.d/*.conf |
生成www.conf配置文件
1 2 |
cd /usr/local/php-8/etc/php-fpm.d cp www.conf.default www.conf |
1 |
/usr/local/php-8/sbin/php-fpm |
php 默认9000 端口
1 |
netstat -tunpl | grep 9000 |
php 修改时区
1 2 3 4 5 6 |
vi /usr/local/php-8/etc/php.ini 找到如下内容: ;date.timezone =PRC 去除;分号修改为: date.timezone =PRC :wq保存退出 |
1 2 3 4 5 6 7 8 9 |
vim /etc/profile export PATH=/usr/local/php-8/sbin:$PATH export PATH=/usr/local/nginx/sbin:$PATH :wq保存退出 #使得环境变量立即生效 source /etc/profile # 查看 设置的环境变量 echo $PATH /usr/local/nginx/sbin:/usr/local/php-8.0.6/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin |