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源
  1. 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
  1. yum -y update
复制代码

2.3使用yum更新所需要的程序库

  1. sudo -s
复制代码

安装libevent,memcached需要

  1. yum -y install libevent libevent-devel
复制代码

三、下载所需文件说明:使用wget将下载的程序统一放到路径 /usr/src/ 下面。原文地址已经有些过期,这里更新为最新的。

  1. cd /usr/src/
  2. wgethttp://nginx.org/download/nginx-0.8.52.tar.gz
  3. wgethttp://cn.php.net/get/php-5.3.3.tar.gz/from/this/mirror
  4. #wgethttp://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.6-rc.tar.gz/from/http://mysql.he.net/
  5. wgethttp://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.2-m2-linux-i686-glibc23.tar.gz
  6. wgethttp://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
  7. wgethttp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
  8. wgethttp://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz?use_mirror=ncu
  9. wgethttp://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz?use_mirror=ncu
  10. wgethttp://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz?use_mirror=ncu
  11. wgethttp://downloads.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.tar.gz?use_mirror=ncu
  12. #wgethttp://downloads.sourceforge.net/project/imagemagick/ImageMagick/00-6.6.5/ImageMagick-6.6.5-0.tar.gz?use_mirror=ncu
  13. wgethttp://sourceforge.net/projects/imagemagick/files/6.7.7-sources/ImageMagick-6.7.7-5.tar.gz/download
  14. wgethttp://pecl.php.net/get/APC-3.1.4.tgz
  15. wgethttp://pecl.php.net/get/memcache-2.2.6.tg
  16. wget http://pecl.php.net/get/imagick-3.0.1RC2.tgz
复制代码

三、安装篇1. 安装libiconv

  1. cd /usr/src/</div><div>tar zxvf libiconv-1.13.1.tar.gz
  2. cdlibiconv-1.13.1/
  3. ./configure--prefix=/usr/local
  4. make
  5. makeinstall
  6. cd ../
复制代码

2. 修改动态链接载入的目录查找文件

  1. vi /etc/ld.so.conf
复制代码

在文件最后添加一行内容/usr/local/lib,然后运行以下命令

  1. /sbin/ldconfig
复制代码

3. 安装libmcrypt

  1. tar zxvf libmcrypt-2.5.8.tar.gz
  2. cdlibmcrypt-2.5.8/
  3. ./configure
  4. make
  5. makeinstall
  6. /sbin/ldconfig
  7. cdlibltdl/
  8. ./configure--enable-ltdl-install
  9. make
  10. makeinstall
  11. cd../../
复制代码

4. 安装mhash

  1. tar zxvf mhash-0.9.9.9.tar.gz
  2. cdmhash-0.9.9.9/
  3. ./configure
  4. make
  5. makeinstall
  6. cd../
  7. ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
复制代码

5. 安装mcrypt

  1. tar zxvf mcrypt-2.6.8.tar.gz
  2. cdmcrypt-2.6.8/
  3. /sbin/ldconfig
  4. ./configure
  5. make
  6. makeinstall
  7. cd../
复制代码

6. 安装memcached

  1. tar xvf memcached-1.4.5.tar.gz
  2. cdmemcached-1.4.5
  3. ./configure--prefix=/usr/local/memcached
  4. make
  5. makeinstall
  6. cd../
复制代码

7. 安装pcre

  1. tar zxvf pcre-8.10.tar.gz
  2. cdpcre-8.10/
  3. ./configure
  4. make
  5. makeinstall
  6. cd../
复制代码

8. 安装Nginx

  1. /usr/sbin/groupadd www
  2. /usr/sbin/useradd-gwwwwww
  3. tarzxvfnginx-0.8.52.tar.gz
  4. cdnginx-0.8.52/
  5. ./configure--user=www--group=www\
  6. --prefix=/usr/local/nginx\
  7. --with-http_stub_status_module\
  8. --with-http_ssl_module
  9. make
  10. makeinstall
  11. cd../
