Home > Backend Development > PHP Problem > How to compile and install php

How to compile and install php

藏色散人
Release: 2023-02-26 11:30:01
Original
2821 people have browsed it

How to compile and install php

How to compile and install php?

Compile and install php7.0

1. Unzip and install

 tar zxvf php-7.0.2.tar.gz
 cd php-7.0.2
Copy after login

2. Install dependent libraries:

yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel  libxslt-devel  curl-devel
Copy after login

3. Compile and install, the parameters are as follows:

./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-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-shmop \
 --enable-soap \
 --enable-sockets \
 --enable-sysvsem \
 --enable-xml \
 --enable-zip
Copy after login

4. Compile and install

 make &&  make install
Copy after login

5. Copy the default configuration file

cp php.ini-development /usr/local/php/lib/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 -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm
Copy after login

It should be noted that php7 Configure the port number and other information of phpfpm in the www.conf configuration file. If you change the default 9000 port number, you need to change it here, and then change the nginx configuration

6. Start php- fpm

/etc/init.d/php-fpm
Copy after login

7. Configure nginx to enable the php-fpm module:

location ~ \.php$ {
root /usr/local/nginx/html/question;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Copy after login

For more PHP-related knowledge, please visit PHP Chinese website!

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

Related labels:
php
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