This article mainly shares with you the most detailed process of installing php on Linux. I have written the installation configuration of nginx before, followed by the installation of php and the installation of mysql. However, the time is limited, and it is too long to put it in one article, so it is all It is written separately. After PHP is installed, it is the configuration of MySQL.
1: Check whether php is installed
1) yum installation check: yum list installed | grep php
2) rpm installation check: rpm -qa | grep php
3) There are many ways to query if you compile and install it yourself, such as finding the executable program of php, or checking the process ps -ef | grep php and other methods.
Two: Check if php is not installed, you can prepare the pre-installation software before php installation. Use yum install xxxx to install it. Of course, you can compile and install it yourself if you don't mind the trouble. I won't go into details here.
1) zlib and zlib-devel zlib provides a data compression function library and is also the front-end software of nginx. Since zlib needs to compile the zlib extension of php, the zlib.h header file will need to be used during compilation. The header files are in zlib-devel, so zlib-devel also needs to be downloaded.
2) libxml2 and libxml-devel libxml2 is a c language xml library that can simply perform various operations on xml, and supports xpath query, and partially supports xslt conversion and other functions.
3) libxslt and libxslt-devel If you do not install libxslt-devel, you will be prompted that the xslt.config file cannot be found. xslt is an extension for converting xml to other formats.
3) openssl and openssl-devel secure socket layer password library
4) jpeg IJG's jpeg library, php's gd library required.
5) libpng is a relatively low-level cross-platform library written in C language for reading and writing png files. It can help easily read and write each line of pixels in png files. It is required by the gd library of PHP.
6) freetype and freetype-devel are free, open source and portable font engines that provide a unified interface to access multiple font formats. Both of these are dependent software of the gd library, so if they are not installed, or The version is too low. If you set the gd library to be installed when installing PHP, an error will be reported. In addition, if -devel is not installed, an error will be reported because the ft2build.h file will be missing when compiling the extension. The error is reported as shown below.
7) gd gd is an extension library for PHP to process graphics
8) curl, because the version in my yum is too low, So I compiled and installed it myself. The installation method is very simple, that is, wget curl downloads the address and decompresses the tar, creates a new /usr/local/curl folder, and then enters the curl decompressed folder to configure./configure --prefix=/ usr/local/curl is enough, and finally make and make install are installed.
Note: xxx-devel is the development package of xxx software, including header files, static libraries and even source code.
Three: PHP download and installation
1) Use wget to download the tar.gz file of PHP: wget http://br2.php.net/get/php-7.2.2.tar. gz
2) Unzip the tar.gz file: tar zxvf php-7.2.2.tar.gz
3) Create a new folder where php will be installed later: mkdir /usr/local/ php, and then enter the decompressed php installation package folder and configure 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
Note:
--prefix=installation directory
--with-use package name [= package directory]
--enable-functions that need to be activated
Four: Configure php related files
1) Configure php.ini , this is the configuration file of php: cp /home/myload/php-7.2.2/php.ini-development /usr/local/php/lib/php.ini
2) Configure php-fpm. conf, this is the php-fpm configuration file: cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
3) Configuration www.conf, the user configuration file: cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf
4) Copy the php-fpm startup file to A copy of the init.d folder is convenient for starting php: cp -R sbin/php-fpm /etc/init.d/php-fpm
5: Start php and confirm whether the installation is successful
Execute the command /etc/init.d/php-fpm
Check whether it is started: ps -ef |grep php You can see which processes have been started by php
6: Installation successful After configuring nginx to support php
1) Change the php.ini file, vim /usr/local/php/lib/php.ini
By searching for the configuration cgi.fix_pathinfo=1, removing the comments, and changing it to cgi.fix_pathinfo=0, this is not related to nginx’s support for php configuration, but a security vulnerability specific to php under nginx. If this is The value is 1. The user can upload the Trojan by uploading a picture, then access the picture address through the URL, and add /xxx.php after the address to run the picture as a php file. This is a problem that only exists in nginx. , neither apache nor iis has this problem
For the above questions, you can directly refer to Brother Niao’s blog, which is written in quite detail: http://www.laruence.com/2010/05/20/1495.html
2) Configure web-specific groups and users
Add the www user group: groupadd www
Add the user www under the www user group: useradd -g www www
3) Change the php-fpm.conf configuration
Remove the comment of user=nobody, and change nobody to the www user configured above
Remove the comment of group=nobody, and Change nobody to the www user group configured above
Finally check whether the last include value of php-fpm.conf is the correct www.conf directory address. If it is incorrect, change it to the correct directory address.
4) Change the www.conf configuration
Remove the comment of user=nobody, and change nobody to the www user configured above
Remove the comment of group=nobody , and change nobody to the www user group configured above
5) Change the nginx.conf file /etc/local/nginx/conf/nginx.conf
and remove the comment #user=nobody And change it to user=www
Remove the comments of location ~ \.php${...} and change /scripts in fastcgi_param to $document_root
Finally, add index.php after the default index in location/{...} to ensure that index.php is used as the default homepage
6) Restart php-fpm and nginx, you can killall php-fpm and then /etc/init.d/php-pfm to restart, /usr/local/nginx/sbin/nginx -s stop to stop nginx, and then execute /usr/local/nginx/sbin/php to restart.
7) Create a php file in the html directory, the content is phpinfo();, and then access the file address in the browser to see if the correct php related information is obtained. If it is displayed correctly, the configuration is successful. .
Seven: Cooperate with apache to support php, this will be added later, to be continue...
Related recommendations:
Linux installation php error record
Linux installation php module --with-mysql --with-mysqli Do you need to install mysql?
Linux installation php and memcache process record
The above is the detailed content of The most detailed process of installing php on linux. For more information, please follow other related articles on the PHP Chinese website!

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor