这回第一次接触CentOS这款Linux系统,安全级别上了一个层次,代价就是各种通常方法安装的程序不能直接使用。首先遇到的问题就是装了Netbeans这款用来编写Java的IDE后,编译的Socket程序只能本机互联,连本地互联都不行。其次是用yum install apache命令搭建的web服务器改到自己的目录不能运行,用chmod加上777的权限以后还跟我说forbidden访问,给跪在那儿了。
最后莫名其妙地解决了,大致回忆下思路。首先是web服务器,网上各种教程搭配,说起来对于centos有这么几点有用:
首先这个鬼配置文件etc/httpd/conf/httpd.conf,蓝色部分我直接全部注释掉了。找的教程说得不明不白,都不懂是注释一部分还是哪几个。干脆全部干掉
DocumentRoot "/var/www/html"
#
# Relax access to content within /var/www.
#
# Further relax access to the default document root:
#
#Options Indexes FollowSymLinks
#AllowOverride None
#
其次是这个文件etc/httpd/conf/welcome.conf,同样蓝色部分也全部注释掉。省的每次开网站都只转跳到没有index主页的目录上。为了让根域名http://localhost直接显示主页,主页一定要命名为index.html而不是index.htm,一定是html而不是htm。
#
# This configuration file enables the default "Welcome" page if there
# is no default index page present for the root URL.
# Welcome page, comment out all the lines below.
#
# NOTE: if this file is removed, it will be restored on upgrades.
#
#
#
#
#
#
#
#
#
#Alias /.noindex.html /usr/share/httpd/noindex/index.html
#Alias /noindex/css/bootstrap.min.css /usr/share/httpd/noindex/css/bootstrap.min.css
#Alias /noindex/css/open-sans.css /usr/share/httpd/noindex/css/open-sans.css
#Alias /images/apache_pb.gif /usr/share/httpd/noindex/images/apache_pb.gif
#Alias /images/poweredby.png /usr/share/httpd/noindex/images/poweredby.png
由于被CentOS的安全机制搞蒙了,所以直接用原配目录/var/www/html
建立主页文件index.html(注意不能用index.htm)
其次是自己搭建的服务器外网老是连不上,原因是防火墙并没有给开端口。例如java写的程序里面,打开端口4999,那么相应的在CentOS的Firewall程序里面,就得在public下添加4999端口: