centos 7 安装和配置apache

1、安装apache非常简单

 yum install httpd

2、配置参数

vi /etc/httpd/conf/httpd.conf

修改网站根目录路径

DocumentRoot "/home/wwwroot"
<Directory "/home/wwwroot">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

 

<Directory "/home/wwwroot">
    #
    # 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
</Directory>

 

3、启动apache服务

 

systemctl start httpd.service

4、禁止网站目录中某个文件夹的访问

让apache识别.htaccess文件

 

vi /etc/httpd/conf/httpd.conf
<Directory >
    AllowOverride All
    # Allow open access:
    Require all granted
</Directory>

在要禁止访问的目录上添加 .htaccess文件内容如下

order deny,allow
deny from ./
顺便提供一个在线生成.htaccess文件的网站:
http://www.babaw.com/htaccess/#a_accesshttp://www.babaw.com/htaccess/#a_access

重新启动apche服务,可生效 

 

systemctl restart httpd.service

5、禁止列出目录中文件列表

vi /etc/httpd/conf/httpd.conf

将  

Options Indexes FollowSymLinks

 

改成

 

 

 Options None

6、设置apache开机自动启动

chkconfig --levels 235 httpd on 

 

7、安装php7

 

复制代码

#更新yum源(默认yum源中无php7)
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm  

#安装php及常用的拓展模块
yum -y install php70w php70w-mysql php70w-mbstring php70w-mcrypt php70w-gd php70w-imap php70w-ldap php70w-odbc php70w-pear php70w-xml php70w-xmlrpc php70w-pdo

#查看php安装了那些拓展模块
php -m

#安装其他你需要的拓展模块
yum -y install php70w-xxx

 

 

 

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值