How to install php7.3 in centos8 custom directory

1. Directory Structure

Source directory: /home/werben/pkgsrc/php-7.3.11

Installation directory: /home/werben/application/php7.3.11

2. Download php source code

Official website address: https://www.php.net/downloads.php

wget https://www.php.net/distributions/php-7.3.11.tar.bz2

3. Unzip the source code

tar --bzip -xvf php-7.3.11.tar.bz2 php-7.3.11

4. Install compilation tools and libraries

yum install -y gcc gcc-c++
yum -y install libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel libicu-devel freetype-devel openldap-devel openldap openldap-devel

5. Configure compilation parameters

# Create user groups and users
groupadd www
useradd -g www www

# Configure fpm user groups and users, and install other extensions
. /configure --prefix=/home/werben/application/php7.3.11 \
- - enable-fpm \
- - with-fpm-user=www \
- - with-fpm-group=www \
- - enable-mysqlnd \
- - with-mysqli=mysqlnd \
- - with-pdo-mysql=mysqlnd \
- - enable-mysqlnd-compression-support \
- - with-iconv-dir \
- - with-freetype-dir \
- - with-jpeg-dir \
- - with-png-dir \
- - with-zlib \
- - with-libxml-dir \
- - enable-xml \
- - disable-rpath \
- - enable-bcmath \
- - enable-shmop \
- - enable-sysvsem \
- - enable-inline-optimization \
- - with-curl \
- - enable-mbregex \
- - enable-mbstring \
- - enable-intl \
- - with-mcrypt \
- - with-libmbfl \
- - enable-ftp \
- - with-gd \
- - enable-gd-jis-conv \
- - enable-gd-native-ttf \
- - with-openssl \
- - with-mhash \
- - enable-pcntl \
- - enable-sockets \
- - with-xmlrpc \
- - enable-zip \
- - enable-soap \
- - with-gettext \
- - disable-fileinfo \
- - enable-opcache \
- - with-pear \
- - enable-maintainer-zts \
- - with-ldap=shared \
- - without-gdbm

# There may be many problems with the above steps. If you need to reinstall libzip, you need to install ldap, you need to install cmake

# Reinstalling libzip requires installing cmake,Record the installation steps of cmake here,Baidu solved other problems by itself,
# No record, I went to the official website to download several latest cmake versions, and errors occurred during the compilation process.
# Found the pagoda with 2.8.X version. The version I use here is 3.5.Version 2

wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz
tar xvf cmake-3.5.2.tar.gz
cd cmake-3.5.2./bootstrap --prefix=/usr/local/cmake
gmake
gmake install

cd /usr/local/cmake/bin
ln -s /usr/local/cmake/bin/cmake /usr/bin/
cmake --version

# Next install libzip
wget https://libzip.org/download/libzip-1.5.2.tar.gz
tar -zxf libzip-1.5.2.tar.gz
cd libzip-1.5.2
mkdir build
cd build 
cmake ..
make -j4
make install

6. Install make tool

# If you are prompted that the make command cannot be found, you need to install the make tool
yum -y install gcc automake autoconf libtool make

7. Compile and install

make && make install

8. Map global commands

ln -s /home/werben/application/php7.3.11/sbin/* /usr/local/sbin/
ln -s /home/werben/application/php7.3.11/bin/* /usr/local/bin/

9. Configure php.ini

# View php.ini's location
php -r "phpinfo();"| grep 'php.ini'

# Php in the source code.ini*Copy to php.ini's location
cp /home/werben/pkgsrc/php-7.3.11/php.ini-*/home/werben/application/php7.3.11/lib/

# Rename php.ini file
cp /home/werben/application/php7.3.11/lib/php.ini-production /home/werben/application/php7.3.11/lib/php.ini

10. Installation directory structure

# /home/werben/pkgsrc/php-7.3.11 Structure of the installation directory
├── bin
│  ├── pear
│  ├── peardev
│  ├── pecl
│  ├── phar -  phar.phar
│  ├── phar.phar
│  ├── php
│  ├── php-cgi
│  ├── php-config
│  ├── phpdbg
│  └── phpize
├── etc
│  ├── pear.conf
│  ├── php-fpm.conf.default
│  └── php-fpm.d
├── include
│  └── php
├── lib
│  ├── php
│  ├── php.ini
│  ├── php.ini-development
│  └── php.ini-production
├── php
│  ├── man
│  └── php
├── sbin
│  └── php-fpm
└── var
 ├── log
 └── run

