---
title: "部署。8服务器"
author: "yaozhan189"
date: "2010-10-28T09:34:51Z"
tags: ["Ant", "Linux", "MySQL", "SVN", "nginx"]
categories: ["互联网"]
slug: "8"
draft: false
lastmod: "2010-10-28T09:34:51Z"
id: 796155
url: "https://yaozhan189.iteye.com/blog/796155"
---

1\. 安装svn  
cd /data/software/temp  
tar xfvz subversion-1.6.5.tar.gz  
tar xfvz subversion-deps-1.6.5.tar.gz  
cd subversion-1.6.5  
./configure --prefix=/data/software/svn  
make && make install

ln -s -f /data/software/svn/bin/svnadmin /usr/bin/svnadmin  
ln -s -f /data/software/svn/bin/svnserve /usr/bin/svnserve  
ln -s -f /data/software/svn/bin/svn /usr/bin/svn

svnserve --version

unzip svn.zip -d /data/svn  
把压缩包解压到/data/svn

svnserve -d -r /data/svn --listen-port 3690

vi /etc/rc.d/rc.local  
svnserve -d -r /data/svn --listen-port 3690

2\. 安装jdk  
cd /data/software/temp  
chmod +x jdk-6u18-linux-i586-rpm.bin  
./jdk-6u18-linux-i586-rpm.bin

vi /etc/profile  
#set java  
JAVA\_HOME=/usr/java/jdk1.6.0\_18  
CLASSPATH=.:$JAVA\_HOME/lib  
JRE\_HOME=$JAVA\_HOME/jre  
export JAVA\_HOME CLASSPATH JRE\_HOME

3\. 安装ant  
cd /data/software/temp  
tar -zxvf apache-ant-1.8.1-bin.tar.gz -C /data/software

vi /etc/profile  
#set ant  
export ANT\_HOME=/data/software/apache-ant-1.8.1  
export PATH=$PATH:$JAVA\_HOME/bin:$ANT\_HOME/bin

source /etc/profile

ln -s -f /data/software/apache-ant-1.8.1/bin/ant /usr/bin/ant

4\. 安装ImageMagick和JMagick  
先安装各种字库  
yum -y install 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

安装ImageMagick  
cd /data/software/temp  
tar -zxvf ImageMagick-6.4.0-0.tar.gz  
cd ImageMagick-6.4.0  
./configure --prefix=/data/software/ImageMagick-6.4.0 --enable-share --enable-static  
Host system type : i686-pc-linux-gnu  
                  Option                        Value  
\-------------------------------------------------------------------------  
Shared libraries --enable-shared=yes           yes  
Static libraries --enable-static=yes           yes  
Module support    --with-modules=no             no  
GNU ld            --with-gnu-ld=yes             yes  
Quantum depth     --with-quantum-depth=16       16  
Delegate Configuration:

BZLIB             --with-bzlib=yes              yes    检查

DPS               --with-dps=yes                no  
FlashPIX          --with-fpx=no         no

FreeType 2.0      --with-ttf=yes                yes    检查

GhostPCL          None                          pcl6 (unknown)  
Ghostscript       None                          gs (7.07)  
Ghostscript fonts --with-gs-font-dir=default    /usr/share/fonts/default/Type1/  
Ghostscript lib   --with-gslib=no               no  
Graphviz          --with-gvc=yes                no  
JBIG              --with-jbig=yes               no

JPEG v1           --with-jpeg=yes               no     检查

JPEG-2000         --with-jp2=yes                no  
LCMS              --with-lcms=yes               no  
Magick++          --with-magick-plus-plus=yes   yes  
PERL              --with-perl=yes               /usr/bin/perl

PNG               --with-png=yes                yes    检查

TIFF              --with-tiff=yes               no  
Windows fonts     --with-windows-font-dir=      none  
WMF               --with-wmf=yes                no  
X11               --with-x=                     no  
XML               --with-xml=yes                yes

ZLIB              --with-zlib=yes               yes    检查

注意:::  
特别检查 BZLIB, FreeType, JPEG v1, JPEG-2000, PNG, ZLIB  
make && make install  
ln -s -f /data/software/ImageMagick-6.4.0/bin/convert /usr/bin/convert  
检查：convert -sample 25%x25% /data/input.jpg /data/output.jpg

安装JMagick  
cd /data/software/temp  
tar -zxvf jmagick-6.4.0-src.tar.gz -C /data/software  
cd /data/software/6.4.0  
./configure --with-java-home=/usr/java/jdk1.6.0\_18 --with-magick-home=/data/software/ImageMagick-6.4.0 --enable-share --enable-static  
make all && make install  
cp lib/libJMagick.so /usr/java/jdk1.6.0\_18/jre/lib/i386/

