The most detailed Linux installation PHP process

Source: Internet
Author: User
Tags gz file php download xslt
This article mainly share with you the most detailed Linux installation PHP process, before writing the installation configuration of Nginx, the following is the installation of PHP and MySQL installation, but the time is limited, and put in an article is too long, so are separate to write, PHP after installation is the configuration of MySQL.

One: Check if PHP is installed

1) Yum install check: Yum list installed |grep PHP

2) RPM installation check: Rpm-qa |grep php

3) There are many ways to compile and install your own query, such as Find PHP execution program, or check the process Ps-ef |grep PHP methods.

Second: Check if you do not have PHP installed, you can prepare the pre-installation of PHP before the software, with yum install XXXX can be installed, of course, it is not too troublesome to compile and install themselves, here is not detailed said.

1) zlib and zlib-devel zlib provide data compression function library, is also Nginx's predecessor software, because zlib need to compile the zlib extension of PHP, In the compilation will need to use Zlib.h this header file, header file in Zlib-devel, so also need to download zlib-devel.

2) LIBXML2 and Libxml-devel libxml2 is a C-language XML library that can perform various operations on XML, support XPath queries, and partially support XSLT transformations.

3) Libxslt and libxslt-devel If you do not install Libxslt-devel you will be prompted to find the Xslt.config file, XSLT is an extension that transforms XML into other formats.


3) OpenSSL and Openssl-devel Secure Sockets Layer Cipher Library

4) JPEG ijg JPEG library, PHP's GD library is required.

5) Libpng is the C language written by the comparison of the underlying read and write PNG file cross-platform library, can help to read and write PNG file every line of pixels, PHP's GD library required.

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 the software of the GD library, so if not installed, or the version is too low, installed in PHP when the installation of the GD library will be an error, Also do not install-devel also will error, because the compile extension will be missing ft2build.h file, error such as.


7) GD GD is an extended library of PHP processing graphics

8) Curl, because my yum version is too low, so I directly compiled the installation, the installation is very simple, that is, wget curl download address after the tar decompression, new/usr/local/curl folder, and then into the folder after Curl decompression configuration. Configure--prefix=/usr/local/curl, the final make and make install is installed.

Note: Xxx-devel is the development kit for XXX software, including header files as well as static libraries and even source code.

Three: PHP Download installation

1) Download php tar.gz file with wget: wget http://br2.php.net/get/php-7.2.2.tar.gz

2) Unzip tar.gz file: Tar zxvf php-7.2.2.tar.gz

3) Create a new folder to install PHP: mkdir/usr/local/php, then go to the extracted PHP installation package folder, configure the Configure:

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

Attention:

--prefix= installation directory

--with-using Package Name [= Package directory]

--enable-features that need to be activated

Four: Configure PHP-related files

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

2) Configure php-fpm.conf, which is the PHP-FPM profile: cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf

3) Configure www.conf, configure user's files: CP etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf

4) Copy the PHP-FPM boot file to the Init.d folder for a convenient start php:cp-r sbin/php-fpm/etc/init.d/php-fpm

V: Launch PHP to determine if the installation was successful

Execute Command/ETC/INIT.D/PHP-FPM

See if it starts: Ps-ef |grep PHP can see which processes PHP has started

Six: After successful installation, configure Nginx support PHP

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

By looking cgi.fix_pathinfo=1 This configuration, and remove the comments, and instead of cgi.fix_pathinfo=0, here is not the Nginx support PHP configuration related, but specifically for the nginx PHP a security vulnerability, if this value is 1, The user can upload the image to upload the Trojan, and then through the URL to access the image address, and add/xxx.php after the address to the image as a PHP file to run, this is only in the Nginx problem, Apache and IIS do not have the problem

The above questions can be directly referred to the bird Brother's blog, written in quite detailed: http://www.laruence.com/2010/05/20/1495.html

2) Configure Web-specific groups and users

Add www user group: Groupadd www

Add users under the WWW user group www:useradd-g www www

3) Change the php-fpm.conf configuration

Remove the comments from the user=nobody and change the nobody to the WWW user configured above

Remove the comments from the group=nobody and change the nobody to the WWW user group configured above

Finally, check that the value of the last include in php-fpm.conf is the correct www.conf directory address, and replace it with the correct directory address if it is incorrect.

4) Change the www.conf configuration

Remove the comments from the user=nobody and change the nobody to the WWW user configured above

Remove the comments from the group=nobody and change the nobody to the WWW user group configured above

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

Remove #user=nobody comments and change to User=www

Remove location ~ \.php${...} Comment on this code and change the/scripts in Fastcgi_param to $document_root


Finally the location/{...} Add the index.php to the default index, making sure that index.php as the default home page


6) Restart PHP-FPM and Nginx, you can killall php-fpm and then/ETC/INIT.D/PHP-PFM can restart,/usr/local/nginx/sbin/nginx-s stop can stop Nginx, and then execute/ Usr/local/nginx/sbin/php can be restarted.

7) in the HTML directory to create a random php file, the content is phpinfo (), and then in the browser to access the file address, to see if the correct information about PHP, if the correct display of the configuration is successful.

Seven: with Apache support PHP, this follow-up add, to be continue ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.