Home>Article>Backend Development> How to install php on centos 7.5
How to install php on centos7.5: 1. Add php user for running php-fpm process; 2. Unzip the php source code package; 3. Install dependency packages; 4. Copy relevant configuration files to php installation Path is enough.
The operating environment of this article: CentOS7.5 system, php7.4.1 version, DELL G3 computer
How to install php on centos 7.5?
CentOS-7.5 Compile and install php-7.4.1
##Travel record: Generally, yum is used to install the package, which is more resistant to source code compilation. After searching on Baidu, it was successfully installed~ 1. Environment preparation Virtual machine: centos 7 Download the source file php-7.4.1:
wget https://www.php.net/distributions/php-7.4.1.tar.gz(Due to half of the download error on the server , change to local download and upload to server scp php-7.4.1.tar.gz root@server ip:/usr/local/)
cd /usr/local/ useradd php -s /sbin/nologin
yum install libxml2-devel sqlite-devel libcurl-devel oniguruma-devel libpng-devel libjpeg-devel freetype-devel libzip-devel openssl-devel -y
cd /usr/local/php-7.4.1
[root@iZ8vbice4h2bcujon9zc00Z php-7.4.1]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mhash --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv --with-zlib --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-bcmath --enable-shmop --enable-sysvsem --enable-gd --with-jpeg --with-freetype --enable-mbregex --enable-mbstring --enable-ftp --enable-pcntl --enable-sockets --enable-soap --without-pear --with-gettext --enable-session --with-curl --enable-opcache --enable-fpm --with-fpm-user=php --with-fpm-group=php --without-gdbm --enable-fast-install --disable-fileinfo
[root@iZ8vbice4h2bcujon9zc00Z php-7.4.1]# make && make install
Compilation and installation completed
Start the script: php-7.4.1/sapi/fpm/init. d.php-fpm
cd /usr/local/php-7.4.1/sapi/fpm/ cp init.d.php-fpm /usr/local/php/
php.ini configuration file: php-7.4.8/php.ini-production
cd /usr/local/php-7.4.1 cp php.ini-production /usr/local/php/etc/php.ini
Create php -fpm.conf configuration file
Enter the etc/usr/local/php/etc
[root@iZ8vbice4h2bcujon9zc00Z etc]# pwd /usr/local/php/etc [root@iZ8vbice4h2bcujon9zc00Z etc]# ls php-fpm.conf.default php-fpm.d php.ini [root@iZ8vbice4h2bcujon9zc00Z etc]# cp php-fpm.conf.default php-fpm.conf##Enter the php-fpm.d directory under the php installation path , rename the files inside
[root@iZ8vbice4h2bcujon9zc00Z php-fpm.d]# pwd /usr/local/php/etc/php-fpm.d [root@iZ8vbice4h2bcujon9zc00Z php-fpm.d]# ls www.conf.default [root@iZ8vbice4h2bcujon9zc00Z php-fpm.d]# [root@iZ8vbice4h2bcujon9zc00Z php-fpm.d]# cp www.conf.default www.conf
Start php-fpm
Execute init.d.php-fpm to start Script, start php-fpm
[root@iZ8vbice4h2bcujon9zc00Z php]# bash init.d.php-fpm start
edit .bash_profile
vim ~/.bash_profile
Finally, run the command
source ~/.bash_profileCheck the PHP version php -v
Test it: vim test.php
Recommended learning: "
PHP Video TutorialThe above is the detailed content of How to install php on centos 7.5. For more information, please follow other related articles on the PHP Chinese website!