5\. 安装mysql(用于bugfree，端口3306)

cd /data/software/temp  
tar -zxvf mysql-5.1.34-linux-i686-icc-glibc23.tar.gz -C /data/software  
cd /data/software  
mv mysql-5.1.34-linux-i686-icc-glibc23 mysql\_3306  
cd mysql\_3306  
scripts/mysql\_install\_db  
groupadd mysql  
useradd -g mysql mysql  
cp /data/software/mysql\_3306/support-files/mysql.server /etc/init.d/mysql\_3306

vi /etc/init.d/mysql\_3306  
修改其中  
basedir=/data/software/mysql\_3306  
Datadir=/data/software/mysql\_3306/data

cd /data/software/mysql\_3306  
chown -R root.root .  
chgrp -R mysql .  
chown -R mysql ./data

vi my.cnf  
把mysql\_3306的内容粘贴进去

\# Example MySQL config file for small systems.  
\#  
\# This is for a system with little memory (&lt;= 64M) where MySQL is only used  
\# from time to time and it's important that the mysqld daemon  
\# doesn't use much resources.  
\#  
\# You can copy this file to  
\# /etc/my.cnf to set global options,  
\# mysql-data-dir/my.cnf to set server-specific options (in this  
\# installation this directory is /usr/local/mysql/data) or  
\# ~/.my.cnf to set user-specific options.  
\#  
\# In this file, you can use all long options that a program supports.  
\# If you want to know which options a program supports, run the program  
\# with the "--help" option.

\# The following options will be passed to all MySQL clients  
\[client]  
#password    = your\_password  
port        = 3306  
socket        = /tmp/mysql\_3306.sock

\# Here follows entries for some specific programs

\# The MySQL server  
\[mysqld]  
basedir         = /data/software/mysql\_3306  
datadir         = /data/software/mysql\_3306/data  
port        = 3306  
socket        = /tmp/mysql\_3306.sock  
skip-locking  
key\_buffer = 16K  
max\_allowed\_packet = 1M  
table\_cache = 4  
sort\_buffer\_size = 64K  
read\_buffer\_size = 256K  
read\_rnd\_buffer\_size = 256K  
net\_buffer\_length = 2K  
thread\_stack = 128K

\# Don't listen on a TCP/IP port at all. This can be a security enhancement,  
\# if all processes that need to connect to mysqld run on the same host.  
\# All interaction with mysqld must be made via Unix sockets or named pipes.  
\# Note that using this option without enabling named pipes on Windows  
\# (using the "enable-named-pipe" option) will render mysqld useless!  
\#  
#skip-networking  
server-id    = 1

\# Uncomment the following if you want to log updates  
#log-bin=mysql-bin

\# binary logging format - mixed recommended  
#binlog\_format=mixed

\# Uncomment the following if you are using InnoDB tables  
#innodb\_data\_home\_dir = /usr/local/mysql/data/  
#innodb\_data\_file\_path = ibdata1:10M:autoextend  
#innodb\_log\_group\_home\_dir = /usr/local/mysql/data/  
\# You can set ..\_buffer\_pool\_size up to 50 - 80 %  
\# of RAM but beware of setting memory usage too high  
#innodb\_buffer\_pool\_size = 16M  
#innodb\_additional\_mem\_pool\_size = 2M  
\# Set ..\_log\_file\_size to 25 % of buffer pool size  
#innodb\_log\_file\_size = 5M  
#innodb\_log\_buffer\_size = 8M  
#innodb\_flush\_log\_at\_trx\_commit = 1  
#innodb\_lock\_wait\_timeout = 50

\[mysqldump]  
quick  
max\_allowed\_packet = 16M

\[mysql]  
no-auto-rehash  
\# Remove the next comment character if you are not familiar with SQL  
#safe-updates

\[isamchk]  
key\_buffer = 8M  
sort\_buffer\_size = 8M

\[myisamchk]  
key\_buffer = 8M  
sort\_buffer\_size = 8M

\[mysqlhotcopy]  
interactive-timeout

#-----------------------------------------end----------------------------------

chmod 755 my.cnf

service mysql\_3306 start  
chkconfig --add mysql\_3306

cd bin  
./mysqladmin -uroot password "123456" -S /tmp/mysql\_3306.sock  
./mysql -uroot -p123456 -S /tmp/mysql\_3306.sock  
mysql&gt; GRANT ALL PRIVILEGES ON \*.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;  
mysql&gt; use mysql;  
mysql&gt; delete from user where password="";  
mysql&gt; create database bugfree2;  
mysql&gt; use bugfree2;  
mysql&gt; source /data/bugfree2.sql  
mysql&gt; flush privileges;  
mysql&gt; exit;

