CentOS Nginx PHP MySQL Memcached 安装 配置 优化

http://www.phpplay.com/thread-118293-1-1.html

按照版本
Nginx 0.8.52 PHP 5.3.3
MySQL 5.5.6 Memcached

一、安装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. # This file uses a new mirrorlist system developed by Lance Davis for CentOS.
4. # The mirror system uses the connecting IP address of the client and the
5. # update status of each mirror to pick mirrors that are updated to and
6. # geographically close to the client. You should use this for CentOS updates
7. # unless you are manually picking other mirrors.
8. #
9. # If the mirrorlist= does not work for you, as a fall back you can try the
10. # remarked out baseurl= line instead.
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. #released updates
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. #packages used/produced in the build but not released
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. #additional packages that may be useful
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. #additional packages that extend functionality of existing packages
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. wget http://nginx.org/download/nginx-0.8.52.tar.gz
  3. wget http://cn.php.net/get/php-5.3.3.tar.gz/from/this/mirror
  4. #wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.6-rc.tar.gz/from/http://mysql.he.net/
  5. wget http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.2-m2-linux-i686-glibc23.tar.gz
  6. wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
  7. wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
  8. wget http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz?use_mirror=ncu
  9. wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz?use_mirror=ncu
  10. wget http://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz?use_mirror=ncu
  11. wget http://downloads.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.tar.gz?use_mirror=ncu
  12. #wget http://downloads.sourceforge.net/project/imagemagick/ImageMagick/00-6.6.5/ImageMagick-6.6.5-0.tar.gz?use_mirror=ncu
  13. wget http://sourceforge.net/projects/imagemagick/files/6.7.7-sources/ImageMagick-6.7.7-5.tar.gz/download
  14. wget http://pecl.php.net/get/APC-3.1.4.tgz
  15. wget http://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. cd libiconv-1.13.1/
  3. ./configure --prefix=/usr/local
  4. make
  5. make install
  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. cd libmcrypt-2.5.8/
  3. ./configure
  4. make
  5. make install
  6. /sbin/ldconfig
  7. cd libltdl/
  8. ./configure --enable-ltdl-install
  9. make
  10. make install
  11. cd ../../
复制代码

4. 安装mhash

  1. tar zxvf mhash-0.9.9.9.tar.gz
  2. cd mhash-0.9.9.9/
  3. ./configure
  4. make
  5. make install
  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. cd mcrypt-2.6.8/
  3. /sbin/ldconfig
  4. ./configure
  5. make
  6. make install
  7. cd ../
复制代码

6. 安装memcached

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

7. 安装pcre

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

8. 安装Nginx

  1. /usr/sbin/groupadd www
  2. /usr/sbin/useradd -g www www
  3. tar zxvf nginx-0.8.52.tar.gz
  4. cd nginx-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. make install
  11. cd ../
复制代码

9. 安装PHP

  1. tar zxvf php-5.3.3.tar.gz
  2. cd php-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. make ZEND_EXTRA_LIBS='-liconv'
  33. make install
  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. cd ImageMagick-6.6.5-0/
  3. ./configure
  4. make
  5. make install
  6. cd ../
复制代码

11. 安装PHP扩展imagick

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

12. 安装PHP扩展memcache

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

13. 安装PHP扩展APC

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

14. 安装MySQL

  1. /usr/sbin/groupadd mysql
  2. /usr/sbin/useradd -g mysql mysql
  3. tar xvf mysql-5.5.6-rc.tar.gz
  4. cd mysql-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. make install
  23. chmod +w /usr/local/mysql
  24. chown -R mysql:mysql /usr/local/mysql
  25. cd ../
复制代码

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

猜你喜欢

转载自mw-fang.iteye.com/blog/1675662