What is the PHP installation directory structure of Linux?

11-09-2023

First, install PHP

1. Download the PHP source code

Go to PHP official website to download the latest version of PHP source code. The latest version is PHP 7.4.24.

2. Decompress the PHP source code

Decompress the downloaded PHP source package. The decompression command is as follows:

tar zxvf php-7.4.24.tar.gz

3. Install compilation tools and dependency libraries.

During the compilation process, some compilation tools and dependency libraries are needed, and they need to be installed first. The specific commands are as follows:

sudo apt-get updatesudo apt-get install build-essential autoconf libtool libssl-dev libcurl4-openssl-dev libxml2-dev libpng-dev libjpeg-dev libfreetype6-dev libzip-dev

4. Configure PHP

You need to configure the compilation before installation. You can enter the configuration interface by executing the following commands:

cd php-7.4.24./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/ etc --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/ usr --with-zlib --with-libxml-dir=/usr --enable-simplexml --enable-bcmath --enable-mbstring --enable-sockets --enable-zip --with-curl --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-gd

The meaning of each parameter is as follows:

--prefix: specifies the installation path of PHP.

-with-config-file-path: specifies the configuration file path of PHP.

--with-MySQLi: enable mysqli extension library.

-with-PDO-MySQL: Enable PDO_MySQL extension library.

-with-iconv-dir: Enable the iconv transcoding extension library.

--with-FreeType-dir-dir: enable freetype font library.

-with-JPEG-dir: Enable JPEG photo gallery.

-with-PNG-dir: enable png picture library.

--with-Zlib: enable zlib compression extension library.

--with-libxml-dir-dir: Enable XML extension library.

--enable-simplexml: Enables the SimpleXML extension library.

--enable-BCMath: enables the bcmath extension library.

--enable-MBString: enables the mbstring extension library.

-enable-Sockets: enable sockets extension library.

--enable-Zip: enables the zip compression extension library.

--with-CURL: enable curl library.

--enable-fpm: enables the FastCGI process manager.

-with-fpm-user: specifies the process user.

-with-fpm-group: specifies the process user group.

5. Compile and install PHP

After configuration, it can be compiled and installed by the following commands:

makesudo make install

6. Test PHP

After the installation, you can test whether PHP is successfully installed by the following command:

/usr/local/php/bin/php -v

If the installation is successful, the version number of PHP will be output.

Second, the PHP directory structure diagram

After installing PHP successfully, you can view the directory structure diagram of PHP, as shown below:

/usr/local/php/├── bin/ # The executable file for storing PHP │ ├ ─────── PHP-CGI ├ ────── PHP DBG │ ├ ───── PHP-FPM ├ ────── phpize. Directory of configuration files for storing PHP │ ├ ── PHP. ini ├ ─── PHP-fpm.conf └ ──── PHP-fpm.d/│ ├ ─── www.conf └ ──── other.conf ├ ───

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us