The most detailed process of installing php on linux
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!

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics



PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

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

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

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

PHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.
