-
进入Apache官网
官网地址:http://httpd.apache/
-
点击Download
-
选择Windows版下载,点击链接
-
下载安装包
-
解压压缩包到指定的文件夹
-
修改配置文件
打开D:\Apache-httpd\Apache24\conf\httpd.conf文件
-
修改Apache安装目录
Define SRVROOT "D:/Apache24" ServerRoot "${SRVROOT}"
-
修改端口
如果80端口已被使用,则需要先关闭相关软件,或者修改apache默认的监听端口检查端口是否被占用:
netstat -aon|findstr 80
修改默认端口:打开httpd.conf 搜索 “Listen 80”,修改为Listen 8088。
-
检查配置文件是否合法
命令行下进入到apache下面的bin目录httpd -t
-
-
安装Apache的主服务
打开cmd窗口,命令行下进入到apache下面的bin目录:
httpd -k install -n apache
其中
-n
后面参数是自定义Windows服务的名称,安装后可以使用Windows管理服务的命令来管理apache服务。如net start/stop apache
(启动/停止服务)。 -
检测是否安装正确
开始–>运行–>services.msc–>确定
错误:Installing the 'apache' service The 'apache' service is successfully installed. Testing httpd.conf.... Errors reported here must be corrected before the service can be started. (OS 10048)通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 : AH00072: make_sock: could not bind to address [::]:443 (OS 10048)通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 : AH00072: make_sock: could not bind to address 0.0.0.0:443 AH00451: no listening sockets available, shutting down AH00015: Unable to open logs
解决办法:
- 卸载
httpd -k uninstall
- 修改配置文件
将D:\Apache-httpd\Apache24\conf\extra目录下httpd-ahssl.conf和httpd-ssl.conf文件中的443改为442。
- 卸载
-
启动apache服务
方式一:利用Windows服务管理启动
开始–>运行–>services.msc–>确定,找到apache服务,右键启动
方式二:利用命令行启动打开cmd窗口,命令行下进入到apache下面的bin目录:
httpd [-n apache] -k [start | restart]
-n apache
如果重命名了服务名,则需加上。利用Windows托管服务命令,以管理员身份运行
net start apache
方式三:利用Apache服务器自身的视窗打开
找到bin目录下的ApacheMonitor.exe
访问网址:http://localhost:1234/ (1234位自行设置的端口号) -
文件下载
复制文件到 D:/Apache24/htdocs 目录下,并删除 index.html 文件。也可以修改放置文件目录位置。
... #DocumentRoot "${SRVROOT}/htdocs" #<Directory "${SRVROOT}/htdocs"> #修改为 DocumentRoot "D:/sharedfile" <Directory "D:/sharedfile"> ...
-
设置访问权限
- 生成密码文件
或D:\Apache24\bin>htpasswd -c d:\sharedfile\.htpasswd lei_charles New password: ********* Re-type new password: ********* Adding password for user lei_charles
D:\Apache24\bin>htpasswd -bc D:\sharedfile\.htpasswd lei_charles 123456 Adding password for user lei_charles
- 创建
.htaccess
文件
注意: Windows下新建.htaccess
文件时,文件名需写为.htaccess.
,否则无法创建。AuthName "OA系统登陆" AuthType Basic AuthBasicProvider file AuthUserFile "D:\sharedfile\.htpasswd" Require valid-user
- 修改 httpd.conf 配置文件
<Directory "D:/sharedfile"> Options Indexes FollowSymLinks # 将 AllowOverride None 修改为 AllowOverride AuthConfig AllowOverride AuthConfig Require all granted </Directory>
- 重启服务
- 生成密码文件
-
Apache服务的卸载
切记一定要先卸载apache服务,然后删除安装文件(若直接删除安装路径的文件夹,会有残余文件在电脑)。
在cmd命令窗口,先停止服务再删除:httpd -k uninstall 或 sc delete apache (apache是Apache服务器的服务名)
Windows下安装Apache搭建文件服务下载
与本文相关的文章
- windows下安装redis和redis扩展
- Windows下Idea,AndroidStudio的字体美化
- windows上设置自动删除oracle归档日志
- jenkins自动构建批处理命令-windows
- windows下用户变量和系统变量
- Windows Bat 用FTP上传文件 使用笔记
- windows安全加固
- 通过windows远程桌面连接CentOS系统
- windows服务器系统监控
- Windows 10 系统设置系统环境变量和用户环境变量
- win10c语言文件不运行,win10系统运行程序出现“dll文件没有被指定在windows运行”的解决教程...
- 【windows使用技巧#0】ISO镜像,OEM、Retail这些到底是什么意思
- 提升Windows 7 64位系统安全与稳定性的必备补丁推荐
- windows server 2003 详细安装过程带镜像资源
- Windows如何正确开机
- 想要极致优化,还得看这些 Windows 系统调教神器!
- [EtherCAT]在Windows中编译并使用开源主站SOEM 1.4.0——2024.07.16
- windows - win11永久关闭更新、延迟十年更新、随时继续更新
- windows配置开机自启动软件或脚本
- javascript - obtain mac address from browser including chrome, windows, safari, firefox - Stack Overflow
评论列表(0)
- 暂无评论