Navicat连接数据库，并把表名的小写改成大写，  
bf\_buginfo 改成 bf\_BugInfo  
bf\_caseinfo 改成 bf\_CaseInfo  
bf\_requireinfo 改成 bf\_RequireInfo  
bf\_resultinfo 改成 bf\_ResultInfo  
bf\_testaction 改成 bf\_TestAction  
bf\_testfile 改成 bf\_TestFile  
bf\_testgroup 改成 bf\_TestGroup  
bf\_testhistory 改成 bf\_TestHistory  
bf\_testmodule 改成 bf\_TestModule  
bf\_testoptions 改成 bf\_TestOptions  
bf\_testproject 改成 bf\_TestProject  
bf\_testuser 改成 bf\_TestUser  
bf\_testuserlog 改成 bf\_TestUserLog  
bf\_testuserquery 改成 bf\_TestUserQuery  
 

6\. 安装TCMalloc  
cd /data/software/temp  
tar -zxvf google-perftools-1.5.tar.gz  
cd google-perftools-1.5  
./configure  
make && make install  
echo "/usr/local/lib" &gt; /etc/ld.so.conf.d/usr\_local\_lib.conf  
/sbin/ldconfig

vi /data/software/mysql\_3306/bin/mysqld\_safe  
在# executing mysqld\_safe的下一行，加上：  
export LD\_PRELOAD=/usr/local/lib/libtcmalloc.so

service mysql\_3306 restart

使用lsof命令查看tcmalloc是否起效：  
lsof -n | grep tcmalloc

如果发现以下信息，说明tcmalloc已经起效：  
mysqld    10847   mysql  mem       REG        8,5  1203756   20484960 /usr/local/lib/libtcmalloc.so.0.0.0 

7\. 安装apache  
cd /data/software/temp  
tar -zxvf httpd-2.2.15.tar.gz  
cd httpd-2.2.15  
./configure --prefix=/data/software/apache2 --enable-so  --enable-dav --enable-dav-fs --enable-mods-shared=most  
make && make install

groupadd apache  
useradd -g apache apache

8\. 安装php  
cd /data/software/temp  
tar -zxvf php-5.2.13.tar.gz  
cd php-5.2.13  
./configure --prefix=/data/software/php --with-apxs2=/data/software/apache2/bin/apxs --with-mysql=/data/software/mysql\_3306  
make && make install  
cp php.ini-dist /usr/local/lib/php.ini

vi /data/software/apache2/conf/httpd.conf

Listen 80 改成 Listen 192.168.27.135:8080

#ServerName www.example.com:80 要改成 ServerName localhost:8080

用户和用户组改成  
User apache  
Group apache

&lt;IfModule mime\_module&gt;  下面加一行  AddType application/x-httpd-php .php

把 Include conf/extra/httpd-vhosts.conf 的#注释去掉

把  
&lt;Directory /&gt;  
    Options FollowSymLinks  
    AllowOverride None  
    Order deny,allow  
    Deny from all  
&lt;/Directory&gt;  
改成  
&lt;Directory /&gt;  
    Options Indexes FollowSymLinks  
    AllowOverride None  
&lt;/Directory&gt;

&lt;IfModule dir\_module&gt;  
    DirectoryIndex index.html index.php  
&lt;/IfModule&gt;  
index.html 后面加 index.php

修改虚拟主机配置文件

vi /data/software/apache2/conf/extra/httpd-vhosts.conf

NameVirtualHost 192.168.1.250:8080

&lt;VirtualHost 192.168.1.250:8080&gt;  
        ServerName bug.jiaming.com  
        DocumentRoot /data/bugfree  
        ErrorLog /data/software/apache2/logs/bugfree.log  
        TransferLog /data/software/apache2/logs/bugfree.log  
&lt;/VirtualHost&gt;

&lt;VirtualHost 192.168.1.250:8080&gt;  
        ServerName admin.jiaming.com  
        DocumentRoot /data/hisupplier.com/hisupplier-admin  
        ErrorLog /data/software/apache2/logs/hisupplier-admin.log  
        TransferLog /data/software/apache2/logs/hisupplier-admin.log  
&lt;/VirtualHost&gt;

解压bugfree的源程序  
cd /data  
unzip bugfree.zip  
chown -R apache.apache /data/bugfree

修改数据库链接  
vi /data/bugfree/Include/Config.inc.php

/* 3. Define the username and password of the BugFree database. \*/  
$\_CFG\['DB']\['User']        = 'root';  
$\_CFG\['DB']\['Password']    = '123456';  
$\_CFG\['DB']\['Host']        = '192.168.1.250';  
$\_CFG\['DB']\['Database']    = 'bugfree2';  
$\_CFG\['DB']\['TablePrefix'] = 'bf\_';  
$\_CFG\['DBCharset']         = 'UTF8';

检出英文版总后台  
svn checkout svn://192.168.1.250/hisupplier-en/admin/branches/v3.2.1 /data/hisupplier.com/hisupplier-admin --username guest --password guest --non-interactive

把apache做成服务  
cp /data/software/apache2/bin/apachectl /etc/init.d/httpd  
chmod +x /etc/init.d/httpd

vi /etc/init.d/httpd  
在 #!/bin/sh 后面加  
\# Linux startup script for Apache  
\# chkconfig: 345 85 15  
\# description: Apache is a Web server.  
\# processname: httpd

service httpd start  
chkconfig --add httpd

11\. 检出svn中的源程序 && 编译

vi /data/checkoutBuild.sh

#!/bin/bash

#----------------- 英文版 -----------------

svn checkout svn://192.168.1.250/hisupplier/app-lib /data/hisupplier.com/svn/app-lib --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier/cas/branches/v3.1 /data/hisupplier.com/svn/hisupplier-cas --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier/img/branches/v3.0 /data/hisupplier.com/svn/img-3.0 --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-en/hicc/branches/v3.0 /data/hisupplier.com/svn/hicc --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-en/b2b/branches/v3.5.0 /data/hisupplier.com/svn/hisupplier-b2b --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-en/account/branches/v3.5.1 /data/hisupplier.com/svn/hisupplier-account --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-en/tradeshow/branches/v3.3.0 /data/hisupplier.com/svn/hisupplier-tradeshow --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-en/goldsite/branches/v3.0 /data/hisupplier.com/svn/hisupplier-goldsite --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-en/manufacturer/branches/v3.0 /data/hisupplier.com/svn/hisupplier-manufacturer --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-en/trade/branches/v3.0 /data/hisupplier.com/svn/hisupplier-trade --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-en/city/branches/v1.0 /data/hisupplier.com/svn/hisupplier-city --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-en/wap/branches/v1.x /data/hisupplier.com/svn/hisupplier-wap --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-en/showroom/branches/v3.2.0 /data/hisupplier.com/svn/hisupplier-showroom --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-en/indie/branches/v4.0.0 /data/hisupplier.com/svn/hisupplier-indie --username guest --password guest --non-interactive  
sleep 1

cd /data/hisupplier.com/svn/hisupplier-cas  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/img-3.0  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hicc  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-b2b  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-account  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-tradeshow  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-goldsite  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-manufacturer  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-trade  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-city  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-wap  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-showroom  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-indie  
ant test

#----------------- 中文版 -----------------

svn checkout svn://192.168.1.250/hisupplier/img/branches/v3.1 /data/hisupplier.com/svn/img-3.1 --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-cn/hicc/branches/v3.0 /data/hisupplier.com/svn/hisupplier-cn-hicc --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-cn/b2b/branches/v3.0.2 /data/hisupplier.com/svn/hisupplier-cn-b2b --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-cn/account/branches/v3.1.1 /data/hisupplier.com/svn/hisupplier-cn-account --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-cn/tradeshow/branches/v3.0.1 /data/hisupplier.com/svn/hisupplier-cn-tradeshow --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-cn/train/branches/v1.0 /data/hisupplier.com/svn/hisupplier-cn-train --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-cn/admin/branches/v3.1.1 /data/hisupplier.com/svn/hisupplier-cn-admin --username guest --password guest --non-interactive  
sleep 1  
svn checkout svn://192.168.1.250/hisupplier-cn/showroom/branches/v3.0.1 /data/hisupplier.com/svn/hisupplier-cn-showroom --username guest --password guest --non-interactive  
sleep 1

cd /data/hisupplier.com/svn/img-3.1  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-cn-hicc  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-cn-b2b  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-cn-account  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-cn-tradeshow  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-cn-train  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-cn-admin  
ant test  
sleep 1  
cd /data/hisupplier.com/svn/hisupplier-cn-showroom  
ant test  
sleep 1

#------------------------- end ------------------------

执行脚本：  
chmod +x /data/checkoutBuild.sh  
/data/checkoutBuild.sh

9\. 安装resin  
cd /data/software/temp  
tar -zxvf resin-3.1.9.tar.gz  
cd resin-3.1.9  
./configure -with-java-home=/usr/java/jdk1.6.0\_18 --prefix=/data/software/resin  
make && make install

