Home>Article>Backend Development> How to deploy php environment in centos

How to deploy php environment in centos

藏色散人
藏色散人 Original
2022-10-25 09:33:45 4312browse

How to deploy the php environment in centos: 1. Install the extension through the "yum install" command; 2. Use the "wget http://php.net/distributions/php-7.1.0.tar.gz" command Unzip php; 3. Compile and install through the "make && make install" command; 4. After the installation is successful, configure the environment variables; 5. Start "php-fpm".

How to deploy php environment in centos

The operating environment of this tutorial: CentOS 7 system, PHP version 8.1, Dell G3 computer.

How to deploy php environment in centos?

centos installation php environment

This time I will tell you about my installation and deployment of php environment (I have successfully used it)

1 , First install the extension with yum

yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel

2, and then decompress php

wget http://php.net/distributions/php-7.1.0.tar.gz

If it cannot be downloaded, download the php.tar.gz file from the local official website

tar -zxvf php-7.1.0.tar.gz cd php-7.1.0

3. Compile and install. Various errors may occur during compilation. The next article will focus on common compilation errors and their solutions:

./configure \ --prefix=/usr/local/php7 \ --with-apxs2=/usr/local/apache/bin/apxs \ --with-config-file-path=/usr/local/php7/etc \ --with-mysql \ --with-mysqli \ --with-mysql-sock \ --enable-pdo \ --with-pdo-mysql \ --with-gd \ --with-iconv \ --with-curl \ --with-zlib \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --enable-mbregex \ --enable-mbstring \ --enable-gd-native-ttf \ --with-openssl \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-zip \ --enable-soap \ --without-pear \ --with-gettext \ --enable-session \ --with-jpeg-dir=/usr/local/jpeg \ --with-freetype-dir \ --with-png-dir=/usr/local/pngp \ --with-bz2

4. Compilation successful Post-installation:

make && make install

5. Configure environment variables after successful installation:

For ease of use, you can add php environment variables at the end of the /etc/profile file:

(1) PATH=$PATH:/usr/local/php7/bin (2) export PATH

6 , Refresh the environment variables after saving:

source /etc/profile  #更新

7. Check the environment variables:

echo $PATH

8. After seeing the path of the php environment variable, you can use the php command directly in the future to check the php version. :

php -v

9. The current PHP does not have .ini files and configuration files, and PHP-FPM needs to be configured:

cp php.ini-production /etc/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm

10. Start, stop and restart php-fpm:

service php-fpm start  #启动 service php-fpm stop   #停止 service php-fpm restart #重启

After successful installation, add a custom root directory and add the index.Php file

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to deploy php environment in centos. 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