Install by Compiling
Compiling Needs Memory Space!
If the memory space of your device is Lower than 2GB, you had better Create a Swap.
Prepare
Prepare for the Environment
dnf groupinstall "Development Tools"
dnf install libxml2-devel libicu-devel sqlite-devel libxslt-devel libpng-devel libjpeg-devel freetype-devel libzip-devel git systemd-devel curl-devel
Download & Install Oniguruma
cd oniguruma ./autogen.sh ./configure --bindir=/usr/sbin/ \ --sbindir=/usr/sbin/ \ --libexecdir=/usr/libexec \ --sysconfdir=/etc/ \ --localstatedir=/var \ --libdir=/usr/lib64/ \ --includedir=/usr/include/ \ --datarootdir=/usr/share \ --infodir=/usr/share/info \ --localedir=/usr/share/locale \ --mandir=/usr/share/man/ \ --docdir=/usr/share/doc/onig make & make install
Add user for FPM
adduser www
Pre-Compile
Here are the recommanded options(FPM included):
cd php-8.1.2
# Replace UR_WEB_USER into your user for php-fpm ./configure --prefix=/usr/local/php/ --enable-fpm --with-openssl --enable-bcmath --with-curl --enable-ftp --enable-gd --enable-mbstring --enable-sockets --enable-pcntl --with-zlib --enable-intl --with-fpm-systemd --enable-pdo --enable-xml --with-zip --with-gettext --with-freetype --enable-opcache --enable-shmop --with-fpm-user=UR_WEB_USER --with-fpm-group=UR_WEB_USER
These MySQL options is optional. The Directories and Configs depend on your env. (MySQL here installed by DNF)
--enable-mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli --with-mysql-sock=/var/lib/mysql/mysql.sock
Compile & Install
make && make install
Finish Config
Copy Config File to the Install Directory
cp PATH_TO_THE_SRC/php.ini-production /usr/local/php/php.ini cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
Add Php to systemd as a service(Recommanded, make it ez to manage) About the usage of systemd,Check systemd#BasicUsage
Edit PID Location
# Open the File vim /usr/local/php/etc/php-fpm.conf # Find the part and Change into pid = /var/run/php-fpm.pid
Write the systemd script
# Create one and edit vim /lib/systemd/system/php-fpm.service
Then, add the content.
[Unit] Description=The PHP FastCGI Process Manager After=syslog.target network.target [Service] Type=forking PIDFile=/var/run/php-fpm.pid ExecStart=/usr/local/php/sbin/php-fpm ExecReload=/bin/kill -USR2 $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
Reload systemd
systemctl daemon-reload
Enjoy it!
Last updated
Was this helpful?