Home>Article>Backend Development> How to install php on centos 7.5

How to install php on centos 7.5

藏色散人
藏色散人 Original
2022-01-26 10:54:29 3204browse

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.

How to install php on centos 7.5

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/)

2. Start installation

    Add php user, used to run the php-fpm process
  1. cd /usr/local/ useradd php -s /sbin/nologin

How to install php on centos 7.5

    Unzip the php source package

  1. tar -zxf php-7.4.1 .tar.gzHow to install php on centos 7.5
  2. Install dependency packages
  3. 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
    Compilation parameter reference
  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

How to install php on centos 7.5Compilation and installation completed

How to install php on centos 7.5

3. Copy the relevant configuration files to the php installation path

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

How to install php on centos 7.5

##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

How to install php on centos 7.5Start php-fpm
Execute init.d.php-fpm to start Script, start php-fpm

[root@iZ8vbice4h2bcujon9zc00Z php]# bash init.d.php-fpm start

How to install php on centos 7.5edit .bash_profile

vim ~/.bash_profile

How to install php on centos 7.5Finally, run the command

source ~/.bash_profile
Check the PHP version php -v

Test it: vim test.phpHow to install php on centos 7.5

How to install php on centos 7.5

How to install php on centos 7.5Recommended learning: "

PHP Video Tutorial

"

The 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn