Linux小知識 (自用)
1.將linux設定成中文
echo "export LANG="zh_CN.UTF8"">>/etc/profile
source /etc/profile
2.安裝JAVA後修改 配置檔案
/etc/profile
最後幾行加上
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_17 **注意這裡的目錄是你安裝的目錄,每臺電腦不一樣!!!! export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
加上之後,再source一下,即source /etc/profile
3.安裝完畢Tomcat後將Tomcat新增到service中
首先 #touch /etc/init.d/tomcat
然後#vi /etc/init.d/tomcat
輸入如下內容
#!/bin/bash
#chkconfig: 2345 90 60
#description: auto_run
#source function libary
. /etc/rc.d/init.d/functions
#source networking configuration
. /etc/sysconfig/network
[ "$NETWORKING" = "no" ] && exit 0
#tomcat home path
tomcat=/home/apps/Tomcat8/apache-tomcat-8.0.53 *****注意!!這裡是你的安裝目錄,每臺電腦不一樣!!!
startup=$tomcat/bin/startup.sh
shutdown=$tomcat/bin/shutdown.sh
#echo -n
#$?
start(){
echo -n $"Starting tomcat service:"
sh $startup
echo $?
}
stop(){
echo -n $"Stoping tomcat service:"
sh $shutdown
echo $?
}
restart(){
stop
start
}
status(){
ps -ef|grep tomcat
}
case "$1" in
start|stop|restart|status)
$1
;;
*)
echo 'Not support operation.'
esac
exit 0
修改完畢後退出。
輸入如下指令
#chkconfig --add /etc/init.d/tomcat
#chmod 755 /etc/init.d/tomcat
#chkconfig --add tomcat
最後一步,有些時候雖然可以呼叫java -version的命令,但是在tomcat中沒有設定JAVA_HOME的環境變數,所以需要設定一下
vi tomcat安裝檔案中bin/setclasspath.sh 新增JAVA和JRE的變數
export JAVA_HOME= 你的JAVA安裝目錄!!!
就完畢了!!!
4.將nginx新增到service中
方法類似!!!
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx **注意這裡是你的安裝目錄!!!
nginx_config=/usr/local/nginx/conf/nginx.conf **注意這裡是你的安裝目錄!!!
nginx_pid=/var/run/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
chkconfig --add /etc/init.d/nginx
chmod 755 /etc/init.d/nginx
chkconfig --add nginx
注意:在安裝nginx的之前需要安裝
yum -y install gcc pcre-devel openssl openssl-devel
yum完畢之後再
make && make install