Nginx series (4.nginx and php)
1. Download php
Download address: http://php.net/downloads.php
2. PHP dependency library
<code>yum install <span>-y</span> libxml2 libxml2<span>-devel</span> gd<span>-devel</span></code>
3. Compile php
1.php compilation parameter configuration
<code><span>.</span>/configure <span>--</span>prefix<span>=</span>/web/php <span>--</span><span>with</span><span>-config</span><span>-file</span><span>-path</span><span>=</span>/web/php/config <span>--</span><span>with</span><span>-gd</span><span>\</span><span>--</span>enable<span>-mbstring</span><span>--</span><span>with</span><span>-pdo</span><span>-mysql</span><span>--</span><span>with</span><span>-mysql</span><span>--</span>enable<span>-fpm</span></code>
Output the following content Then the configuration is successful
2. Compile php
<code><span>make</span> && <span>make</span> install</code>
Output the following content and the configuration is successful
4. Start php-fpm
1. Copy php-fpm to the php directory
<code>cp /home/download/php/sapi/fpm/php<span>-fpm</span> /web/php/bin/php<span>-fpm</span></code>
2. Copy the php configuration File to the config directory
<code>mkdir -p /web/php/config <span>cp</span> /home/download/php/php<span>.ini</span>-development /web/php/config/php<span>.ini</span><span>#生成环境下复制php.ini-production</span></code>
3. Copy the php-fpm configuration file to the config directory
<code><span>cp</span> /home/download/php/sapi/fpm/php-fpm<span>.conf</span> /web/php/config/</code>
4. Start php-fpm
<code><span>.</span>/php<span>-fpm</span><span>-y</span> /web/php/php<span>-fpm</span><span>.</span>conf</code>
5. Configure nginx and start nginx
1. Modify the nginx configuration file to support php
<code>location ~ \.php<span>$ </span>{ root /web/www; fastcgi_pass <span>127.0</span>.<span>0</span>.<span>1</span><span>:</span><span>9000</span>; fastcgi_index index.php; <span>include</span> fastcgi_params; fastcgi_param <span>SCRIPT_FILENAME</span><span>$document_root</span><span>$fastcgi_script_name</span>; fastcgi_param <span>SCRIPT_NAME</span><span>$fastcgi_script_name</span>; }</code>
2. Start the nginx service
<code>service nginx <span><span>start</span></span></code>
Output the following content and the configuration is successful
5. Detailed explanation of PHP compilation parameters
The meaning of the specific parameters can be viewed with ./configure –help.
The list is as follows (some parameters are not explained):
Specify the php installation directory
–prefix=/usr/local/php
Specify php.ini location
–with-config-file-path=/usr/local/php/etc
mysql installation directory, support for mysql
–with-mysql=/usr/local/mysql
mysqli extension technology can not only call MySQL stored procedures and process MySQL transactions, but also make accessing the database more stable.
–with-mysqli=/usr/local/mysql/bin/mysql_config
Integrate apache, the apxs function is to use the LoadModule instruction in mod_so to load the specified module into apache, requiring apache to open the SO module
–with-apxs2=/usr/local/apache/bin/apxs
Option directive –with-iconv-dir is used to specify the path of iconv in the system when compiling PHP, otherwise the default path will be scanned.
–with-iconv-dir=/usr/local
–with-freetype-dir turns on support for the freetype font library
–with-jpeg-dir turns on support for jpeg images
–with-png-dir turns on support for png images
–with-zlib-dir turns on support for the zlib library for http compression transmission
–with-libxml-dir turns on support for libxml2 library
–disable-rpath closes additional runtime files
–enable-bcmath turns on image resizing. This module is used when using zabbix monitoring
–enable-shmop –enable-sysvsem This allows your PHP system to handle related IPC functions.
–enable-inline-optimization Optimize threads
–with-curl Turn on curl browsing tool support
–with-curlwrappers Use curl tool to open url stream
–enable-mbregex
–enable-fpm This parameter is only available after applying the PHP-fpm patch. It is a startup program installed in CGI mode
–enable-mbstring multi-byte, string support
–with-mcrypt mcrypt algorithm extension
–with-mhash mhash algorithm extension
–with-gd turns on gd library support
–enable-gd-native-ttf supports TrueType string function library
–with-openssl openssl support, used when encrypting https transmission
–enable-pcntl FreeTDS needs to be used, it may be used to link mssql
–enable-sockets Turn on sockets support
–with-xmlrpc opens the c language of xml-rpc
–enable-zip Turn on support for zip
–enable-ftp Turn on ftp support
–with-bz2 Turn on support for bz2 files
–without-iconv turns off the iconv function and converts between character sets
–with-ttf turns on freetype1.* support, you don’t need to add it
–with-xsl turns on XSLT file support, extends the libXML2 library, and requires libxslt software
–with-gettext turns on gnu’s gettext support, which is used by the coding library
–with-pear turns on support for pear command, used for PHP extension
–enable-calendar Turn on the calendar extension function
–enable-exif image metadata support
–enable-magic-quotes Magic quote support
–disable-debug Turn off debug mode
–with-mime-magic=/usr/share/file/magic.mime Magic header file location
Parameters only used for CGI installation
–enable-fastCGI supports fastcgi mode to start PHP
–enable-force-CGI-redirect Start PHP in redirection mode
–with-ncurses is a dynamic library that supports ncurses screen drawing and text terminal-based graphical interaction functions
–with-gmp should support a specification
–enable-dbase Create DBA as a shared module
–with-pcre-dir=/usr/local/bin/pcre-config perl regular library installation location
--disable-dmalloc
–with-gdbm dba’s gdbm support
–enable-sigchild
–enable-sysvshm
–enable-zend-multibyte supports zend multibyte
–enable-wddx
–enable-soap
6. Reference address
1.php official installation guide: http://php.net/manual/zh/install.unix.nginx.php
The above has introduced the Nginx series (four.nginx and php), including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

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 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
