Redhat + Nginx0.8.46 + PHP5.2.14 + MySQL5.1.46 build LNMP (X64) Platform

Source: Internet
Author: User
RedHat + Nginx0.8.46 + PHP5.2.14 + MySQL5.1.46 build LNMP (X64) platform read: CentOS5.5 build LNMP refer to idea (can go to the official website to download): mhash-0.9.9.9.tar.gzmysql-5.1.46-linux-i686-glibc23

RedHat + Nginx0.8.46 + PHP5.2.14 + MySQL5.1.46 build LNMP (X64) Platform

See http://www.linuxidc.com/Linux/2012-07/66073.htm for LNMP construction on CentOS 5.5

1. Required software packages (you can download them on the official website ):
Mhash-0.9.9.9.tar.gz
Mysql-5.1.46-linux-i686-glibc23.tar.gz
Eaccelerator-0.9.6.1.tar.bz2
Nginx-0.8.46.tar.gz
ImageMagick.tar.gz
Imagick-2.3.0.tgz
Pcre-8.10.tar.gz
Libiconv-1.13.1.tar.gz
PDO_MYSQL-1.0.2.tgz
Libmcrypt-2.5.8.tar.gz
Memcache-2.2.5.tgz
Php-5.2.14.tar.bz2
Php-5.2.14-fpm-0.5.14.diff.gz
Mcrypt-2.6.8.tar.gz

Ii. install PHP 5.2.14 (FastCGI Mode)
Yum groupinstall "Development Tools" "Development Libraries"
1. Compile and install the support libraries required for PHP 5.2.14.
Tar zxvf libiconv-1.13.1.tar.gz
Cd libiconv-1.13.1/
./Configure -- prefix =/usr/local
Make
Make install
Cd ../

Tar zxvf libmcrypt-2.5.8.tar.gz
Cd libmcrypt-2.5.8/
./Configure
Make
Make install
/Sbin/ldconfig
Cd libltdl/
./Configure -- enable-ltdl-install
Make
Make install
Cd ../../

Tar zxvf mhash-0.9.9.9.tar.gz
Cd mhash-0.9.9.9/
./Configure
Make
Make install

Cd ../
Ln-s/usr/local/lib/libmcrypt. la/usr/lib/libmcrypt. la
Ln-s/usr/local/lib/libmcrypt. so/usr/lib/libmcrypt. so
Ln-s/usr/local/lib/libmcrypt. so.4/usr/lib/libmcrypt. so.4
Ln-s/usr/local/lib/libmcrypt. so.4.4.8/usr/lib/libmcrypt. so.4.4.8
Ln-s/usr/local/lib/libmhash. a/usr/lib/libmhash.
Ln-s/usr/local/lib/libmhash. la/usr/lib/libmhash. la
Ln-s/usr/local/lib/libmhash. so/usr/lib/libmhash. so
Ln-s/usr/local/lib/libmhash. so.2/usr/lib/libmhash. so.2
Ln-s/usr/local/lib/libmhash. so.2.0.1/usr/lib/libmhash. so.2.0.1
Ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config

Tar zxvf mcrypt-2.6.8.tar.gz
Cd mcrypt-2.6.8/
/Sbin/ldconfig
./Configure
Make
Make install
Cd ../
2. Compile and install PHP (FastCGI Mode)
Tar zxvf php-5.2.14.tar.gz
Gzip-cd php-5.2.14-fpm-0.5.14.diff.gz | patch-d php-5.2.14-p1
Cd php-5.2.14/
Yum install libjpeg-devel libpng-devel freetype-devel-y
./Configure \
-- Prefix =/usr/local/php \
-- With-config-file-path =/usr/local/php/etc \
-- With-mysql =/usr/local/mysql \
-- With -- mysqli =/usr/local/mysql /\
-- With-iconv-dir =/usr/local \
-- With-freetype-dir \
-- With-jpeg-dir \
-- With-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 \
-- With-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-ldap \
-- With-ldap-sasl \
-- With-xmlrpc \
-- Enable-zip \
-- Enable-soap
Make ZEND_EXTRA_LIBS = '-liconv'
Make install
Cp php. ini-dist/usr/local/php/etc/php. ini
Cd ../
3. Compile and install the PHP5 extension module
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 ../

Tar jxvf eaccelerator-0.9.6.1.tar.bz2
Cd eaccelerator-0.9.6.1/
/Usr/local/php/bin/phpize
./Configure -- enable-eaccelerator = shared -- with-php-config =/usr/local/php/bin/php-config
Make
Make install
Cd ../

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

Tar zxvf ImageMagick.tar.gz
Cd ImageMagick-6.6.5-8/
./Configure
Make
Make install
Cd ../

