一、在线安装 jdk1.8
cd /usr/local/
1、查看安装程序:
rpm -qa | grep -i jdk
若之前安装过 jdk,下次安装一定把之前的删除干净
2、命令下载 jdk 包 (需要联网,下载也需要点时间)
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz
3、解压
tar -zxvf jdk-8u131-linux-x64.tar.gz
4、配置环境变量
vi /etc/profile
可以看到这个文件的内容,profile 文件有点类似于 windows 系统里面的环境变量的配置,
shift + g 定位到最后一行
在最后一行添加以下内容:
export JAVA_HOME=/usr/local/jdk1.8.0_131 export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
5、查看是否配置成功
java -version
如果路径配置都正确还是找不到命令,尝试 reboot 重启一下系统再来查看
二、在线安装 nginx
mkdir /root/install
1、pcre 安装
cd /root/install wget https://netix.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.tar.gz tar zxvf pcre-8.40.tar.gz cd pcre-8.40 ./configure && make && make install
2、zlib 安装
cd /root/install wget http://zlib.net/zlib-1.2.11.tar.gz tar zxvf zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure && make && make install
3、openssl 安装
yum -y install openssl openssl-devel
4、nginx 安装
# 下载安装包 wget http://nginx.org/download/nginx-1.12.2.tar.gz # 创建安装目录 mkdir -p /www/server # 解压 tar zxvf nginx-1.12.2.tar.gz # 安装 cd nginx-1.12.2 ./configure --user=admin --group=admin --prefix=/www/server/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module make && make install # 赋予执行权限 chmod +s /www/server/nginx/sbin/nginx # 授予admin权限 chown -R admin.admin /www/server/nginx/conf
5、设置 nginx 开机自启服务
5.1、首先先创建一个启动脚本 nginx_service_start.sh,内容如下:
5.1.1、创建命令:
cd /root/install vi nginx_service_start.sh
5.1.2、内容为:
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: NGINX is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/www/server/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/www/server/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
if [ -z "`grep $user /etc/passwd`" ]; then
useradd -M -s /bin/nologin $user
fi
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
5.2、创建好后,开始制作开机自启
# 将启动脚本拷贝到开机初始化目录 cp /root/install/nginx_service_start.sh /etc/init.d/nginx chmod a+x /etc/init.d/nginx chkconfig --add nginx chkconfig nginx on chmod u+x /www/server/nginx/sbin/nginx
制作完成
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于