**ps: The following will show how to integrate PHP with Nginx and Apache. **

Configure PHP for use with Apache

If you use Apache as a web server, please use the following command to restart the httpd service, you can use:

$ sudo systemctl restart httpd

Configure PHP for use with Nginx

By default, PHP FPM runs as the user apache. To avoid permission issues, we change the user to nginx. To do this, please edit the relevant lines, namely user = nginx and group = nginx:

$ sudo nano /etc/php-fpm.d/www.conf
...
user = nginx
..
group = nginx

Make sure the /var/lib/php directory has the correct ownership:

$ chown -R root:nginx /var/lib/php

After completion, restart the PHP FPM service:

$ sudo systemctl restart php-fpm

Next, edit the Nginx host directive and add the following location block so that Nginx can process PHP files:

server {

 # ... other code

 location ~ \.php$ {

  try_files $uri =404;

  fastcgi_pass unix:/run/php-fpm/www.sock;

  fastcgi_index index.php;

  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

  include fastcgi_params;}}

In order for the new configuration to take effect, restart the Nginx service:

$ sudo systemctl restart nginx

to sum up

The above is the editor's introduction to you how to install php7.3 in the centos8 custom directory. I hope it will be helpful to you. If you have any questions, please leave me a message, and the editor will reply to you in time. Thank you very much for your support to the ZaLou.Cn website!
If you think this article is helpful to you, welcome to reprint, please indicate the source, thank you!

Recommended Posts

How to install php7.3 in centos8 custom directory
How to install PHP7.4 in CentOS
How to install HDP2.6 in Centos7.2
How to install PHP on CentOS 8
How to install Android SDK in centos7
Install php in centos
Install nginx in centos8 custom directory (detailed tutorial)
How to install jdk1.8 on centOS7
How to install MySQL on CentOS 8
How to install Memcached on CentOS 8
How to install FFmpeg on CentOS 8
How to install Virtualbox on CentOS 8
How to install TensorFlow on CentOS 8
How to install TeamViewer on CentOS 8
How to install Perl 5 on CentOS
How to install Git on CentOS 8
How to install Gradle on CentOS 8
How to install Jenkins on CentOS 8
How to install Java on CentOS 8
How to install Go on CentOS 8
How to install GCC on CentOS 8
How to install mysql in Ubuntu 14.04
How to install Yarn on CentOS 8
How to install Nginx on CentOS 8
How to install Jenkins on CentOS 8
How to install Vagrant on CentOS 8
How to install Python 3.8 on CentOS 8
How to install Tomcat 9 on CentOS 8
How to install Webmin on CentOS 8
How to install Ruby on CentOS 8
How to install Skype on CentOS 8
How to install htop on CentOS 8
How to install Python on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Postgresql on CentOS 8
How to install Wordpress on Centos
How to install htop on CentOS 8
How to install mysql in Ubuntu 14.04
How to install TeamViewer on CentOS 8
How to install MariaDB on CentOS 8
How to install MongoDB on CentOS 7
How to install Odoo 13 on CentOS 8
How to install Apache on CentOS 8
How to install OpenCV on CentOS 8
How to install MongoDB on CentOS 8
How to compile and install PHP and Nginx in Ubuntu environment
CentOS install PHP
Centos install sshfs to achieve mount directory
How to install Apache Maven on CentOS 8
How to install third-party modules in Python
How to custom catch errors in python
How to install Apache Kafka on CentOS 7
How to install cuda10.1 driver in Ubuntu
How to install ROS Noetic in Ubuntu20.04
[Graphic] How to install tomcat on centos
R&D: How To Install Python 3 on CentOS 7
How to install GCC compiler on CentOS 7
How to install offline JDK1.8 on centos7.0
How to install and configure Elasticsearch on CentOS 7
How to install Visual Studio Code on CentOS 8
How to install and use Docker on CentOS 7