Tar zxvf imagick-2.3.0.tgz
Cd imagick-2.3.0/
/Usr/local/php/bin/phpize
./Configure -- with-php-config =/usr/local/php/bin/php-config
Make
Make install
Cd ../

4. Modify the php. ini file
Manually modify: Find extension_dir = "./" in/usr/local/php/etc/php. ini "./"
Change to extension_dir = "/usr/local/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
Search again; cgi. fix_pathinfo = 0
Modify it to cgi. fix_pathinfo = 0, that is, cancel the annotation and make it take effect. This prevents the Nginx file type error Parsing Vulnerability.
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/webserver/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
Sed-I "s #; cgi. fix_pathinfo = 0 # cgi. fix_pathinfo = 0 # g"/usr/local/php/etc/php. ini
6. Configure eAccelerator to accelerate PHP:
Mkdir-p/usr/local/eaccelerator_cache
Vi/usr/local/php/etc/php. ini
Press shift + g to jump to the end of the configuration file, and add the following configuration information:

[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"
7. Create www users and groups, as well as directories for linux.linuxidc.com and www.linuxidc.com virtual hosts:
/Usr/sbin/groupadd www
/Usr/sbin/useradd-g www
Mkdir-p/data0/htdocs/linux
Chmod + w/data0/htdocs/linux
Chown-R www: www/data0/htdocs/linux
Mkdir-p/data0/htdocs/www
Chmod + w/data0/htdocs/www
Chown-R www: www/data0/htdocs/www
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/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 0 Change 1 To display the PHP error message. Otherwise, Nginx reports a blank error page in the 500 status ):


All relative paths in this config are relative to php's install prefix


Pid file
/Usr/local/php/logs/php-fpm.pid
Error log file
/Usr/local/php/logs/php-fpm.log
Log level
Notice
When this amount of php processes exited with SIGSEGV or SIGBUS...
10
... 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.
1 m
Time limit on waiting child's reaction on signals from master
5S
Set to 'no' to debug fpm
Yes



Name of pool. Used in logs and stats.
Default
Address to accept fastcgi requests on.
Valid syntax is 'IP. ad. re. ss: port' or just 'Port' or '/path/to/unix/socket'
127.0.0.1: 9000

Set listen (2) backlog
-1
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.


0666

Additional php. ini defines, specific to this pool of workers.

/Usr/sbin/sendmail-t-I
0

Unix user of processes
Www
Unix group of processes
Www
Process manager settings

Sets style of controling worker process count.
Valid values are 'static 'and 'apache-like'
Static
Sets the limit on the number of simultaneous requests that will be served.
Equivalent to Apache MaxClients directive.
Equivalent to PHP_FCGI_CHILDREN environment in original php. fcgi
Used with any pm_style.
128
Settings group for 'apache-like' pm style

Sets the number of server processes created on startup.
Used only when 'apache-like 'pm_style is selected
20
Sets the desired minimum number of idle server processes.
Used only when 'apache-like 'pm_style is selected
5
Sets the desired maximum number of idle server processes.
Used only when 'apache-like 'pm_style is selected
35


The timeout (in seconds) for serving a single request after which the worker process will be terminated
Shocould be used when 'max _ execution_time 'ini option does not stop script execution for some reason
'0s' means 'off'
0 s
The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow. log file
'0s' means 'off'
0 s
The log file for slow requests
Logs/slow. log
Set open file desc rlimit
65535
Set max core size rlimit
0
Chroot to this directory at the start, absolute path

Chdir to this directory at the start, absolute path

Redirect workers 'stdout and stderr into main error log.
If not set, they will be redirected to/dev/null, according to FastCGI specs
Yes
How much requests each process shocould execute before respawn.
Useful to work around memory leaks in 3rd party libraries.
For endless request processing please specify 0
Equivalent to PHP_FCGI_MAX_REQUESTS
1024
Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.
Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php. fcgi (5.2.2 +)
Makes sense only with AF_INET listening socket.
127.0.0.1
Pass environment variables like LD_LIBRARY_PATH
All $ VARIABLEs are taken from current environment

$ HOSTNAME
/Usr/local/bin:/usr/bin:/bin
/Tmp
/Tmp
/Tmp
$ OSTYPE
$ MACHTYPE
2




9. Start the php-cgi process and listen to port 9000 of 127.0.0.1. The number of processes is 128 (if the server memory is smaller than 3 GB, only 64 processes can be enabled). The user is www:
Ulimit-SHn 65535
/Usr/local/php/sbin/php-fpm start
Note:/usr/local/webserver/php/sbin/php-fpm has other parameters, including: start | stop | quit | restart | reload | logrotate, modify php. after ini, do not restart php-cgi and reload the configuration file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.