3. Compile and install PHP (FastCGI Mode)
Tar-zxvf php-5.2.10.tar.gz
// The following step for the php-5.3.3 version does not need to be executed, directly compile it
Gzip-CD php-5.2.10-fpm-0.5.11.diff.gz | patch-D php-5.2.10-p1
CD php-5.2.10/
. /Configure -- prefix =/usr/local/PHP -- With-config-file-Path =/usr/local/PHP/etc -- With-mysql =/usr/local/MySQL -- with-mysqli =/usr/local/MySQL/bin/mysql_config -- With-iconv-Dir =/usr/local -- With-FreeType-dir -- With-JPEG-dir --- PNG-dir -- With-zlib -- With-libxml-Dir =/usr
-- Enable-XML -- disable-rpath -- enable-discard-path -- enable-safe-mode -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline-optimization -- -curl -- With-curlwrappers -- enable-mbregex -- enable-FastCGI -- enable-FPM -- enable-force-CGI-redirect -- enable-mbstring
-- With-mcrypt -- With-Gd -- enable-Gd-native-TTF -- With-OpenSSL -- With-mhash -- enable-pcntl -- enable-sockets -- With-XMLRPC -- enable-zip -- enable-FTP
Make zend_extra_libs = '-liconv'
Make install
Cp php. ini-Dist/usr/local/PHP/etc/PHP. ini
CD ../
Http://pear.php.net/go-pear |/usr/local/PHP/bin/PHP
4. Compile and install the PhP5 extension module --------------------------------- memcache ---------------------------------------
Tar-zxvf memcache-2.2.5.tgz
CD memcache-2.2.5/
/Usr/local/PHP/bin/phpize
./Configure -- With-PHP-Config =/usr/local/PHP/bin/PHP-config
Make
Make install
CD ../
----------------------------------- Eaccelerator ------------------------------------
Tar jxvf eaccelerator-0.9.5.3.tar.bz2
CD eaccelerator-0.9.5.3/
/Usr/local/PHP/bin/phpize
./Configure -- enable-eaccelerator = shared -- With-PHP-Config =/usr/local/PHP/bin/PHP-config
Make
Make install
CD ../
----------------------------------- Pdo_mysql ------------------------------------
Tar zxvf PDO_MYSQL-1.0.2.tgz
CD PDO_MYSQL-1.0.2/
/Usr/local/PHP/bin/phpize
./Configure -- With-PHP-Config =/usr/local/PHP/bin/PHP-config -- With-PDO-mysql =/usr/local/MySQL
Make
Make install
CD ../
----------------------------------- Pdo_mysql ------------------------------------
Tar zxvf imagemagick.tar.gz
CD ImageMagick-6.5.1-2/
./Configure
Make
Make install
CD ../
----------------------------------- Imagick ------------------------------------
Tar zxvf imagick-2.2.2.tgz
CD imagick-2.2.2/
/Usr/local/webserver/PHP/bin/phpize
./Configure -- With-PHP-Config =/usr/local/PHP/bin/PHP-config
Make
Make install
CD ../
5. Modify the php. ini file
Manual modification:
Find extension_dir = "./" in/usr/local/webserver/PHP/etc/PHP. ini "./"
Change to extension_dir = "/usr/local/webserver/PHP/lib/PHP/extensions/no-debug-non-zts-20060613 /"
Add the following lines after this line, and then save:
Extension = "memcache. So"
Extension = "pdo_mysql.so"
Extension = "imagick. So"
Find output_buffering = off
Change to output_buffering = on
Automatic modification:If manual modification is troublesome, You can execute the following shell command to automatically modify the php. ini file:
Sed-I's # extension_dir = ". /"# extension_dir ="/usr/local/PHP/lib/PHP/extensions/no-debug-non-zts-20060613/"\ nextension =" memcache. so "\ nextension =" pdo_mysql.so "\ nextension =" imagick. so "\ n # '/usr/local/PHP/etc/PHP. ini
Sed-I's # output_buffering = off # output_buffering = on # '/usr/local/PHP/etc/PHP. ini
Sed-I "s #; always_populate_raw_post_data = on # G"/usr/local/PHP/etc/PHP. ini
6. Configure eaccelerator to accelerate PHP: mkdir-P/usr/local/eaccelerator_cache
Cat>/usr/local/PHP/etc/PHP. ini <EOF
[Eaccelerator]
Zend_extension = "/usr/local/PHP/lib/PHP/extensions/no-debug-non-zts-20060613/eaccelerator. So"
Eaccelerator. shm_size = "64 ″
Eaccelerator. cache_dir = "/usr/local/eaccelerator_cache"
Eaccelerator. Enable = "1 ″
Eaccelerator. optimizer = "1 ″
Eaccelerator. check_mtime = "1 ″
Eaccelerator. DEBUG = "0 ″
Eaccelerator. Filter = ""
Eaccelerator. shm_max = "0 ″
Eaccelerator. shm_ttl = "3600 ″
Eaccelerator. shm_prune_period = "3600 ″
Eaccelerator. shm_only = "0 ″
Eaccelerator. Compress = "1 ″
Eaccelerator. compress_level = "9 ″
Eaccelerator. Keys = "disk_only"
Eaccelerator. Sessions = "disk_only"
Eaccelerator. content = "disk_only"
EOF
7. Create WWW users and groups and directories for the VM:/usr/sbin/groupadd WWW
/Usr/sbin/useradd-G WWW
Mkdir-P/web/WWW
Chmod + w/web/WWW
Chown-r www: www/web/WWW
Mkdir-P/www/html/www.lnmp.com
Chmod + w/www/html/www.lnmp.com
Chown-r www: www/html/www.lnmp.com
8. Create a PHP-FPM configuration file (PHP-FPM is a FastCGI management patch for PHP. You can smoothly change the php. ini configuration without restarting PHP-CGI ):
Create a php-fpm.conf file in the/usr/local/webserver/PHP/etc/directory:
Rm-F/usr/local/PHP/etc/php-fpm.conf
6/usr/local/PHP/etc/php-fpm.conf
Enter the following content (if you install nginx + PHP for program debugging, change <value name = "display_errors"> 0 </value> to <value name = "display_errors"> 1 </value> to display the PHP error message. Otherwise, nginx will report a blank error page in the status of 500 ):
<? XML version = "1.0"?>
<Configuration>
All relative paths in this config are relative to PhP's install prefix
<Section name = "global_options">
PID File
<Value name = "pid_file">/usr/local/PHP/logs/php-fpm.pid </value>
Error Log File
<Value name = "error_log">/usr/local/PHP/logs/php-fpm.log </value>
Log Level
<Value name = "log_level"> notice </value>
When this amount of PHP processes exited with SIGSEGV or sigbus...
<Value name = "emergency_restart_threshold"> 10 </value>
... In a less than this interval of time, a graceful restart will be initiated.
Useful to work around und accidental curruptions in accelerator's shared memory.
<Value name = "emergency_restart_interval"> 1 m </value>
Time limit on waiting child's reaction on signals from Master
<Value name = "process_control_timeout"> 5 S </value>
Set to 'no' to debug FPM
<Value name = "daemonize"> Yes </value>
</Section>
<Workers>
<Section name = "pool">
Name of pool. Used in logs and stats.
<Value name = "name"> default </value>
Address to accept FastCGI requests on.
Valid syntax is 'IP. Ad. Re. SS: port' or just 'Port' or '/path/to/Unix/socket'
<Value name = "listen_address"> 127.0.0.1: 9000 </value>
<Value name = "listen_options">
Set listen (2) Backlog
<Value name = "backlog">-1 </value>
Set permissions for UNIX socket, if one used.
In Linux read/write permissions must be set in order to allow connections from web server.
Extends BSD-derrived systems allow connections regardless of permissions.
<Value name = "owner"> </value>