Chinaunix首页 | 论坛 | 博客
  • 博客访问: 268405
  • 博文数量: 41
  • 博客积分: 2560
  • 博客等级: 少校
  • 技术积分: 465
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-01 15:56
文章分类

全部博文(41)

文章存档

2011年(10)

2010年(31)

我的朋友

分类: 系统运维

2010-07-01 17:02:11

这仅是个人工作中安装操作,仅记录安装过程
环境:centos 5.3 64
软件:

nginx-0.7.65.tar.gz

mysql-5.1.35.tar.gz

php-5.3.2.tar.gz

jpegsrc.v6b.tar.gz

libxml2-2.7.3.tar.gz

freetype-2.3.8.tar.gz

libpng-1.2.35.tar.gz

gd-2.0.35.tar.gz

libmcrypt-2.5.8.tar.gz

mhash-0.9.9.9.tar.gz

ImageMagick-6.4.9-9.tar.gz

imagick-2.2.2.tgz

libevent-1.4.11-stable.tar.gz

memcache-2.2.5.tgz

libmemcached-0.27.tar.gz

memcached-1.0.0.tgz

APC-3.0.19.tgz

oauth-0.99.9.tgz

libiconv-1.13.tar.gz

一、修改nginx显示版本:

   修改nginx版本号

tar -zxvf nginx-0.7.65.tar.gz
cd nginx-0.7.65/src/core
more nginx.h

/*
 * Copyright (C) Igor Sysoev
 */


#ifndef _NGINX_H_INCLUDED_
#define _NGINX_H_INCLUDED_


#define nginx_version         7065
#define NGINX_VERSION      "0.7.65"
#define NGINX_VER          "nginx/" NGINX_VERSION

#define NGINX_VAR          "NGINX"
#define NGX_OLDPID_EXT     ".oldbin"


#endif /* _NGINX_H_INCLUDED_ */
 

修改相应文件如下:
vi nginx.h

/*
 * Copyright (C) Igor Sysoev
 */


#ifndef _NGINX_H_INCLUDED_
#define _NGINX_H_INCLUDED_


#define nginx_version         iis
#define NGINX_VERSION      "8.0"
#define NGINX_VER          "iis/" NGINX_VERSION

#define NGINX_VAR          "iis"
#define NGX_OLDPID_EXT     ".oldbin"


#endif /* _NGINX_H_INCLUDED_ */
二、nginx安装编译
tar -zxvf pcre-7.9.tar.gz
cd pcre-7.9
./configure
make && make install

tar -zxvf nginx-0.7.65.tar.gz
cd nginx-0.7.65
--prefix=/usr/local/nginx
--without-http_userid_module
--without-http_ssi_module
--without-http_memcached_module
--without-http_map_module
--without-http_empty_gif_module 
--without-http_geo_module
--without-http_empty_gif_module
--without-http_autoindex_module
--without-http_auth_basic_module
--without-http_browser_module
--without-http-cache
make && make install
三、mysql安装编译
groupadd mysql
useradd -g mysql -d /usr/local/mysql/ -M mysql

tar zxf mysql-5.1.35.tar.gz
cd mysql-5.1.35
./configure --prefix=/usr/local/mysql
--sysconfdir=/etc
--localstatedir=/usr/local/mysql/data
--enable-assembler
--with-mysqld-ldflags=-all-static
--with-charset=utf8
--with-extra-charsets=all
--with-named-curses-libs=/usr/lib64/libncursesw.so.5
--withplugins=partition,daemon_example,ftexample,archive,blackhole,federated,heap,innobase,myisammrg,ndbcluster
make && make install
/usr/local/mysql/bin/mysql_install_db
chown -R mysql:mysql /usr/local/mysql/data
cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
perl -pi -e 's/skip-federated/#skip-federated/g' /etc/my.cnf
service mysqld start
ln -s /usr/local/mysql/include/mysql /usr/include
/usr/local/mysql/bin/mysqladmin -u root password "mysql"
四、php安装编译
由于编译过程中需要用到一些lib库
1、yum -y install zlib-devel gettext-devel  curl-devel libidn-devel openssl-devel krb5-devel e2fsprogs-devel keyutils-libs-devel libselinux-devel libsepol-devel
2、echo '/usr/local/lib
/usr/lib64
/usr/local/lib64' >> /etc/ld.so.conf
ldconfig
3、mkdir /usr/local/modules
mkdir /usr/local/modules/jpeg6
mkdir /usr/local/modules/jpeg6/bin
mkdir /usr/local/modules/jpeg6/lib
mkdir /usr/local/modules/jpeg6/include
mkdir /usr/local/modules/jpeg6/man
mkdir /usr/local/modules/jpeg6/man/man1

