PHP部分
官网下载地址:https://www.php.net/downloads.php
我下载的是此时的最新稳定版8.2.3
cd /usr/local
wget https://www.php.net/distributions/php-8.2.3.tar.gz
解压
tar -zxvf php-8.2.3.tar.gz
安装一些必要依赖
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel curl curl-devel openssl openssl-devel
yum -y install gcc gcc-c++ libxslt-devel* mod_ssl libtool-ltdl* sqlite-devel oniguruma-devel perl* libzip autoconf
进去
cd /usr/local/php-8.2.3/
配置
./configure --prefix=/usr/local/php8 --with-curl --with-freetype --enable-gd --with-gettext --with-kerberos --with-libdir=lib64 --with-mysqli --with-openssl --with-external-pcre --with-jpeg --with-pdo-mysql --with-pear --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --with-zip --enable-pcntl --enable-ftp --enable-session --enable-xml --without-pear --disable-phar
如果遇到这个错:
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:
就停下来 看这篇文章 https://blog.csdn.net/tootsy_you/article/details/123132164
把问题解决掉 解决完了再重新执行上面的配置命令
编译
make
安装
make install
添加环境变量
vim /etc/profile
在最后一行下面加入
PATH=$PATH:/usr/local/php8/bin export PATH
立即生效
source /etc/profile
查看PHP版本
php -v
生成必要文件
cp /usr/local/php-8.2.3/php.ini-production /usr/local/php8/etc/php.ini cp /usr/local/php-8.2.3/sapi/fpm/php-fpm /usr/local/php8/etc/php-fpm cp /usr/local/php8/etc/php-fpm.conf.default /usr/local/php8/etc/php-fpm.conf cp /usr/local/php8/etc/php-fpm.d/www.conf.default /usr/local/php8/etc/php-fpm.d/www.conf
编辑php.ini
vim /usr/local/php8/etc/php.ini
以下参数仅供参考
date.timezone = PRC //设置时区 file_uploads = On //是否允许上传 upload_tmp_dir = /tmp //上传临时目录 max_file_uploads = 20 //单个请求最多上传数量 upload_max_filesize = 10M //允许上传文件大小 post_max_size = 20M //允许post传输最大值(这个必须比upload_max_filezise大) memory_limit = 128M //设置脚本最大使用内存 error_reporting=E_ALL //输出错误信息 error_log = /var/log/php.log //错误日志路径
创建日志文件
touch /var/log/php.log chmod 755 /var/log/php.log
启动php-fpm,载入php.ini
/usr/local/php8/sbin/php-fpm -c /usr/local/php8/etc/php.ini
注意 如果修改了php.ini则每次需要杀掉php-fpm进程再重新启动php-fpm,PHP的解析执行靠的是这家伙,不靠nginx。
ps -ef | grep php-fpm kill -9 上一条命令查到的PID
nginx部分
nginx的安装:https://www.cnblogs.com/fengyumeng/p/17163412.html
打开配置文件
vim /usr/local/nginx/conf/nginx.conf
每一段都是包在server{}之中 如要配置多个域名 则复制粘贴多个server{}代码块
其中server_name为域名,root为php代码所在目录 。 替换这两个即可
server { listen 80; server_name www.abc.com abc.com; root /var/www/abc; location / { if (!-e $request_filename) { rewrite ^/index.php(.*)$ /index.php?s=$1 last; rewrite ^(.*)$ /index.php?s=$1 last; } index index.html index.htm index.php; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
保存退出
重启nginx
systemctl restart nginx
标签:enable,--,fpm,PHP8,usr,Linux,新版,php,local From: https://www.cnblogs.com/fengyumeng/p/17164154.html