apache httpd server config and compile

1、httpd 安裝方法

Apache httpd server 能夠運行 php ,可是官方提供的文件只是源文件,須要本身下載源文件,而後編譯成能夠執行文件。php

windows 下面下載已經編譯好的Binary files。這個也是apache 官方推薦的windows 可執行二進制文件。html

點擊 https://www.apachelounge.com/download/ 中的相應版本c++

Apache 2.4.23 Win64redis

Apache 2.4.23 Win32apache

而後檢查一下是否安裝了vc++ 運行環境,若是沒有須要下載相應版本安裝。windows

Be sure that you have installed the latest C++ Redistributable Visual Studio 2015 vc_redist.x86.exe or vc_redist.x64.exe.session

https://httpd.apache.org/docs/2.2/platform/windows.htmlapp

2、httpd server 配置工程文件路徑

2.1 httpd server 監聽端口

 打開 conf/httpd.conf 文件,找到listen 修改你要監聽的端口。less

#Listen 12.34.56.78:80
Listen 8000ide

2.2 Configuring Access to Network Resources

若是你想單獨讓httpd 訪問一個資源不在htdocs 文件下面,那麼須要設置別名,而且給出訪問權限。

Alias "/image" "/ftp/pub/image"
<Directory "/ftp/pub/image">
    Require all granted
</Directory>

Access to files over the network can be specified using two mechanisms provided by Windows:

Mapped drive letters

e.g., Alias "/images/" "Z:/"

UNC paths

e.g., Alias "/images/" "//imagehost/www/images/"

Mapped drive letters allow the administrator to maintain the mapping to a specific machine and path outside of the Apache httpd configuration. However, these mappings are associated only with interactive sessions and are not directly available to Apache httpd when it is started as a service. Use only UNC paths for network resources in httpd.conf so that the resources can be accessed consistently regardless of how Apache httpd is started. (Arcane and error prone procedures may work around the restriction on mapped drive letters, but this is not recommended.)

Example DocumentRoot with UNC path

DocumentRoot "//dochost/www/html/"

Example DocumentRoot with IP address in UNC path

DocumentRoot "//192.168.1.50/docs/"

Example Alias and corresponding Directory with UNC path

Alias "/images/" "//imagehost/www/images/"

<Directory "//imagehost/www/images/">
#...
<Directory>

When running Apache httpd as a service, you must create a separate account in order to access network resources, as described above.

https://httpd.apache.org/docs/current/platform/windows.html

2、運行方法

Linux 運行方法:
service apache2 start
service apache2 stop
service apache2 restart

windows 運行方法:

在cmd 到httpd文件路徑,而後cmd裏面運行httpd便可

相關文章
相關標籤/搜索