tar xzf jpegsrc.v6b.tar.gz
alias 'cp=cp'
cp -f /usr/share/libtool/config.sub jpeg-6b
cp -f /usr/share/libtool/config.guess jpeg-6b
cd jpeg-6b
./configure --prefix=/usr/local/modules/jpeg6 --enable-shared --enable-static
make && make install

tar -zxf libxml2-2.7.3.tar.gz
cd libxml2-2.7.3
sed -i 's/@TAR@/& --wildcards/' xstc/Makefile.in
./configure --prefix=/usr/local/modules/libxml 
make && make install

tar xzf freetype-2.3.8.tar.gz
cd freetype-2.3.8
./configure --prefix=/usr/local/modules/freetype
make && make install

tar xzf libpng-1.2.35.tar.gz
cd libpng-1.2.35
cp scripts/makefile.linux makefile
make && make install

tar xzf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --prefix=/usr/local/modules/gd --with-jpeg=/usr/local/modules/jpeg6 --with-png --with-freetype=/usr/local/modules/freetype
make && make install

tar xzf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/modules/libmcrypt
make && make install
cd libmcrypt-2.5.8/libltdl
./configure --enable-ltdl-install
make && make install

tar -zxf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure --prefix=/usr/local/modules/mhash
make && make install

tar -zxvf libiconv-1.13.tar.gz
cd libiconv-1.13
./configure --prefix=/usr/local/modules/iconv
make && make install

tar -zxf libevent-1.4.11-stable.tar.gz
cd libevent-1.4.11-stable
./configure
make && make install

tar -zxvf autoconf-2.13.tar.gz(这个看系统环境来定,由于在给php-fpm打补丁安装时报错,需将autoconf安装到2.13以上)
cd autoconf-2.13
./configure
make && make install
mv /usr/bin/autoconf /usr/bin/autoconf.bak
ln -s /usr/local/bin/autoconf /usr/bin/autoconf
tar -zxvf php-5.3.2.tar.gz(由于我们是使用fpm来管理fastcgi需要打fpm补丁,我们install服务器上已有打php-fpm补丁的php-fpm-5.3.2.tar.gz)注:如果采用mysqlnd,mysql可以不用安装
cd php-5.3.2
svn co sapi/fpm
./buildconf --force
./configure 
--prefix=/usr/local/php5 
--with-mysql=mysqlnd
--with-mysqli=mysqlnd
--with-pdo-mysql=mysqlnd
--with-gd=/usr/local/modules/gd
--with-iconv-dir=/usr/local/modules/iconv
--with-jpeg-dir=/usr/local/modules/jpeg6
--with-freetype-dir=/usr/local/modules/freetype
--with-libxml-dir=/usr/local/modules/libxml
--with-mcrypt=/usr/local/modules/libmcrypt
--with-mhash=/usr/local/modules/mhash
--with-png-dir
--with-zlib
--with-xmlrpc
--with-openssl
--with-curl
--with-curlwrappers
--enable-fpm
--enable-xml
--enable-soap
--enable-sockets
--enable-mbstring
--enable-bcmath
--enable-exif
--enable-gd-native-ttf
--enable-safe-mode
--enable-shmop
--enable-sysvsem
--enable-inline-optimization
--enable-mbregex
--enable-pcntl
--disable-rpath
make && make install
cp ./php.ini-production /usr/local/php5/lib/php.ini
php扩展模块安装
install ImageMagick
tar -zxf ImageMagick-6.4.9-9.tar.gz
cd ImageMagick-6.4.9-9
./configure LDFLAGS="-L/usr/local/modules/freetype/lib -L/usr/local/modules/jpeg6/lib" CPPFLAGS="-I/usr/local/modules/freetype/include -I/usr/local/modules/jpeg6/include" --prefix=/usr/local/ImageMagick --enable-shared
make && make install

