在nginx上运行YouTrack问题和项目跟踪工具(Debian Wheezy)
YouTrack是一个用Java编写的问题和项目跟踪工具。 本教程将介绍如何通过Debian Wheezy上的nginx网络服务器为YouTrack提供服务。
我不会保证这将为您工作!
1安装Java
为了运行YouTrack,我们需要在我们的服务器上安装Java:
apt-get install openjdk-6-jdk openjdk-6-jre unzip
update-alternatives --config java
update-alternatives --config javac
2安装YouTrack
创建一个YouTrack用户和一个目录来安装YouTrack:
adduser youtrack --disabled-password
mkdir -p /usr/local/youtrack
chown youtrack:youtrack /usr/local/youtrack
创建YouTrack初始化脚本:
vi /etc/init.d/youtrack
#! /bin/sh ### BEGIN INIT INFO # Provides: youtrack # Required-Start: $local_fs $remote_fs # Required-Stop: $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: S 0 1 6 # Short-Description: initscript for youtrack # Description: initscript for youtrack ### END INIT INFO export HOME=/home/youtrack set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME=youtrack SCRIPT=/usr/local/$NAME/$NAME.sh d_start() { su youtrack -l -c "$SCRIPT start" } d_stop() { su youtrack -l -c "$SCRIPT stop" } case "$1" in start) echo "Starting $NAME..." d_start ;; stop) echo "Stopping $NAME..." d_stop ;; restart|force-reload) echo "Restarting $NAME..." d_stop d_start ;; *) echo "Usage: sudo /etc/init.d/youtrack {start|stop|restart}" >&2 exit 1 ;; esac exit 0 |
使脚本可执行并设置系统启动链接:
chmod 755 /etc/init.d/youtrack
update-rc.d youtrack defaults
以下脚本由init脚本调用,并启动端口8112上的YouTrack守护程序:
vi /usr/local/youtrack/youtrack.sh
#! /bin/sh export HOME=/home/youtrack export JAVA_HOME=/usr/bin/java NAME=youtrack PORT=8112 USR=/usr/local/$NAME JAR=$USR/`ls -Lt $USR/*.jar | grep -o "$NAME-[Linux. YouTrack JAR as a Service. Alternative Method^/]*.jar" | head -1` LOG=$USR/$NAME-$PORT.log PID=$USR/$NAME-$PORT.pid d_start() { if [ -f $PID ]; then PID_VALUE=`cat $PID` if [ ! -z "$PID_VALUE" ]; then PID_VALUE=`ps ax | grep $PID_VALUE | grep -v grep | awk '{print $1}'` if [ ! -z "$PID_VALUE" ]; then exit 1; fi fi fi PREV_DIR=`pwd` cd $USR exec $JAVA_HOME -Xmx512m -jar $JAR"youtrack.jar" $PORT >> $LOG 2>&1 & echo $! > $PID cd $PREV_DIR } d_stop() { if [ -f $PID ]; then PID_VALUE=`cat $PID` if [ ! -z "$PID_VALUE" ]; then PID_VALUE=`ps ax | grep $PID_VALUE | grep -v grep | awk '{print $1}'` if [ ! -z "$PID_VALUE" ]; then kill $PID_VALUE WAIT_TIME=0 while [ `ps ax | grep $PID_VALUE | grep -v grep | wc -l` -ne 0 -a "$WAIT_TIME" -lt 2 ] do sleep 1 WAIT_TIME=$(expr $WAIT_TIME + 1) done if [ `ps ax | grep $PID_VALUE | grep -v grep | wc -l` -ne 0 ]; then WAIT_TIME=0 while [ `ps ax | grep $PID_VALUE | grep -v grep | wc -l` -ne 0 -a "$WAIT_TIME" -lt 15 ] do sleep 1 WAIT_TIME=$(expr $WAIT_TIME + 1) done echo fi if [ `ps ax | grep $PID_VALUE | grep -v grep | wc -l` -ne 0 ]; then kill -9 $PID_VALUE fi fi fi rm -f $PID fi } case "$1" in start) d_start ;; stop) d_stop ;; *) echo "Usage: $0 {start|stop|restart}" >&2 exit 1 ;; esac exit 0 |
使脚本可执行:
chmod 755 /usr/local/youtrack/youtrack.sh
接下来请访问http://www.jetbrains.com/youtrack/download/get_youtrack.html ,确保选择Linux
,然后单击“ 下载YouTrack
”按钮:
将youtrack-5.0.6.jar
下载到桌面,然后将其上传到服务器的/ tmp
文件夹。 之后运行...
cp /tmp/youtrack-5.0.6.jar /usr/local/youtrack/youtrack.jar
...并启动YouTrack:
/etc/init.d/youtrack restart
YouTrack守护程序现在应该在端口8112
上运行,您可以使用以下命令进行验证:
netstat -tapn|grep 8112
root@server1:/var/www/example.com/web# netstat -tapn|grep 8112
tcp6 0 0 :::8112 :::* LISTEN 11504/java
root@server1:/var/www/example.com/web#
如果没有运行,请查看日志文件/usr/local/youtrack/youtrack-8112.log
。
3配置nginx
接下来,我们必须配置我们要访问YouTrack的nginx vhost。 您必须将以下配置粘贴到服务器{}
容器中(如果使用ISPConfig,则为nginx
指令):
location / { proxy_pass http://127.0.0.1:8112; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; } |
而已! 现在访问您的网站,您应该可以使用YouTrack:
4链接
- YouTrack: http : //www.jetbrains.com/youtrack/
- nginx: http : //nginx.org/
- Debian: http : //www.debian.org/