Use Nginx to build an efficient Moodle Learning Platform
------- Installation notes for Centos5.4 + Nginx.083 + Php5.32 + Mysql5.4
● Preparations
1. Install the yum Source
1. Replace all the yum packages found (some require-nodeps) (Steps 1 and 2 for redhatlinux)
Rpm-e-nodeps *. yum
2. download and install the following two yum packages from the MIIT Website:
Wget http://centos.ustc.edu.cn/centos/5.3/ OS /i386/CentOS/yum-3.2.19-18.el5.centos.noarch.rpm
Wget http://centos.ustc.edu.cn/centos/5.3/ OS /i386/CentOS/yum-metadata-parser-1.1.2-2.el5.i386.rpm
Rpm-ivh yum-metadata-parser-1.1.2-2.el5.i386.rpm
Rpm-ivh yum-3.2.8-9.el5.centos.1.noarch.rpm
3. Download the configuration file dedicated to HKUST and replace the original yum configuration file:
# Cd/etc/yum. repos. d/
# Wget http://centos.ustc.edu.cn/CentOS-Base.repo.5
# Mv CentOS-Base.repo.5 CentOS-Base.repo
4. Because the version number of the server address in the default configuration file is $ releasever, replace it with the actual version number, otherwise it is unable to connect to the server (the latest version can go to http://centos.ustc.edu.cn/centos/query), the current CentOS latest version is 5.5, So we modify the CentOS-Base.repo
# Vim CentOS-Base.repo.
#: 1, $ s/$ releasever/5.5/g: wq save and quit
Ii. Use yum to install the library required for upgrade
Yum-y install gcc-c ++ autoconf libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel zlib-devel glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses- devel curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn-devel openssl-devel openldap-devel nss_ldap openldap-clients openldap-servers libtool-ltdl-devel pcre-devel
● Install the MySQL database (you can download the latest version of MySQL at http://dev.mysql.com/downloads)
# Rpm-ivh MySQL-server-community-5.4.1-0.rhel5.i386.rpm
# Rpm-ivh MySQL-devel-community-5.4.1-0.rhel5.i386.rpm
# Rpm-ivh MySQL-client-community-5.4.1-0.rhel5.i386.rpm
● Compile and install PHP (FastCGI mode) using php-fpm Management
I. libraries used for PHP Compilation
1. Install libiconv.
# Wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
# Tar-xvf libiconv-1.13.1.tar.gz
# Cd libiconv-1.13.1
#./Configure -- prefix =/usr & make install
2. Install mhash.
# Yum install-y mhash-devel
3. Install mcrypt
# Yum install libmcrypt-devel
4. Compile and install libevent
# Wget http://www.monkey.org /~ Provos/libevent-1.4.13-stable.tar.gz
# Tar-xvf libevent-1.4.13-stable.tar.gz
#./Configure -- prefix =/usr & make install
[Do not install libevent using yum. For php-fpm, Libevent 1.4.12-stable or higher is recommended, and at least libevent 1.4.3-stable is required, therefore, php-fpm requires libevent 1.4.3 and later versions. Therefore, go to the libevent source code package of the most stable version on the libevent official website for compilation and installation]
2. Download and compile PHP (php-5.2.13 and php-5.3.2 compilation parameters are not the same)
◆ Use php-5.2.13
1. Download source code
# Wget http://www.php.net/get/php-5.2.13.tar.gz/from/a/mirror [php source code]
# Wget http://php-fpm.org/downloads/php-5.2.13-fpm-0.5.13.diff.gz "PHP-FPM patch package]
2. Unzip and install
# Tar-xvf php-5.2.13.tar.gz
# Gzip-cd php-5.2.13-fpm-0.5.13.diff.gz | patch-d php-5.2.13-p1 [patch php]
# Cd php-5.2.13
#. /Configure -- prefix =/usr/local/php -- with-config-file-path =/usr/local/php/etc -- with-mysql =/var/lib/mysql -- with-mysql =/usr/bin/mysql_config -- with-iconv-dir =/usr -- with-freetype-dir -- with-jpeg-dir -- with-png-dir --- 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 -sasl -- with-xmlrpc -- enable-zip -- enable-soap (1)
# Make ZEND_EXTRA_LIBS = '-liconv'
# Make install
◆ Use php-5.3.2
1. Download source code
# Wget http://cn.php.net/distributions/php-5.3.2.tar.bz2/* Get source code */
# Wget http://php-fpm.org/downloads/0.6/php-fpm-0.6 ~ 5.3.1.tar.gz/* php-fpm patch
# Tar-xvf php-5.3.2.tar.bz2
# Tar-zxvf php-fpm-0.6 ~ 5.3.1.tar.gz
# Php-fpm-0.6-5.3.1/generate-fpm-patch
# Cd php-5.3.2
# Patch-p1 <../fpm. patch
** An error will be prompted when you reinstall autoconf2.5.9to translate php-fpm. install autoconf-2.13.tar.gz.
Uninstall autoconf2.59 and install autoconf2.13
# Rpm-e autoconf2.59
# Wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.13.tar.gz
#./Buildconf -- force
#. /Configure -- prefix =/usr/local/php -- with-config-file-path =/usr/local/php/etc -- with-mysql =/var/lib/mysql -- with-mysql =/usr/bin/mysql_config -- with-iconv-dir =/usr -- with-freetype-dir -- with-jpeg-dir -- with-png-dir --- 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 -- with-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 -sasl -- with-xmlrpc -- enable-zip -- enable-soap -- with-libevent = shared (or -- with-libevent =/usr/lib, use this parameter when the shared compilation parameter is invalid)
# Make ZEND_EXTRA_LIBS = '-liconv'
Generating phar. php
Generating phar. phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
Pharcommand. inc
Invertedregexiterator. inc
Directorygraphiterator. inc
Clicommand. inc
Directorytreeiterator. inc
Phar. inc
Build complete.
Don't forget to run 'make test '.
# Make install
Error message: PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled
Solution: download an unwrapped pearnet installation package from http://pear.php.net/go-pearand store it in the "go-pear.php" directory.
Run: php go-pear.php
Notice: Following unknown configure options were used:
•-Enable-fastcgi
•-Enable-force-cgi-redirect
•-Enable-discard-path
Php 5.3.0 finds that fastcgi is already supported by default, and you do not need to write configuration parameters any more. If you write the parameter, the above error message is displayed, which can be ignored.
3. Compile and install the PHP5 extension module
1. Compile and install the memcache-2.2.5.tgz
# Wget http://pecl.php.net/get/memcache-2.2.5.tgz
# Tar-xvf 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
2. Compile and install the eaccelerator-0.9.6-rc1.tar.bz2
# Wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2
# Tar-xvf eaccelerator-0.9.6.1.tar.bz2
# Cd eaccelerator-0.9.6.1
#/Usr/local/php/bin/phpiz
#./Configure -- with-php-config =/usr/local/php/bin/php-config
3. Compile and install the PDO_MYSQL-1.0.2
# Wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
#/Usr/local/php/bin/phpiz
#./Configure -- with-php-config =/usr/local/php/bin/php-config -- with-pdo-mysql =/usr & make install
Compile and install ImageMagick
# Wget ftp://ftp.kddlabs.co.jp/graphics/ImageMagick/ImageMagick-6.6.3-0.tar.gz
#./Configure
# Make & make install
4. Compile and install imagick
# Wget http://pecl.php.net/get/imagick-3.0.0RC1.tgz
# Tar-xf imagick3.0.0RC1. tgz
# Cd imagick3.0.0RC1
#/Usr/local/php/bin/phpize
#./Configure -- with-php-config =/usr/local/php/bin/php-config & make install
5. Compile and install mysqli
# Cd php-5.3.2/ext/mysqli
#./Configure -- with-php-config =/usr/local/php/bin/php-config
# Make & make in
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/" [The no-debug-non-zts-20060613 name may be different]
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
★PHP enable short tag support
Change short_open_tag = off in php. ini to short_open_tag = On.
★Modify the size of the uploaded file
Open php. ini and modify the following content to the following values:
Upload_max_filesize = 20 M; (2 M by default)
Max_execution_time = 300; (default value: 30 [seconds])
Post_max_size = 12 M; (8 M by default)
● Install Nginx0.8.35
Download Nginx0.8.35
# Wget http://nginx.org/download/nginx-0.8.35.tar.gz
1. Install the pcre Library
Method 1 download and install ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre with source code
Errors may occur.
Make error:
"Make-f objs/Makefile
Make [1]: Entering directory '/home/nginx-0.7.65'
Cd/usr/local/pcre \
& If [-f Makefile]; then make distclean; fi \ & CC = "gcc" CFLAGS = ""\
./Configure -- disable-shared
/Bin/sh: line 2:./configure: No file or directory
Make [1]: *** [/usr/local/pcre/Makefile] Error 127
Make [1]: Leaving directory '/home/nginx-0.7.65'
Make: *** [build] Error 2"
Solution: uninstall the manually installed pcre, make uninstall, and then let the machine install yum install pcre-devel.
Method 2: yum install pcre-devel
Ii. Install nginx
./Configure -- prefix =/usr/local/nginx -- with-http_stub_status_module -- with-http_ssl_module
(You do not need to use -- with-pcre =/usr/local/lib)
/* -- The with-http_stub_status_module is used to enable nginx's NginxStatus function to monitor the current state of Nginx */
Nginx error "413 Request Entity Too Large"
If the error "413 Request Entity Too Large" is reported during upload, add client_max_body_size 8 m in nginx. conf and add the upload size limit.
Solution: Open the nginx main configuration file nginx. conf, locate the http {} segment, and add
Client_max_body_size 20 m;
In Ubuntu, the file is stored in/etc/nginx. conf.