Csuper Blog

Csuper Blog

Centos6.3 + php5.3 + nginx1.2.2 + mysql5.5服务器搭建过程及问题记录
2012-11-01

 

一.配置环境

  OS:Centos6.3

sudo -s
LANG=C
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

二.下载源代码

  nginx,php,mysql,php-fpg(php5.3后已集成),libiconv(locale),mcrypt,libmcrypt,memcache,mhash,pcre,pdo_mysql等等任何可能需要的组件。

三.编译安装php所需组件

  libiconv  

    --prefix=/usr/local

  libmcrypt

    /sbin/ldconfig

    cd libltd/

    ./configure --enable-ltdl-install

  mhash

    ln -s /usr/local/lib/libmcrypt.* /usr/lib/  //只是一个形式,根据后面命令提示ln对应文件即可
    ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2

  mcrypt

    /sbin/ldconfig

四.编译安装MySQL  

  groupadd mysql

  useradd -g mysql mysql

  新版本mysql可以使用cmake编译(需安装bison)。设置路径为/usr/local/webserver/

  chmod +w /usr/local/webserver/mysql

  chown -R mysql:mysql /usr/local/webserver/mysql

  cp support-files/my-medium.cnf /usr/local/webserver/mysql/my.cnf

  创建数据库目录:

  mkdir -p /data0/mysql/3306/data/

  chown -R mysql:mysql /data0/mysql/

  /usr/local/webserver/mysql/script/mysql_install_db --basedir=/usr/local/webserver/mysql --          datadir=/data0/mysql/3306/data --user=mysql

  启动mysql

  /usr/local/webserver/mysql/bin/mysqld_safe &

五.编译安装PHP及扩展模块

  ./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --   with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --   with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr   --enable-xml --disable-debug --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 

  本步骤结束时会有找不到ssl头文件的问题。根据提示路径mkdir,cp对应文件夹过去即可。

  重新./configure make & make install

  sed -i 's#-lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt#& -liconv#' Makefile

  cp php.ini-dist /usr/local/webserver/php/etc/php.ini

  

  cd memcache-version/

  /usr/local/webserver/php/bin/phpize
  ./configure --with-php-config=/usr/local/webserver/php/bin/php-config
  make
  make install
  cd ../
  

  cd xcache-version/

  /usr/local/webserver/php/bin/phpize
  ./configure --with-php-config=/usr/local/webserver/php/bin/php-config --enable-xcache
  make
  make install
  cd ../

 

  以及pdo_mysql等等也可在此处安装

  安装完毕编辑php.ini添加extension

  配置xcache,以下内容加入php.ini末尾

  [xcache-common]
  zend_extension = /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so

  [xcache.admin]
  xcache.admin.user = "xcache"
  ; xcache.admin.pass = md5($yourpasswd)
  xcache.admin.pass = "8e6867a5d05144cf4761d6481fc674a8"

  [xcache]
  xcache.cacher = On
  xcache.shm_scheme = "mmap"
  xcache.size = 32M
  ; cpu number (cat /proc/cpuinfo |grep -c processor)
  xcache.count = 2
  xcache.slots = 8k
  xcache.ttl = 0
  xcache.gc_interval = 0
  xcache.var_size = 2M
  ; cpu number (cat /proc/cpuinfo |grep -c processor)
  xcache.var_count = 2
  xcache.var_slots = 8K
  xcache.var_ttl = 0
  xcache.var_maxttl = 0
  xcache.var_gc_interval = 300
  xcache.readonly_protection = Off
  xcache.mmap_path = "/dev/zero"    

  

  mv /usr/local/webserver/php/etc/php-fpm.conf.default /usr/local/webserver/php/etc/php-fpm.conf

 

六.安装nginx

  pcre

  cd nginx-version/
  ./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-     http_stub_status_module --  with-http_ssl_module
  make && make install
  cd ../

  

  日志目录

  mkdir -p /data1/logs
  chmod +w /data1/logs
  chown -R www:www /data1/logs

  nginx.conf按照通常习惯设置。

  设置开机启动,编辑/etc/rc.local

 

发表评论: