CentOS Nginx PHP MySQL Memcached 安装 配置 优化
http://www.phpplay.com/thread-118293-1-1.html
按照版本
Nginx0.8.52PHP5.3.3
MySQL5.5.6Memcached
一、安装centos
这个比较容易,安装过程可以在如下几个帖子中找到。
http://www.phpplay.com/thread-118283-1-1.html
http://www.phpplay.com/thread-118286-1-1.html
http://www.phpplay.com/thread-118287-1-1.html
二、准备篇
2.1 修改CentOS的yum源- vi /etc/yum.repos.d/CentOS-Base.repo
为了加快速度,我们采用网易的源地址,文件内容参照以下修改:变颜色的为需要修改的地方
1.#CentOS-Base.repo
2.#
3.#ThisfileusesanewmirrorlistsystemdevelopedbyLanceDavisforCentOS.
4.#ThemirrorsystemusestheconnectingIPaddressoftheclientandthe
5.#updatestatusofeachmirrortopickmirrorsthatareupdatedtoand
6.#geographicallyclosetotheclient.YoushouldusethisforCentOSupdates
7.#unlessyouaremanuallypickingothermirrors.
8.#
9.#Ifthemirrorlist=doesnotworkforyou,asafallbackyoucantrythe
10.#remarkedoutbaseurl=lineinstead.
11.#
12.#
13.[base]
14.name=CentOS-$releasever-Base
15.#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
16.#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
17.baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
18.gpgcheck=1
19.gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
20.#releasedupdates
21.[updates]
22.name=CentOS-$releasever-Updates
23.#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
24.#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
25.baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
26.gpgcheck=1
27.gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
28.#packagesused/producedinthebuildbutnotreleased
29.[addons]
vi/etc/yum.repos.d/CentOS-Base.repo
30.name=CentOS-$releasever-Addons
31.#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
32.#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
33.baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/
34.gpgcheck=1
35.gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
36.#additionalpackagesthatmaybeuseful
37.[extras]
38.name=CentOS-$releasever-Extras
39.#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
40.#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
41.baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
42.gpgcheck=1
43.gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
44.#additionalpackagesthatextendfunctionalityofexistingpackages
45.[centosplus]
46.name=CentOS-$releasever-Plus
47.#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
48.#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
49.baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
50.gpgcheck=1
51.enabled=0
52.gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
2.2更新yum- yum -y update
2.3使用yum更新所需要的程序库
- sudo -s
安装libevent,memcached需要
- yum -y install libevent libevent-devel
三、下载所需文件说明:使用wget将下载的程序统一放到路径 /usr/src/ 下面。原文地址已经有些过期,这里更新为最新的。
- cd /usr/src/
- wgethttp://nginx.org/download/nginx-0.8.52.tar.gz
- wgethttp://cn.php.net/get/php-5.3.3.tar.gz/from/this/mirror
- #wgethttp://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.6-rc.tar.gz/from/http://mysql.he.net/
- wgethttp://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.2-m2-linux-i686-glibc23.tar.gz
- wgethttp://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
- wgethttp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
- wgethttp://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz?use_mirror=ncu
- wgethttp://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz?use_mirror=ncu
- wgethttp://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz?use_mirror=ncu
- wgethttp://downloads.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.tar.gz?use_mirror=ncu
- #wgethttp://downloads.sourceforge.net/project/imagemagick/ImageMagick/00-6.6.5/ImageMagick-6.6.5-0.tar.gz?use_mirror=ncu
- wgethttp://sourceforge.net/projects/imagemagick/files/6.7.7-sources/ImageMagick-6.7.7-5.tar.gz/download
- wgethttp://pecl.php.net/get/APC-3.1.4.tgz
- wgethttp://pecl.php.net/get/memcache-2.2.6.tg
- wget http://pecl.php.net/get/imagick-3.0.1RC2.tgz
三、安装篇1. 安装libiconv
- cd /usr/src/</div><div>tar zxvf libiconv-1.13.1.tar.gz
- cdlibiconv-1.13.1/
- ./configure--prefix=/usr/local
- make
- makeinstall
- cd ../
2. 修改动态链接载入的目录查找文件
- vi /etc/ld.so.conf
在文件最后添加一行内容/usr/local/lib,然后运行以下命令
- /sbin/ldconfig
3. 安装libmcrypt
- tar zxvf libmcrypt-2.5.8.tar.gz
- cdlibmcrypt-2.5.8/
- ./configure
- make
- makeinstall
- /sbin/ldconfig
- cdlibltdl/
- ./configure--enable-ltdl-install
- make
- makeinstall
- cd../../
4. 安装mhash
- tar zxvf mhash-0.9.9.9.tar.gz
- cdmhash-0.9.9.9/
- ./configure
- make
- makeinstall
- cd../
- ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
5. 安装mcrypt
- tar zxvf mcrypt-2.6.8.tar.gz
- cdmcrypt-2.6.8/
- /sbin/ldconfig
- ./configure
- make
- makeinstall
- cd../
6. 安装memcached
- tar xvf memcached-1.4.5.tar.gz
- cdmemcached-1.4.5
- ./configure--prefix=/usr/local/memcached
- make
- makeinstall
- cd../
7. 安装pcre
- tar zxvf pcre-8.10.tar.gz
- cdpcre-8.10/
- ./configure
- make
- makeinstall
- cd../
8. 安装Nginx
- /usr/sbin/groupadd www
- /usr/sbin/useradd-gwwwwww
- tarzxvfnginx-0.8.52.tar.gz
- cdnginx-0.8.52/
- ./configure--user=www--group=www\
- --prefix=/usr/local/nginx\
- --with-http_stub_status_module\
- --with-http_ssl_module
- make
- makeinstall
- cd../
9. 安装PHP
- tar zxvf php-5.3.3.tar.gz
- cdphp-5.3.3
- ./configure--prefix=/usr/local/php\
- --with-config-file-path=/usr/local/php/etc\
- --with-curl--with-curlwrappers\
- --with-freetype-dir\
- --with-jpeg-dir--with-png-dir\
- --with-gd--enable-gd-native-ttf\
- --with-iconv-dir=/usr/local/libiconv\
- --with-libxml-dir=/usr/local\
- --with-mhash--with-mcrypt\
- --with-mysql=mysqlnd--with-mysqli=mysqlnd\
- --with-openssl\
- --with-xmlrpc\
- --with-zlib\
- --disable-debug--disable-rpath\
- --enable-bcmath\
- --enable-fpm\
- --enable-inline-optimization\
- --enable-mbregex\
- --enable-mbstring\
- --enable-pcntl\
- --enable-safe-mode\
- --enable-shmop\
- --enable-soap\
- --enable-sockets\
- --enable-sysvsem\
- --enable-xml\
- --enable-zip\
- --with-libdir=lib64\←64位操作系统需要添加此项,否则去除此项
- --without-pear
- makeZEND_EXTRA_LIBS='-liconv'
- makeinstall
- cp./php.ini-production/usr/local/php/etc/php.ini
- cd../
10. 安装ImageMagick
- tar zxvf ImageMagick-6.6.5-0.tar.gz
- cdImageMagick-6.6.5-0/
- ./configure
- make
- makeinstall
- cd ../
11. 安装PHP扩展imagick
- tar zxvf imagick-3.0.1RC2.tgz
- cdimagick-3.0.1RC2/
- /usr/local/php/bin/phpize
- ./configure--with-php-config=/usr/local/php/bin/php-config
- make
- makeinstall
- cd ../
12. 安装PHP扩展memcache
- tar zxvf memcache-2.2.6.tgz
- cdmemcache-2.2.6/
- /usr/local/php/bin/phpize
- ./configure--with-php-config=/usr/local/php/bin/php-config
- make
- makeinstall
- cd ../
13. 安装PHP扩展APC
- tar zxvf APC-3.1.4.tgz
- cdAPC-3.1.4/
- /usr/local/php/bin/phpize
- ./configure--with-php-config=/usr/local/php/bin/php-config
- make
- makeinstall
- cd ../
14. 安装MySQL
- /usr/sbin/groupadd mysql
- /usr/sbin/useradd-gmysqlmysql
- tarxvfmysql-5.5.6-rc.tar.gz
- cdmysql-5.5.6-rc/
- ./configure--prefix=/usr/local/mysql/\
- --with-unix-socket-path=/tmp/mysql.sock\
- --with-big-tables\
- --with-charset=utf8\
- --with-collation=utf8_general_ci\
- --with-extra-charsets=gbk,gb2312,utf8\
- --with-client-ldflags=-all-static\
- --with-mysqld-ldflags=-all-static\
- --with-plugins=partition,innobase,myisammrg\
- --with-pthread\
- --with-readline\
- --without-debug\
- --without-isam\
- --enable-assembler\
- --enable-local-infile\
- --enable-thread-safe-client
- make
- makeinstall
- chmod+w/usr/local/mysql
- chown-Rmysql:mysql/usr/local/mysql
- cd ../
全部安装的过程已经结束,下一篇结束配置。