复制代码

9. 安装PHP

  1. tar zxvf php-5.3.3.tar.gz
  2. cdphp-5.3.3
  3. ./configure--prefix=/usr/local/php\
  4. --with-config-file-path=/usr/local/php/etc\
  5. --with-curl--with-curlwrappers\
  6. --with-freetype-dir\
  7. --with-jpeg-dir--with-png-dir\
  8. --with-gd--enable-gd-native-ttf\
  9. --with-iconv-dir=/usr/local/libiconv\
  10. --with-libxml-dir=/usr/local\
  11. --with-mhash--with-mcrypt\
  12. --with-mysql=mysqlnd--with-mysqli=mysqlnd\
  13. --with-openssl\
  14. --with-xmlrpc\
  15. --with-zlib\
  16. --disable-debug--disable-rpath\
  17. --enable-bcmath\
  18. --enable-fpm\
  19. --enable-inline-optimization\
  20. --enable-mbregex\
  21. --enable-mbstring\
  22. --enable-pcntl\
  23. --enable-safe-mode\
  24. --enable-shmop\
  25. --enable-soap\
  26. --enable-sockets\
  27. --enable-sysvsem\
  28. --enable-xml\
  29. --enable-zip\
  30. --with-libdir=lib64\←64位操作系统需要添加此项,否则去除此项
  31. --without-pear
  32. makeZEND_EXTRA_LIBS='-liconv'
  33. makeinstall
  34. cp./php.ini-production/usr/local/php/etc/php.ini
  35. cd../
复制代码

10. 安装ImageMagick

  1. tar zxvf ImageMagick-6.6.5-0.tar.gz
  2. cdImageMagick-6.6.5-0/
  3. ./configure
  4. make
  5. makeinstall
  6. cd ../
复制代码

11. 安装PHP扩展imagick

  1. tar zxvf imagick-3.0.1RC2.tgz
  2. cdimagick-3.0.1RC2/
  3. /usr/local/php/bin/phpize
  4. ./configure--with-php-config=/usr/local/php/bin/php-config
  5. make
  6. makeinstall
  7. cd ../
复制代码

12. 安装PHP扩展memcache

  1. tar zxvf memcache-2.2.6.tgz
  2. cdmemcache-2.2.6/
  3. /usr/local/php/bin/phpize
  4. ./configure--with-php-config=/usr/local/php/bin/php-config
  5. make
  6. makeinstall
  7. cd ../
复制代码

13. 安装PHP扩展APC

  1. tar zxvf APC-3.1.4.tgz
  2. cdAPC-3.1.4/
  3. /usr/local/php/bin/phpize
  4. ./configure--with-php-config=/usr/local/php/bin/php-config
  5. make
  6. makeinstall
  7. cd ../
复制代码

14. 安装MySQL

  1. /usr/sbin/groupadd mysql
  2. /usr/sbin/useradd-gmysqlmysql
  3. tarxvfmysql-5.5.6-rc.tar.gz
  4. cdmysql-5.5.6-rc/
  5. ./configure--prefix=/usr/local/mysql/\
  6. --with-unix-socket-path=/tmp/mysql.sock\
  7. --with-big-tables\
  8. --with-charset=utf8\
  9. --with-collation=utf8_general_ci\
  10. --with-extra-charsets=gbk,gb2312,utf8\
  11. --with-client-ldflags=-all-static\
  12. --with-mysqld-ldflags=-all-static\
  13. --with-plugins=partition,innobase,myisammrg\
  14. --with-pthread\
  15. --with-readline\
  16. --without-debug\
  17. --without-isam\
  18. --enable-assembler\
  19. --enable-local-infile\
  20. --enable-thread-safe-client
  21. make
  22. makeinstall
  23. chmod+w/usr/local/mysql
  24. chown-Rmysql:mysql/usr/local/mysql
  25. cd ../
复制代码

全部安装的过程已经结束,下一篇结束配置。

相关推荐