在Apache的Web服务器备忘录

在Apache上的Web服务器备忘录。

Apache 是指的是一个开放源代码的Web服务器软件。

免费的Web服务器软件。目前在全球占有最大的市场份额。
自1995年开始发展,以其稳定性、丰富的子功能以及与其他软件的兼容性而享有盛誉。
其他常见的Web服务器包括Microsoft的IIS和nginx。

安装Apache

请在以下网站上下载.Zip文件。

在命令提示符下,展开C:直下等目录,打开Apache/conf/httpd.conf文件,取消注释#ServerName*,并将其改为ServerName*。

ServerName www.example.com:80

然后在C:Apache24bin目录下执行以下命令,启动Apache Web服务。

C:Apache24\bin>httpd -k start

如果是Apache启动终端,请使用http://localhost/进入网页,在同一域内的其他终端,则使用http://192.168.**.***/进行访问。
如果浏览器显示”It works!”,表示访问正常。

在创建一个适当的文件夹后,可以通过打开C:Apache/conf/httpd.conf文件并修改以下路径来公开网页。

DocumentRoot "C:\xampp\webroot"
<Directory "C:\xampp\webroot">

将 html 文件放置在公开文件夹的根目录下,然后像之前一样通过 http://localhost/ 或者 http://192.168.**.*** 打开,网页就会显示出来。※需要重新启动 Apache C:\Apache24\bin>httpd -k restart。

公开文件夹的结构

webroot/
       ├─ index.html
       ├─ css/
             ├─ style.css
       ├─ img/
             ├─ sample.jpg
index.html<!doctype html>

 

#######################

######################################

 

style.css/* 容器 */
.wrapper{
宽度:100%;
背景图片:url(../img/sample.jpg);
背景重复:不重复;
背景大小:覆盖;
背景位置:中间居中;
}
.wrapper .container{
最大宽度:1000像素;
左右边距:0像素自动;
上下边距:80像素 0像素;
}
/* 内容 */
.wrapper .content .heading{
左右边距:0像素 0像素;
下边距:40像素;
颜色:#ffffff;
字体大小:24像素;
字体粗细:普通;
文本对齐:居中;
}
@media (min-width: 992像素) {
.wrapper .content .list {
显示:弹性;
对齐项目:中心;
对齐内容:中心;
}
}
.wrapper .content .list-item {
内边距:30像素;
行高:1.8倍行距;
颜色:#ffffff;
文本对齐:中心;
}
@media (min-width: 992像素) {
.wrapper .content .list-item {
宽度:50%;
}
}

sample_html_image.PNG

安装Apache模块

Apache有许多丰富的模块,以下链接可以查看它们的列表。有很多模块可供选择。

默认情况下,静态模块(已在安装时包含的模块)包括以下内容。

C:\Apache24\bin>httpd -l
Compiled in modules:
  core.c - 常に使用可能な Apache HTTP サーバのコア機能
  mod_win32.c - 起動時や再起動時に実行コードとモジュールをサーバにロードする
  mpm_winnt.c - Windows NT 向けに最適化されたマルチプロセッシングモジュール
  http_core.c - 常に使用可能な Apache HTTP サーバのコア機能
  mod_so.c - 起動時や再起動時に実行コードとモジュールをサーバにロードする

需要在安装之后添加的动态模块

C:\Apache24\bin>httpd -M
Loaded Modules:
 actions_module (shared)
 alias_module (shared)
 allowmethods_module (shared)
 asis_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 dir_module (shared)
 env_module (shared)
 include_module (shared)
 isapi_module (shared)
 log_config_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 setenvif_module (shared)
 .....

总结

我安装了Apache并显示了一个简单的网站。非常容易建立网站,对于对网站有兴趣的初学者来说,我认为可以轻松尝试一下。

bannerAds