cd /data/software/temp  
tar -zxvf resin-3.1.9.tar.gz  
cd resin-3.1.9  
./configure -with-java-home=/usr/java/jdk1.6.0\_18 --prefix=/data/software/resin-3.1.9-en  
make && make install

cd ..  
rm -rf resin-3.1.9

tar -zxvf resin-3.1.9.tar.gz  
cd resin-3.1.9  
./configure -with-java-home=/usr/java/jdk1.6.0\_18 --prefix=/data/software/resin-3.1.9-cn  
make && make install

1). 把ext-lib拷贝到中英文的resin/lib目录下

2). 把预先设置好的conf文件贴进去  
vi /data/software/resin/conf/resin.conf  
vi /data/software/resin-3.1.9-en/conf/resin.conf  
vi /data/software/resin-3.1.9-cn/conf/resin.conf

3). 把 resin resin-en resin-cn 三个文件拷贝到 /etc/init.d目录下面  
chmod +x /etc/init.d/resin  
chmod +x /etc/init.d/resin-en  
chmod +x /etc/init.d/resin-cn

4). 拷贝开发好的svn自动更新程序  
mkdir /data/hisupplier.com/svnUpdate  
unzip svnUpdate.zip -d /data/hisupplier.com/svnUpdate

vi /data/hisupplier.com/svnUpdate/en.sh  
vi /data/hisupplier.com/svnUpdate/cn.sh

把这个2个脚本贴进去

chmod +x /data/hisupplier.com/svnUpdate/en.sh  
chmod +x /data/hisupplier.com/svnUpdate/cn.sh

chkconfig --add resin  
chkconfig --add resin-en  
chkconfig --add resin-cn

service resin start  
service resin-en start  
service resin-cn start

10\. 安装nginx  
cd /data/software/temp  
tar -zxvf pcre-8.02.tar.gz  
mv pcre-8.02 ../  
cd /data/software/pcre-8.02  
./configure  
make && make install

cd /data/software/temp  
tar -zxvf nginx-0.8.35.tar.gz  
cd nginx-0.8.35  
./configure  --user=root --group=root --prefix=/data/software/nginx --with-http\_stub\_status\_module --with-http\_ssl\_module --with-http\_sub\_module  
make && make install

vi /data/software/nginx/conf/nginx.conf  
把预先设置好的conf贴进去

启动nginx  
/data/software/nginx/sbin/nginx  
如果关闭,ps –aux|grep nginx,然后kill，如果平滑重启 kill -HUP

或者可以做成服务

vi /etc/init.d/nginx

#!/bin/bash  
\# Linux startup script for nginx  
\# chkconfig: 345 85 15  
\# description: Nginx HTTP Server.  
\# processname: nginx  
\# pidfile: /var/run/nginx.pid  
\# config: /data/software/nginx/conf/nginx.conf

nginxd=/data/software/nginx/sbin/nginx  
nginx\_config=/data/software/nginx/conf/nginx.conf  
nginx\_pid=/data/software/nginx/logs/nginx.pid

RETVAL=0  
prog="nginx"

\# Source function library.  
. /etc/rc.d/init.d/functions

\# Source networking configuration.  
. /etc/sysconfig/network

\# Check that networking is up.  
\[ ${NETWORKING} = "no" ] && exit 0

\[ -x $nginxd ] || exit 0

\# Start nginx daemons functions.  
start() {

if \[ -e $nginx\_pid ];then  
   echo "nginx already running...."  
   exit 1  
fi

   echo -n $"Starting $prog: "  
   daemon $nginxd -c ${nginx\_config}  
   RETVAL=$?  
   echo  
   \[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx  
   return $RETVAL

}

\# Stop nginx daemons functions.  
stop() {  
        echo -n $"Stopping $prog: "  
        killproc $nginxd  
        RETVAL=$?  
        echo  
        \[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid  
}

\# reload nginx service functions.  
reload() {

    echo -n $"Reloading $prog: "  
    #kill -HUP \`cat ${nginx\_pid}\`  
    killproc $nginxd -HUP  
    RETVAL=$?  
    echo

}

\# See how we were called.  
case "$1" in  
start)  
        start  
        ;;

stop)  
        stop  
        ;;

reload)  
        reload  
        ;;

restart)  
        stop  
        start  
        ;;

status)  
        status $prog  
        RETVAL=$?  
        ;;  
\*)  
        echo $"Usage: $prog {start|stop|restart|reload|status|help}"  
        exit 1  
esac

exit $RETVAL

\# ============== the END =============

chmod +x /etc/init.d/nginx  
service nginx start  
chkconfig --add nginx