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

  1. 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
  2. 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
  3. Add user for FPM

    adduser www
  4. wget https://www.php.net/distributions/php-8.1.2.tar.gz
    tar -xzf ./php-8.2.5.tar.gz
  5. 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
  6. Compile & Install

    make && make install
  7. 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

    1. 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
    1. Write the systemd script

    # Create one and edit
    vim /lib/systemd/system/php-fpm.service
    1. 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
    1. Reload systemd

    systemctl daemon-reload
  8. Enjoy it!

Last updated