Centos7 Apache httpd 2.4.6 | You don’t have permission to access / on this server.|Forbidden 403

Forbidden
You don't have permission to access /index.html on this server.

笔者在今天折腾一天Centos7 的web想写个脚本自动部署,结果搞了一天网站测试访问永远是以上错误。
笔者有一个好习惯就是 经常百度,这次也不例外。但 Centos 这个7版本不给力,Apache 2.4.6配置坑人,让笔者体验到绝望。笔者百度了一个晚上终于找到答案。
必须注释以下代码配置文件位于/etc/httpd/conf/httpd.conf,部分代码注释完成如下:

#<Directory />
   # AllowOverride none
   # Require all denied
#</Directory>

同时确保你的SeLinux 状态位 disabled

#sestatus
SELinux status:                 disabled

修改方法,修改结果如下:vim /etc/sysconfig/selinux

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

Selinux修改之后一定要重启,Apache配置文件修改之后一定要重启服务

版权申明:未经允许不得随意转载,网络转载必须说明来自www.0xc2.cn 原创文章

股票代码_公司介绍_单页信息 Version 0.1

# -*- coding:utf-8 -*-
#股票代码_公司介绍_单页信息 Version 0.1
#Author: NMTech
#Mail: NMTech@Aliyun.com
import requests,re
Share_id = []
def Spider(url):
    html = requests.get(url)
    html.encoding = 'utf-8'
    txt(html.text)
#html正则过滤
def txt(text):
    html_tmp = re.compile(r'<div class="nc">\s*<h5>.*\s*(.*?)\s*</h5>')
    company = html_tmp.findall(text)
    html_tmp = re.compile(r'<td width="184">(.*?)</td>\s*<td>(.*?)</td>')
    tmp_txt = html_tmp.findall(text)
    Addinfo(company,tmp_txt)
#创建并添加item到list"SS"中
def Addinfo(company,tmp_txt):
    item = {}
    item['company'] = company[0]
    for list in range(len(tmp_txt)):
        item[tmp_txt[list][0]] = tmp_txt[list][1]
        print tmp_txt[list][0] + "\t"+ item[tmp_txt[list][0]]
    Share_id.append(item)
    print Share_id

Spider("http://www.962518.com/newscenter/gszb.htm?code=000001")

版权申明:未经允许不得随意转载,网络转载必须说明来自www.0xc2.cn 原创文章