CentOS给予port端口权限(搭建web…

本文介绍了在CentOS系统中遇到的Web服务器权限问题和端口开放问题的解决办法。通过修改httpd.conf和welcome.conf配置文件,解除对网页访问的限制,并确保Apache服务器可以运行在自定义目录下。同时,为了允许外网连接,需要在Firewall中开启对应端口。
摘要由CSDN通过智能技术生成

这回第一次接触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.
#


    AllowOverride None
    # Allow open access:
    Require all granted


# Further relax access to the default document root:
#
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
   
#Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
   
#AllowOverride None

    #
    # Controls who can get stuff from this server.
    #

    #Require all granted
    #Order deny,allow
    #Deny from all
#

 

 

其次是这个文件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.  To disable the
# Welcome page, comment out all the lines below.
#
# NOTE: if this file is removed, it will be restored on upgrades.
#


#
#    Options -Indexes
#    ErrorDocument 403 /.noindex.html
#

#
#    AllowOverride None
#    Require all granted
#

#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端口:

CentOS给予port端口权限(搭建web和非web服务器的安全问题)


http://blog.itpub.net/29773961/viewspace-1261417/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值