sudo apt-get install -y gcc autoconf automake libtool cmake m4 bison re2c
sudo apt-get -y install libwebp-dev libjpeg-dev libxpm-dev libzip-dev libxslt1-dev libmcrypt-dev libsqlite3-dev libcurl4-openssl-dev libssl-dev
$ git clone https://github.com/kkos/oniguruma.git
$ cd oniguruma/
# 生成 configure
$ ./autogen.sh
# 检测
$ ./configure --prefix=/usr/local
# 编译及安装
$ make && make install
```
$ wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable.tar.gz
$ tar -xf libsodium-1.0.18-stable.tar.gz
$ cd libsodium-stable/
$ ./configure --prefix=/usr/local
$ make && make install
目录
)$ mkdir -p /opt/php/7.4.27
# 设置当前用户的权限
$ sudo chown -R [用户名]:[用户组] /opt/php/7.4.27
./configure
)$ ./configure --prefix=/opt/php/7.4.27 \
--with-openssl \
--with-curl \
--enable-opcache \
--enable-fpm \
--enable-mbstring \
--enable-sockets \
--enable-ftp \
--enable-phpdbg \
--enable-debug \
--enable-shmop \
--enable-intl \
--enable-pcntl \
--enable-bcmath \
--enable-sigchild \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-inline-optimization \
--enable-calendar \
--disable-short-tags \
--without-pear \
--with-mhash \
--with-zlib \
--with-bz2 \
--enable-xml \
--enable-soap \
--with-xmlrpc \
--with-xsl \
--with-pcre-jit \
--with-zip \
--with-ffi \
--with-sodium \
--enable-gd \
--with-webp \
--with-jpeg \
--with-xpm \
--with-freetype \
--enable-exif \
--with-gettext \
--enable-mysqlnd \
--with-mysqli \
--with-pdo-mysql \
--with-pdo-sqlite \
--enable-zts
......
Generating files
configure: patching main/php_config.h.in
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/www.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating sapi/phpdbg/phpdbg.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: main/php_config.h is unchanged
config.status: executing default commands
# 如果没有设置安装目录的权限,需要加 sudo
$ make -j8 && make install
php-7.4.27$ cp php.ini-development /opt/php/7.4.27/etc/php.ini
php-7.4.27$ cd /opt/php/7.4.27/etc
etc$ cp php-fpm.conf.default php-fpm.conf
etc$ cp php-fpm.d/www.conf.default php-fpm.d/www.conf
sudo groupadd www
sudo useradd -s /sbin/nologin -g www www
php-fpm.conf
$ vim /opt/php/7.4.27/etc/php-fpm.conf
# 修改以下内容
pid = /run/php-fpm.pid
error_log = /var/log/php-fpm.log
www.conf
$ vim /opt/php/7.4.27/etc/php-fpm.d/www.conf
# 修改以下内容
user = www
group = www
listen = 127.0.0.1:9000
# 不设置,则在执行 php 命令时会出错
ln -s /opt/php/7.4.27/etc/php.ini /opt/php/7.4.27/lib/php.ini
sudo ln -s /opt/php/7.4.27/bin/php /usr/local/bin/php
sudo ln -s /opt/php/7.4.27/bin/phpize /usr/local/bin/phpize
sudo ln -s /opt/php/7.4.27/bin/php-config /usr/local/bin/php-config
$ cd /opt/php/7.4.27/sbin/
$ ./php-fpm -t
....../php/7.4.27/etc/php-fpm.conf test is successful
$ sudo vim /usr/lib/systemd/system/php-fpm.service
# 加入以下内容
[Unit]
Description=service The PHP-FPM HTTP Server
After=syslog.target network.target
[Service]
Type=forking
Restart=always
User=root
ExecStart=/opt/php/7.4.27/sbin/php-fpm -c /opt/php/7.4.27/etc/php.ini -y /opt/php/7.4.27/etc/php-fpm.conf
ExecStop=kill -SIGQUIT `cat /run/php-fpm.pid`
ExecReload=kill -SIGUSR2 `cat /run/php-fpm.pid`
[Install]
WantedBy=multi-user.target
# php-fpm 软连接
sudo ln -s /usr/lib/systemd/system/php-fpm.service /etc/systemd/system/
# 设置服务自启开机
sudo systemctl enable php-fpm.service
# 启动
sudo systemctl start php-fpm.service
sudo systemctl status php-fpm.service