install imagick for php
tar zxf imagick-2.2.2.tgz
cd imagick-2.2.2
/usr/local/php5/bin/phpize
./configure --with-php-config=/usr/local/php5/bin/php-config --with-imagick=/usr/local/ImageMagick/
make && make install
perl -pi -e 's%extension_dir = "./"%extension_dir = "/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/"%g' /usr/local/php5/lib/php.ini
perl -pi -e 's%^;extension=php_bz2.dll%extension=imagick.so\n;extension=php_bz2.dll%' /usr/local/php5/lib/php.ini

tar -zxvf oauth-0.99.9.tgz
/usr/local/php5/bin/pecl install oauth-0.99.9
perl -pi -e 's%^;extension=php_bz2.dll%extension=oauth.so\n;extension=php_bz2.dll%' /usr/local/php5/lib/php.ini

服务器端
tar -zxf memcached-1.2.6.tar.gz
cd memcached-1.2.6
./configure --prefix=/usr/local/memcached
make && make install

php memcache扩展
install memcache for php
tar zxf memcache-2.2.5.tgz
cd memcache-2.2.5; /usr/local/php5/bin/phpize
./configure --with-php-config=/usr/local/php5/bin/php-config --with-gettext --with-gettext --enable-socket --enable-memcache --enable-sysvshm --enable-shmop
make && make install
perl -pi -e 's%^;extension=php_bz2.dll%extension=memcache.so\n;extension=php_bz2.dll%' /usr/local/php5/lib/php.ini

install another memcached client for php
tar zxf libmemcached-0.27.tar.gz
cd libmemcached-0.27
./configure --with-memcached=/usr/local/memcached
make && make install

安装igbinary
wget
/usr/local/php5/bin/phpize
./configure CFLAGS="-O2 -g" --enable-igbinary  --with-php-config=/usr/local/php5/bin/php-config
make && make install

php memcached扩展
tar zxf memcached-1.0.0.tgz
cd memcached-1.0.0
/usr/local/php5/bin/phpize
./configure --with-php-config=/usr/local/php5/bin/php-config --with-gettext --with-gettext --enable-socket

make && make install
perl -pi -e 's%^;extension=php_bz2.dll%extension=memcached.so\n;extension=php_bz2.dll%' /usr/local/php5/lib/php.ini

apc 安装
tar zxvf APC-3.1.3p1.tgz
cd APC-3.1.3p1
/usr/local/php5/bin/phpize
./configure --enable-apc --enable-apc-mmap --with-php-config=/usr/local/php5/bin/php-config
make && make install

APC是PHP有效的开放源高速缓冲储存器工具以下是一个优化
echo 'apc.enabled=1
apc.shm_segments=1
apc.shm_size=32
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/dev/shm/apc.XXXXXX
apc.enable_cli=1'>>/usr/local/php5/lib/php.ini
五、nginx配置文件
user       demo demo;
worker_processes  8;
error_log  logs/error.log;
pid        logs/nginx.pid;
worker_rlimit_nofile 51200;

events {
    worker_connections  51200;
    use            epoll;
}

