一、背景
有個老項目用的thinkphp寫的,咱也沒接觸過啊,只能先搭個本地環境測試一下了
二、實操
基礎的搭建網上示例挺多的,版本的話按着需要來吧,大同小異。
下面給一個網址,個人覺得非常好的例子
https://blog.csdn.net/zhangtao0417/article/details/81534227主要介紹php+apache的環境搭建
https://blog.csdn.net/zhuanshu666/article/details/74936940[1]主要介紹apache添加CGI功能
現在問題主要,thinkPHP這個框架貌似用的CGI技術(別問我為什么知道,看項目原來配置猜的)。然后由於吃了沒文化的虧,一直不知道問題出哪里,一直報下面這個錯
接下來就是頓悟時刻了,按照這么多年對於程序的理解,程序得執行啊,按照[1]最后給的一個python示例,我猜想<Directory>里面的配置就是允許apache進行CGI執行相關設置,也就是這幾行代碼,參看鏈接【1】
AllowOverride All
Options +ExecCGI
Order allow,deny
Allow from all
然后博主把它的py文件放到了自己設置的directory下面,然后我就嘗試着把自己的website,即thinkPHP項目所在的文件夾的directory設置給改了,如下
DocumentRoot "${SRVROOT}/htdocs/"
<Directory "${SRVROOT}/htdocs/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
#Options Indexes FollowSymLinks#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
#AllowOverride None#
# Controls who can get stuff from this server.
#
#Require all granted
AllowOverride All
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
大概在265行吧,結果成功跳轉,具體頁面就不放了哈~
三、總結
其實現在想想的話,其實如果thinkPHP用的CGI技術,那么應該給它所在的目錄設置相應執行設置即可!有點被鏈接【1】里面的cgi-bin文件夾慣例給限制思路了。
這次的經歷挺有意思的,哈哈哈。
ps:不會使php,CGI是啥也不太懂,就很尷尬啊