Install php7 under Linux system Version 3

Time:2022-5-17

Please install the dependent package first


$ yum install -y gcc gcc-c++  make zlib zlib-devel pcre pcre-devel  libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

Download php-7.3.0


wget http://cn2.php.net/get/php-7.3.0.tar.gz/from/this/mirror -o php-7.3.0

decompression


$ tar -zxvf php-7.3.0.tar.gz
$ cd php-7.3.0

to configure


./configure \
--prefix=/usr/local/php \
--exec-prefix=/usr/local/php \
--bindir=/usr/local/php/bin \
--sbindir=/usr/local/php/sbin \
--includedir=/usr/local/php/include \
--libdir=/usr/local/php/lib/php \
--mandir=/usr/local/php/php/man \
--with-config-file-path=/usr/local/php/etc \
--with-openssl \
--enable-mbstring \
--enable-fpm

Compile and install 


$ make && make install

In the previously compiled source package, find PHP Ini production, copy it to / usr / local / PHP / etc and rename it PHP ini:


$ cp php.ini-production /usr/local/php/etc/php.ini

Compile the PHP source code into SAPI / FPM / init d. Copy the PHP FPM file to the system configuration / etc / init D) directory and rename it to PHP FPM


[[email protected] php-7.3.0]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm 
[[email protected] php-7.3.0]# chmod +x /etc/init.d/php-fpm

Add PHP FPM configuration file
Install PHP in / usr / local / PHP / etc / PHP FPM Copy the file conf.default to the same directory and rename it PHP FPM conf


[[email protected] php-7.3.0]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf 

Add www.conf configuration file

Install PHP in / usr / local / PHP / etc / PHP FPM Copy the D / www.conf.default file to the same directory and rename it www.conf


[[email protected] php-7.3.0]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf 

Add the PHP installation directory to the system environment variable

Create and open the file PHP sh


[[email protected] php-7.3.0]# vim /etc/profile.d/php.sh

Add the following:


export PATH=$PATH:/usr/local/php/bin/:/usr/local/php/sbin/

Save and exit


:wq! 

Use source to take effect immediately. The PHP environment variable just added


[[email protected] php-7.3.0]# source /etc/profile.d/php.sh 

Start PHP FPM


[[email protected] php-7.3.0]# service php-fpm start

See the 9000 port is also successful!!!

Set PHP startup

Modify the executable permissions of PHP FPM files in the system configuration directory 
[[email protected] php-src-php-7.1.6]# chmod +x /etc/init.d/php-fpm
>Add 'PHP FPM' under the system configuration directory to the 'system service'`
[[email protected] php-src-php-7.1.6]# chkconfig --add php-fpm
 
>Set 'PHP FPM' and 'system service' to startup
[[email protected] php-src-php-7.1.6]# chkconfig php-fpm on

After restarting, check the port to see if it exists!

This is about installing php7 under Linux system This is the article of version 3. More related Linux Installation php7 Please search the previous articles of developeppaer or continue to browse the relevant articles below. I hope you will support developeppaer in the future!