Get the App
SLTechnology News&Howtos  ›  Development  › 

How to install php environment under Linux

Shulou Source: shulou.com Published: 2022-06-02 00:37:03 10月06日 Update

This article introduces you how to install php environment under Linux, the content is very detailed, interested friends can refer to, I hope to help you.

If you want to install it in one step, use the following procedure:

Step 1: Install cmake

yum install epel-release -yyum install cmake3 -ycp /usr/bin/cmake3 /usr/bin/cmake

Run cmake -version to see if the installation is successful:

#Enter cmake version 3.16.1CMake suite maintained and supported by Kitware (kitware.com/cmake).

Step 2: Install libzip 1.5.2

#install bzip2-devel dependency package yum install bzip2 bzip2-devel -y#install libzipcd ~wget https://libzip.org/download/libzip-1.5.2.tar.gztar xf libzip-1.5.2.tar.gz cd libzip-1.5.2mkdir buildcd buildcmake.. make#make testmake install

Step 3: Install php dependencies

yum install gcc \ gcc-c++ \ libxml2 \ libxml2-devel \ openssl \ openssl-devel \ libcurl \ libcurl-devel \ freetype \ freetype-devel \ libjpeg \ libjpeg-devel \ libpng \ libpng-devel \ libxslt \ libxslt-devel \ systemd-devel \ libicu-devel \ libedit-devel

Step 4: Create www users

useradd -M -s /sbin/nologin www modify library load path

vim /etc/ld.so.conf

#Add the following lines/usr/local/lib64/usr/local/lib/usr/lib/usr/lib64

To bring it into effect:

ldconfig -v

Or:

echo /usr/local/lib64 >>/etc/ld.so.conf echo /usr/local/lib >>/etc/ld.so.conf echo /usr/lib >>/etc/ld.so.conf echo /usr/lib64 >>/etc/ld.so.conf ldconfig -v

Finally, pre-configuration again.

Step 5: Download php source code and pre-configure

#install wget tool yum install wget -y#download php source code wget https://www.php.net/distributions/php-7.3.12.tar.gz#extract php tar package tar xf php-7.3.12.tar.gz#enter php decompressed directory cd php-7.3.12#pre-configuration./ configure --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --with-config-file-scan-dir=/usr/local/php/etc/conf.d \ --disable-cgi \ --enable-fpm \ --with-fpm-user=www \ --with-fpm-group=www \ --enable-ftp \ --with-curl \ --with-gd \ --with-gettext \ --with-iconv-dir \ --with-kerberos \ --with-libedit \ --with-openssl \ --with-pcre-regex \ --with-pdo-mysql \ --with-xsl \ --with-zlib \ --with-mhash \ --with-mysqli \ --with-png-dir=/usr/lib \ --with-jpeg-dir=/usr/lib\ --with-freetype-dir=/usr/lib \ --enable-mysqlnd \ --enable-bcmath \ --enable-libxml \ --enable-inline-optimization \ --enable-gd-jis-conv \ --enable-mbregex \ --enable-mbstring \ --enable-opcache \ --enable-pcntl \ --enable-shmop \ --enable-soap \ --enable-sockets \ --enable-sysvsem \ --enable-xml \ --enable-zip \ --enable-calendar \ --enable-intl \ --enable-exif

See if error appears in the final output:

If no error occurs and the following words appear, proceed to the next step

Thank you for using PHP

Step 6: Compile and install

make && make install

Step 7: Create a startup script

cp php.ini-development /usr/local/php/etc/php.ini cd /usr/local/php/etc/ cp php-fpm.conf.default php-fpm.conf

The default official provides a systemd administration script

The path is php-fpm.service under/root/php-7.3.12/sapi/fpm

#Copy a configuration file cp php-fpm.conf.default php-fpm.conf#Copy the startup script to the specified directory cp /root/php-7.3.13/sapi/fpm/php-fpm.service /usr/lib/systemd/system/systemctl daemon-reload systemctl start php-fpmsystemctl enable php-fpmsystemctl status php-fpm

At this point, the startup will prompt you that you cannot find the included configuration file:

cd /usr/local/php/etc/php-fpm.d/cp www.conf.default www.confsystemctl start php-fpmsystemctl status php-fpm

At this time, no accident is normal state:

Check if the process exists

ps -ef|grep php-fpm

Check whether the port is enabled:

ss -lntup| grep 9000 on how to install php environment under Linux to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

Tags: Configuration script environment content file time more source code directory path help output good success one step no accident interest again command word Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MySQL NVidia Linux Docker