修改host
/etc/host
修改防火墙
我们很多时候在liunx系统上安装了web服务应用后(如tomcat、apache等),需要让其它电脑能访问到该应用,而Linux系统(centos、redhat等)的防火墙是默认只对外开放了22端口。
linux系统的端口设置在/etc/sysconfig/iptables文件中配置。使用编辑器打开该文件。内容如下:
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
如果我们需要对外开放80端口,则上面文件中添加如下code
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
终端运行命令
service iptables restart
下面这个命令可以看到开放的端口
/sbin/iptables -L -n
下面的命令可以关闭/打开防火墙(需要重启系统)
开启: chkconfig iptables on
关闭: chkconfig iptables off
下面的代码可以启动和停止防火墙(立即生效,重启后失效)
开启: service iptables start
关闭: service iptables stop
修改环境变量
修改etc/profile,增加环境变量
export JAVA_HOME=/usr/java/jdk1.8.0_65
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
启用环境变量,命令行执行
source /etc/profile