How to install php in linux
Method: 1. Use wget to download the tar.gz file of php, the syntax is "wget http://br2.php.net/get/php-7.2.2.tar.gz"; 2. Use tar Command to decompress the PHP tar.gz file, the syntax is "tar zxvf php compressed file"; 3. Create a new PHP-related folder, then enter the decompressed PHP installation package folder, and use the command to configure; 4. Configure PHP-related files; 5. Start php and confirm whether the installation is successful.
The operating environment of this tutorial: linux7.3 system, PHP7.2.2 version, DELL G3 computer
Check whether Installed php
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.
Check If php is not installed, you can prepare the initial 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 will need to be used during compilation. Files and 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) If libxslt and libxslt-devel are not installed, you will be prompted to find the xslt.config file. xslt is an extension for converting xml to other formats.
3) openssl and openssl-devel security proprietary layer password library
4) jpeg IJG's jpeg library, PHP's gd library required.
5) libpng is a cross-platform library for relatively complex pngpng files written in C language. It can help easily read and replace each line of pngpng files, which 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. When installing phptime, the setting is to install the gd library and insert an error. In addition, if -devel is not installed, an error will be reported because the ft2build.h file will be generated 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 directly use it myself Compiled and installed, 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 immediately, 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.
Download and install php in linux
1) Use wget to download the tar.gz file of php: wget <span class="invisible">http: //<span class="visible">br2.php.net/get/php-7.2<span class="invisible">.2.tar.gz</span></span></span>
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 In the installation package folder, 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-Features that need to be activated
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, this is the php-fpm configuration file: cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
3) Configure www.conf and configure the user’s file: cp etc /php-fpm.d/www.conf.default etc/php-fpm.d/www.conf
4) Copy the php-fpm startup file to the init.d folder to conveniently start php: cp -R sbin / php-fpm /etc/init.d/php-fpm
Start php and confirm whether the installation is successful
Execute the command /etc/init. d/php-fpm immediately
Check whether it is started: ps -ef | grep php You can see that php has started some progress
After successful installation, configure 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, deleting the comment, and replacing cgi.fix_pathinfo = 0, this is not related to nginx’s support for php configuration, or is a security vulnerability specific to php under nginx. If this is narrowed down 1. Users can upload Trojans by uploading images, and then access the image address through the URL, and add /xxx.php after the address to run the image as a PHP file. This is a problem that only exists in nginx, apache and iis None of them have this problem
The above questions can be directly thought of Brother Niao’s blog, which is written in quite detail: http://http://www.laruence.com/2010/05/20 /1495.html
2) Configure web-specific groups and users
Add 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 user = nobody, add nobody and change it to the configuration above www user
Remove the comment of group = nobody, add nobody and change it to the www user group configured above
Finally check whether the last value contained in php-fpm.conf is correct www. conf directory address, if incorrect, replace it with the correct directory address.
4) Change the www.conf configuration
Remove the comment of user = nobody, add nobody and change it to the www user configured above
Remove the comment of group = nobody, Join nobody and change to the www user group configured above
5) Change the nginx.conf file /etc/local/nginx/conf/nginx.conf
Remove the comment and replace #user = nobody user = www
Delete the comments of this code at location ~\.php ${...}, and replace $document_root
PHP Video Tutorial"
The above is the detailed content of How to install php in 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 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 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 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.

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.

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

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.
