Home > Article > Backend Development > 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.