http {
    include    mime.types;
    default_type application/octet-stream;

    log_format main      '$remote_addr - $remote_user [$time_local] '
                         '"$request" $status $bytes_sent '
                         '"$http_referer" "$http_user_agent" ';

    log_format download  '$remote_addr - $remote_user [$time_local] '
                         '"$request" $status $bytes_sent '
                         '"$http_referer" "$http_user_agent" '
                         '"$http_range" "$sent_http_content_range"';

    client_header_timeout  3m;
    client_body_timeout    3m;
    send_timeout           3m;

    client_header_buffer_size    1k;
    large_client_header_buffers  4 4k;

    output_buffers   1 32k;
    postpone_output  1460;

    sendfile         on;
    tcp_nopush       on;
    tcp_nodelay      on;
    fastcgi_connect_timeout 60;
    fastcgi_send_timeout 60;
    fastcgi_read_timeout 180;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 16 16k;
    fastcgi_busy_buffers_size 32k;
    fastcgi_temp_file_write_size 32k;

    client_max_body_size       10m;
    client_body_buffer_size 128k;


    keepalive_timeout  75 20;
       

    #gzip  on;

        server {
                listen       80;
                server_name  192.168.204.40;
                root         /var/www/test;
                #charset koi8-r;
                index        index.php index.html index.htm;

                access_log  logs/test_access.log  main;

                location ~ .*\.(php|php5)$ {
                        fastcgi_pass   unix:/tmp/php-cgi.sock;
                        fastcgi_index  index.php;
                        include        fastcgi.conf;
                }
        }

        server {
        listen       80;
        server_name  example.test.com;
            root         /var/www/test/example.test.com/public;
            #charset koi8-r;
            index        index.php index.html index.htm;

            access_log  logs/example.test.com_access.log  main;

        location ~ .*\.(php|php5)$ {
                fastcgi_pass   unix:/tmp/php-cgi.sock;
            fastcgi_index  index.php;
            include        fastcgi.conf;
        }
    }

        server {
            listen       80;
        server_name  admin.test.com;
        root         /var/www/test/admin.test.com/public;
        #charset koi8-r;
        index        index.php index.html index.htm;

        access_log  logs/admin.test.com_access.log  main;

        location ~ .*\.(php|php5)$ {
            fastcgi_pass   unix:/tmp/php-cgi.sock;
            fastcgi_index  index.php;
            include        fastcgi.conf;
            }
    }

        server {
        listen       80;
        server_name  resource.test.com;
        root         /var/www/test/resource;
        #charset koi8-r;
        index        index.php index.html index.htm;

        access_log  logs/resource.test.com_access.log  main;
        location ~ .*\.(js|css)$ {
             rewrite        ^\/minify\/([a-z0-9]+)\/([a-z_]+)\/([a-z_]+)\.([0-9\.]+)(css|js)$ /minify/index.php?theme=$1&domain=$2&name=$3&type=$5 last;
             rewrite        ^\/(.*)\.(css|js)$ /$1\.$2 last;
        }
       
        location ~ .*\.(php|php5)$ {
             fastcgi_pass   unix:/tmp/php-cgi.sock;
             fastcgi_index  index.php;
             include        fastcgi.conf;

        }
    }
}
六、php-fpm配置
[global]
pid = /usr/local/php5/var/run/php-fpm.pid
error_log = /usr/local/php5/var/log/php-fpm.log
log_level = notice
emergency_restart_threshold = 10
emergency_restart_interval = 60s
process_control_timeout = 5s
daemonize = yes
[www]
#listen = 127.0.0.1:9000
listen = /tmp/php-cgi.sock
listen.backlog = -1
listen.mode = 0666
user = demo
group = demo
pm = static
pm.max_children = 100
pm.start_servers = 100
pm.min_spare_servers = 200
pm.max_spare_servers = 1000
pm.max_requests = 2000
rlimit_files = 65536







阅读(1780) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:rsync配置

给主人留下些什么吧!~~