美文网首页我爱编程
Apache 服务器安装与基本配置

Apache 服务器安装与基本配置

作者: znsw007 | 来源:发表于2017-07-14 09:21 被阅读73次

    下载

    Apache 选择对应的版本进行下载

    配置(2.4版本)

    ==不同版本配置有所不同==

    下载后解压文件,在conf目录下打开httpd.conf 修改目录位置

    Define SRVROOT "D:/Apache" //当前Apache安装所在目录
    ServerRoot "${SRVROOT}"
    
    

    默认80端口(可在cmd下使用netstat -a查看),如需修改则如下所示

    #Listen 12.34.56.78:80
    Listen 8070
    
    

    在window下安装服务,切换到bin目录下

    "D:\Apache-2.4.20\Apache\bin\httpd.exe" -k install -n apache
    
    

    可以自定义服务名称apache

    apache-server-install.jpg

    其中,Errors reported here must be corrected before the service can be started.意思是,此处报告的错误必须在服务开始前进行纠正。若没有,则成功。

    Apache启动

    包含三种

    • window 服务启动,在计算机管理>服务和应用程序>服务中找到创建的apache服务项

    • bin目录下

    httpd -k start      // 开启
    httpd -k shutdown // 关闭服务
    httpd -k restart // 重启服务
        
    

    如果错误,需要添加上 服务名称

    httpd -n "apache" -k start
    
    
    • bin目录下 ApacheMonitor.exe

    如果服务启动失败,涉及到配置文件,可通过命令行进行查看,在bin目录下

    httpd.exe -w -n "apache" -k start
    
    

    apache 是服务的名称

    常见目录功能

    bin // 存放常用命令
    cgi-bin // linux下常用命令
    conf // 配置文件
    error // 错误记录
    htdocs // 存放站点资源
    logs // apache 相关日志
    
    

    配置虚拟目录

    httpd.conf中查找<IfModule alias_module>,然后在节点内输入以下内容

    Alias /workspace "D:/WorkSpace/WebStorm_Space_01/AdminLTE"
     
    <Directory "D:/WorkSpace/WebStorm_Space_01/AdminLTE">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>
    

    重启即可。需要注意的是apache不同版本,Directory 里面的内容设置不同
    参考stackoverflow.com,官网 upgrading

    在2.2

    Order allow,deny
    Allow from all
    

    在2.4

    Require all granted
    

    开启服务,在浏览器中访问http://localhost:8070/workspace/ 即可

    相关文章

      网友评论

        本文标题:Apache 服务器安装与基本配置

        本文链接:https://www.haomeiwen.com/subject/eslnhxtx.html