所有操作需要在root用户下
本机测试案例系统信息:ubuntu
安装路径:/usr/local/php8
解压缩:
wget https://downloads.php.net/~pollita/php-8.0.0alpha1.tar.gz
tar -zxvf php-8.0.0alpha1.tar.gz
cd php-8.0.0alpha1/
编译:
./configure --prefix=/usr/local/php8 --with-config-file-path=/usr/local/php8 --enable-mbstring --enable-ftp --enable-gd --enable-gd-jis-conv --enable-mysqlnd --enable-pdo --enable-sockets --enable-fpm --enable-xml --enable-soap --enable-pcntl --enable-cli --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pear --with-zlib --with-iconv --with-curl
make && make install
有依赖错误的,需要搜索解决一下
复制配置文件:
cp php.ini-production /usr/local/php8/php.ini
打开错误:
vim /usr/local/php8/php.ini
display_errors = On
复制fpm的启动脚本:
cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm8.0
增加执行权限
chmod +x /etc/init.d/php-fpm8.0
修改php-fpm配置文件:
cd /usr/local/php8/etc
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
去掉 pid = run/php-fpm.pid 前面的分号
修改启动用户:
user = www-data
group = www-data
修改监听端口:
listen = 127.0.0.1:9080
配置nginx:
server { listen 80; server_name test.sopans.com; access_log /var/log/nginx/test.sopans.com.access.log main; root /var/www/html/test; index index.html index.htm index.php; location ~ \.php { fastcgi_pass 127.0.0.1:9080; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # fastcgi_split_path_info ^(.+\.php)(/.*)$; # fastcgi_param PATH_INFO $fastcgi_path_info; include fastcgi_params; } }
启动fpm
/etc/init.d/php-fpm8.0 start
访问: