The most detailed linux php installation process

This article and share the most detailed linux php installation process, and then write the installation of nginx configuration, the back is installed php and mysql installed, but time is limited, and put the papers in too long, so all write separately , php mysql after installation is configured.

 

A: Check the installed php

1) yum install check: | grep php yum list of installed

2) rpm installation check: rpm -qa | grep php

3) There are many ways a query, such as finding php execution of the program, or check the process ps -ef own compiler installation | grep php and other methods.

Two: If you do not check php installed, you can prepare the initial software pre-installed php with yum install xxxx to install, of course, too much trouble, trouble could compile your own installation, not explained in detail here.

1) zlib and zlib-devel zlib data compression library provides, but also the nginx front-end software, due to the zlib zlib extension needs to compile php, and will need to use the compiler zlib.h this header file, header file in zlib-devel and, therefore, you need to download the zlib-devel.

2) libxml2 libxml-devel libxml2 and c is a language xml library, you can simply perform various operations on the xml, xpath queries and support, as well as some support xslt conversion.

3) libxslt and libxslt-devel if libxslt-devel is not installed will be prompted to find xslt.config file, xslt xml conversion is extended to other formats.

3) openssl and openssl-devel proprietary layer security code library

4) jpeg IJG jpeg library is required php's gd library.

5) libpng is c language more complex cross-platform pngpng document library that can help readers easily replace each line of the file pngpng required php's gd library.

6) freetype and freetype-devel free open source and portable font engine, providing a unified interface to access a variety of font formats, both of which are dependent on software gd library, so if you have not installed, or the version is too low, the installation phptime set is installed gd library insert error, no additional installation -devel also will complain, because the compiler extensions of time will ft2build.h file, an error in the following figure.

7) gd gd is a graphics processing php extensions

8) curl, due yum in my version is too low, so direct their own compiler installation, the installation is very simple, that is, after wget curl Download tar decompression, the new / usr / local / curl folder, then enter curl after extracting the file folder configuration. / Configure - prefix = / usr / local / curl immediately, and finally make make install it installed.

Note: xxx-devel is xxx software development kit, containing static libraries and header files and even source code.

Three: php download and install

1) using wget to download the php file tar.gz: wget 

2) extract the tar.gz file: tar zxvf php-7.2.2.tar.gz

3) would be to install a new php folder: mkdir / usr / local / php, php and then enter the installation package file folder after extracting, Configuration:

./configure --prefix = / usr / local / php --with-curl = / usr / local / 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-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip

 

note:

--prefix = installation directory

--with- package name [= package directory]

--enable- need to activate the function

Four: Configure php related documents

1) Configure php.ini, which is php configuration file: cp /home/myload/php-7.2.2/php.ini-development /usr/local/php/lib/php.ini

 

2) Configure php-fpm.conf, this is php-fpm configuration file: cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

3) Configure www.conf, user configuration files: cp etc / php-fpm.d / www.conf.default etc / php-fpm.d / www.conf

4) Copy php-fpm init.d startup file folder to a convenient starting php: cp -R sbin / php-fpm /etc/init.d/php-fpm

Five: Start php, determine whether the installation was successful

Immediately execute the command /etc/init.d/php-fpm

Check whether to activate: ps -ef | grep php can either start to see some progress php

Six: After successful installation support configuration nginx php

1) Change the php.ini file, vim /usr/local/php/lib/php.ini

Find cgi.fix_pathinfo = 1 by this configuration, and remove the comment and replace cgi.fix_pathinfo = 0, does not belong here nginx php configuration-related support, or exclusively under nginx php of a security breach, if here is decremented by one user party can upload pictures to upload by Trojans, and then access the images through the Web site address, and adding /xxx.php PHP will run as a picture file in the address, it will be only in the presence of problems in nginx, apache and iis not the problem

The above problems can be directly think of Bird Brother blog, write in considerable detail: HTTP: //

2) specific web configuration and user groups

Add www user group: groupadd www

Add users at www www user groups: useradd -g www www

3) Change the php-fpm.conf configuration

The user = nobody Notes removed, nobody was added into the above configuration user www

The group = nobody Notes removed, nobody was added into the above configuration www user groups

Finally, check the last value contained php-fpm.conf is not the right www.conf address directory, if an incorrect address is changed to the correct directory.

4) Change the configuration www.conf

The user = nobody Notes removed, nobody was added into the above configuration user www

The group = nobody Notes removed, nobody was added into the above configuration www user groups

5) Change the nginx.conf file /etc/local/nginx/conf/nginx.conf

Note #user = nobody will remove and replace the user = www

Delete location ~ \ .php $ {...} comment this code, turn / scripts replace fastcgi_param in the $ document_root

Finally, add the index position later in replacement / {...} index.php on, to ensure that as an alternative home index.php

6) restart php-fpm and nginx, can kill all php-fpm and then to restart /etc/init.d/php-pfm, / usr / local / nginx / sbin / nginx -s stop can stop nginx, then execute / usr / local / nginx / sbin / php restart immediately.

7) just create a php directory in html file, content is phpinfo () ;, then access the file address in the browser to see if the correct php related information displayed correctly if the configuration was successful.

Seven: apache with support php, add the follow-up to be continued ...

 

Above hope to help everyone, many PHPer always encounter some problems and bottlenecks in the advanced time, write more business code no sense of direction, I do not know from where to start to ascend, which I compiled some information, including but not limited to: a distributed architecture, highly scalable, high-performance, high-concurrency, server performance tuning, TP6, laravel, YII2, Redis , Swoole, Swoft, Kafka, Mysql optimization, shell scripts, Docker, micro-services, Nginx, etc. more advanced knowledge required for advanced dry goods can be free for everyone to share, I need to join the official group , click here .

Guess you like

Origin www.cnblogs.com/a609251438/p/12088717.html