上次买了物理服务器,高高兴兴的扛回家。
上window server 上面下载了一个server 2016 ,下载后发现还有180天的试用期,真香~
买的路由器刚刚好,有两个LAN口,把放了有段时间的超六类网线拿了出来,立马做了一根,nice,真香~
但是遇到了一个问题:应用发布不到网上怎么处理呢???
然后连续打了两天的电信服务电话,小姐姐都不耐烦了。
后面也了解到了国家对运营商提了要求,并在法律中进行了说明,家庭网络的80、8080、443端口默认关闭的,如果需要,需要进行备案,备案不就得拉企业专线??
后面想了想,总有个地方可以设置的把,即使关了几个端口,难道其他端口不能用了???绝对不可能。
所以就一直在问电信服务人员,最后联系了更加专业的人员,我说我需要开端口,一开始对方比较懵逼,后面解释了一下,应该明白了我是个懂行的。我提了一个问题,即使封了几个端口,但不能全部都封了把,全部封了不就上不了网了???还有我在路由器上面做端口映射也出不去??后面那个师傅说:你换宽带拨号吧,其他人也是这么做的。嗯,可以的,告诉我账号密码把,需要你到我家弄吗?专业的师傅说,你自己会弄的把,搞网络应该知道的把。嗯 算是知道吧。
高高兴兴下班回家就开始调网络。
宽带拨号、分配固定ip、web服务、防火墙、端口映射。一直弄到网上十点。
首先在宽带拨号就没什么说的,路由器进行宽带拨号,然后设置固定ip,通过mac地址进行绑定。
保证三个客户端都能上网。
下面才是正文:
web服务:使用的是nginx,遇到了很多问题,比如端口开放了,但是外网连不上?只能一个一个进行排查。
思路:先看nginx端口是不是存在?存在的话端口有没有被占用?没有被占用的话服务有没有运行??
netstat -tlnup|grep nginx // nginx的端口在吗? 或者把nginx改为端口号也是可以的
lsof -i:8080 //端口的使用情况
ps -A | grep nginx // nginx运行情况咋样?
好像也没有被占用,那服务有没有运行?
service nginx status // 嗯~ 好像没有,没有并且还给我抛出一个异常

嗯~ 没有服务,后面发现安装nginx后,还需要配置服务。
vim /etc/init.d/nginx //在/etc/init.d/目录下新建文件,文件名为nginx
# // 拷贝这一段
#!/bin/sh
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/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="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
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
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
esc=>:wq
chmod 755 /etc/init.d/nginx // 改一下权限
chkconfig --add nginx
最后在试一试,嗯~ 耐斯~

目前为止:服务没问题、端口没被占用、服务可以正常开启;然后在启动一下

网友评论