• nginx安装过程记录
    时间:2008-11-11   作者:佚名   出处:互联网

    去官网下载nginx到本地

    unzip nginx-php-1.zip
    unzip nginx-php-2.zip
    cd nginx-php
    tar zxvf libiconv-1.11.tar.gz
    cd libiconv-1.11/
    ./configure --prefix=/usr/local
    make
    make install
    cd ../

    tar zxvf freetype-2.3.5.tar.gz
    cd freetype-2.3.5/
    ./configure
    make
    make install
    cd ../

    tar zxvf libpng-1.2.20.tar.gz
    cd libpng-1.2.20/
    ./configure
    make
    make install
    cd ../

    tar zxvf jpegsrc.v6b.tar.gz
    cd jpeg-6b/
    ./configure --enable-static --enable-shared
    make
    make install
    make install-lib
    cd ../

    #----If your system was install libxml2, you do not need to install it.----
    tar zxvf libxml2-2.6.30.tar.gz
    cd libxml2-2.6.30/
    ./configure
    make
    make install
    cd ../

    tar zxvf libmcrypt-2.5.8.tar.gz
    cd libmcrypt-2.5.8/
    ./configure
    make
    make install
    /sbin/ldconfig
    cd libltdl/
    ./configure --enable-ltdl-install
    make
    make install
    cd ../../

    tar zxvf mhash-0.9.9.tar.gz
    cd mhash-0.9.9/
    ./configure
    make
    make install
    cd ../

    cp /usr/local/lib/libmcrypt.* /usr/lib
    ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2

    tar zxvf mcrypt-2.6.6.tar.gz
    cd mcrypt-2.6.6/
    ./configure
    make
    make install
    cd ../

    /usr/sbin/groupadd mysql
    /usr/sbin/useradd -g mysql mysql
    tar zxvf mysql-5.0.45.tar.gz
    cd mysql-5.0.45
    ./configure --prefix=/usr/local/webserver/mysql/ --without-debug --with-unix-socket-path=/tmp/mysql.sock --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --with-extra-charsets=gbk,gb2312,utf8 --with-pthread --enable-thread-safe-client
    make && make install
    chmod +w /usr/local/mysql
    chown -R mysql:mysql /usr/local/mysql
    cp support-files/my-medium.cnf /usr/local/webserver/mysql/my.cnf
    cd ../

    /usr/local/webserver/mysql/bin/mysql_install_db --defaults-file=/usr/local/webserver/mysql/my.cnf --basedir=/usr/local/webserver/mysql --datadir=/usr/local/webserver/mysql/data --user=mysql --pid-file=/usr/local/webserver/mysql/mysql.pid --skip-locking --port=3306 --socket=/tmp/mysql.sock
    ln -sf /usr/local/webserver/mysql/my.cnf /etc/my.cnf
    /bin/sh /usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/usr/local/webserver/mysql/my.cnf &


    tar zxvf php-5.2.5.tar.gz
    cd php-5.2.5/

    ./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/webserver/mysql --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --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-force-cgi-redirect --enable-mbstring --with-mcrypt

    sed -i 's#-lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt#& -liconv#' Makefile
    make
    make install
    cp php.ini-dist /usr/local/php/etc/php.ini
    cd ../

    /usr/sbin/groupadd nginx -g 48
    /usr/sbin/useradd -u 48 -g nginx nginx
    mkdir -p /data/vshare/htdocs
    chmod +w /data/vshare/htdocs
    chown -R nginx:nginx /data/vshare/htdocs

    tar zxvf pcre-7.2.tar.gz
    cd pcre-7.2/
    ./configure
    make && make install
    cd ../

    tar zxvf nginx-0.5.33.tar.gz
    cd nginx-0.5.33/
    ./configure --user=nginx --group=nginx --prefix=/usr/local/webserver/nginx --with-http_stub_status_module
    make && make install
    cd ../

    mkdir -p /data/vshare/logs
    chmod +w /data/vshare/logs
    chown -R nginx:nginx /data/vshare/logs

    rm -f /usr/local/webserver/nginx/conf/nginx.conf
    cd /usr/local/webserver/nginx/conf/


    cat <<EOF > nginx.conf
    user  nginx nginx;

    worker_processes 10;

    error_log  /data/vshare/logs/nginx_error.log  crit;

    #pid        logs/nginx.pid;

    #Specifies the value for maximum file descriptors that can be opened by this process.
    worker_rlimit_nofile 51200;

    events
    {
          use epoll;

          worker_connections 51200;
    }

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

          charset  gbk;
         
          server_names_hash_bucket_size 128;
         
          #sendfile on;
          #tcp_nopush     on;

          keepalive_timeout 60;

          tcp_nodelay on;

          gzip on;
          gzip_min_length  1k;
          gzip_buffers     4 8k;
          gzip_http_version 1.1;
          gzip_types       text/plain application/x-javascript text/css text/html application/xml;

          server
          {
                  listen       80;
                  server_name  gc.imop.com;
                  index index.html index.htm index.php;
                  root  /data/vshare/htdocs;

                  if (-d $request_filename)
                  {
                         rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
                  }
                                
                  location ~ .*\.php?$
                  {
                       include conf/fcgi.conf;     
                       fastcgi_pass  127.0.0.1:10080;
                       fastcgi_param SCRIPT_FILENAME /data/vshare/passport$fastcgi_script_name;
                       fastcgi_index index.php;
                  }

                  log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
                                        '$status $body_bytes_sent "$http_referer" '
                                        '"$http_user_agent" $http_x_forwarded_for';
                  access_log  /data/vshare/logs/access.log  access;
          }
    }

    EOF

    cat <<EOF > fcgi.conf
    fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param  SERVER_SOFTWARE    nginx;

    fastcgi_param  QUERY_STRING \$query_string;      
    fastcgi_param  REQUEST_METHOD \$request_method;
    fastcgi_param  CONTENT_TYPE \$content_type;
    fastcgi_param  CONTENT_LENGTH \$content_length;

    fastcgi_param  SCRIPT_FILENAME \$document_root$fastcgi_script_name;
    fastcgi_param  SCRIPT_NAME \$fastcgi_script_name;
    fastcgi_param  REQUEST_URI        \$request_uri;
    fastcgi_param  DOCUMENT_URI       \$document_uri;
    fastcgi_param  DOCUMENT_ROOT      \$document_root;
    fastcgi_param  SERVER_PROTOCOL    \$server_protocol;

    fastcgi_param  REMOTE_ADDR        \$remote_addr;
    fastcgi_param  REMOTE_PORT        \$remote_port;
    fastcgi_param  SERVER_ADDR        \$server_addr;
    fastcgi_param  SERVER_PORT        \$server_port;
    fastcgi_param  SERVER_NAME        \$server_name;

    # PHP only, required if PHP was built with --enable-force-cgi-redirect
    #fastcgi_param  REDIRECT_STATUS    200;
    EOF

    cd /usr/local/webserver/nginx/sbin
    cat <<EOF>naginstart.sh
    ulimit -SHn 51200
    /usr/local/webserver/php/bin/spawn-fcgi -a 127.0.0.1 -p 10080 -C 64 -u www -f /usr/local/webserver/php/bin/php-cgi
    /usr/local/webserver/nginx/sbin/nginx -c /usr/local/webserver/nginx/conf/nginx.conf
    EOF
    chmod a+x /usr/local/webserver/nginx/sbin/naginstart.sh

    网友留言/评论

    我要留言/评论