Home > Operation and Maintenance > CentOS > How to install php under centos

How to install php under centos

藏色散人
Release: 2020-08-29 13:42:31
Original
4144 people have browsed it

How to install php under centos: first install the software required by php; then download php and unzip and install it; then enter the directory and compile and configure; finally compile and install the php source code through the command "make & make install" .

How to install php under centos

# Recommended: "

centos tutorial

Install the software required for php

yum install -y gcc gcc-c++ libxml2 libxml2-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel curl curl-devel libxslt-devel openssl-devel
Copy after login

Download php

wget http://cn2.php.net/distributions/php-7.1.4.tar .gz

Unzip and install

tar zxvf php-7.1.4.tar.gz

Enter the directory

cd php-7.1.4

Compile (installation) configuration

./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysql --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-sockets --enable-sysvsem --enable-xml --enable-zip
Copy after login

—If there is an error in this step, it is probably because of a lack of extensions. Follow the prompts to install extensions or fix problems

Compile and install php source code

make & make install

Copy the php configuration to the php installation directory

1. 复制php.ini命令: cp php.ini-development /usr/local/php/lib/php.ini
2. 复制php-fmp配置命令: cp ./sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf
3. 查看php是否安装成功: /usr/local/php/bin/php --version
Copy after login

If the php version is displayed, the installation is successful


How to install php under centos

groupadd www # New Add user group

useradd -g www www #Add user and set user group

View the port number occupied by php-fpm: ps -ef | grep php-fpm

Configure php-fmp: vi /usr/local/php/etc/php-fpm.conf
Modify
            user = nobody
          group = nobody
                                                                                                                                                     Changed to
                 user = www
group = www

Configure php-fpm.conf (vim /usr/local/php/etc/php-fpm.conf), put before pid (;pid = run/php-fpm.pid); Remove.

cp /usr/local/src/php-7.1.4/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
Set permissions and add services
chmod x /etc/init.d/php-fpm
chkconfig –add php-fpm
You can use the following commands to manage php-fpm in the future
service php-fpm start
service php-fpm stop
service php-fpm restart
service php-fpm reload

Test if the following error is reported


How to install php under centos

Solution:

Enter PHP Installation directory/etc/php-fpm.d

cp www.conf.default www.conf
Amend user and group in www.conf and change nobody to www

The above is the detailed content of How to install php under centos. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template