search
HomeBackend DevelopmentPHP ProblemHow to deploy php environment in centos

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools