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
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