ph-bookshelf-wiki/web-server.md

41 lines
1.5 KiB
Markdown
Raw Permalink Normal View History

2023-01-29 10:24:15 +08:00
# Web Server
[Apache]: https://httpd.apache.org/
[.htaccess]: https://httpd.apache.org/docs/2.4/howto/htaccess.html
[mod_rewrite]: https://httpd.apache.org/docs/current/mod/mod_rewrite.html
ph-Bookshelf 原始版本是在 [Apache Web Server][Apache] 环境下开发的,并有用到 [Apache] 的 [.htaccess]。
你也可以在其它的环境下使用 **ph-Bookshelf**,只需要一些简单的路径重写设置。
## Apache
要想在 [Apache] 中使用 **ph-Bookshelf**,你只需要确认一些简单的设置:
确认 [mod_rewrite] 已经打开。这一般可以通过以下简单的命令确认:
```shell
# a2enmod rewrite
```
> 如果你使用的是旧版 Apache<small>一般存在于会被叫做 httpd 的 apache</small>module 配置或许会在服务器里,这时候,大概你的 Apache 的配置文件(通常为 /etc/apache2/httpd.conf 或者 /etc/httpd/httpd.conf找到以下行并取消注释它
>
> ```apache
> # uncomment this line
> LoadModule rewrite_module libexec/apache2/mod_rewrite.so
> ```
然后,为你的 ph-Bookshelf 目录配置允许路径重写:
```apache
<Directory /path/to/your/ph-Bookshelf>
AllowOverride All
</Directory>
```
至此,你已经完成了 ph-Bookshelf 需要的所有配置。
你无需在 [Apache] 配置文件中配置路径重写规则,它已经存在在了 ph-Bookshelf 项目根目录下的 .htaccess 当中。
> 如果你是使用 php 站点托管,请询问你的托管服务商是否支持 [Apache] [.htaccess] 的使用。