Home >Backend Development >PHP Problem >How to compile and install PHP?
How to compile and install PHP?
First use the "wget" command to download and decompress PHP;
wget http://am1.php.net/distributions/php-7.3.2.tar.gz tar -zxvf php-7.3.2.tar.gz
Then execute the command "./configure --prefix=/opt/soft/php --enable-fpm "Compile;
./configure --prefix=/opt/soft/php --enable-fpm
Finally execute "make install" to install.
sudo make install
Configuring PHP
In the previously compiled source code package, find php.ini-production, copy it to /usr/local/php, and rename it to php .ini:
$ cp php.ini-production /usr/local/php/php.ini
[Optional] Set PHP error messages to be printed on the page
$ vim /usr/local/php/php.ini
display_errors = On
Copy the startup script:
$ cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm $ chmod +x /etc/init.d/php-fpm
Modify the php-fpm configuration file:
$ cd /usr/local/php/etc $ cp php-fpm.conf.default php-fpm.conf $ vim php-fpm.conf
Remove the semicolon in front of pid = run/php-fpm.pid
$ cd php-fpm.d $ cp www.conf.default www.conf $ vim www.conf
Modify the users of user and group to the current user (you can also leave it unchanged, the user and user group nobody will be added by default) )
Recommended tutorial: "PHP"
The above is the detailed content of How to compile and install PHP?. For more information, please follow other related articles on the PHP Chinese website!