您的位置:首页 > 编程语言 > PHP开发

PHP开发框架HushFrameword在阿里服务器Windows Server2012上的环境搭建正确方法

2015-10-29 16:04 811 查看
1.将hush-master文件夹放入local中,打开命令行,输入cd D:\local\hush-master\hush-app\bin,根据提示输入。数据库类型:mysql,用户名:root,密码:1234,端口:3306.直到安装完成。确定PHP和Mysql的主程序目录已加入系统环境变量。要看自己改的hush-lib里面的配置文件,有的是mysql,有的是mysqli,可以先试一下mysql,有问题再用MySQLi.
2.打开httpd.conf ,取消 LoadModule rewrite_module modules/mod_rewrite.so前的注释。

取消Include conf/extra/httpd-vhosts.conf前的注释。
3.如果报警:PHP Warning: PHP Startup: in Unknown on line 0 about php_curl.dll :把php根目录下的libeay32.dll、ssleay32.dll copy to C:\WINDOWS\system32; 复制 php中的libsasl.dll 到 apache/bin 路径下,重新启动apache,没有警告了。
4.打开D:\local\Apache24\conf \extra中的httpd-vhosts.conf,去掉默认实例,添加

<pre name="code" class="objc" style="margin-top: 4px; margin-bottom: 4px;"><pre name="code" class="plain" style="margin-top: 4px; margin-bottom: 4px;"><span style="font-size:18px;">Listen 8001
<VirtualHost *:8001>
DocumentRoot "D:/local/hush-master/hush-app/web/backend/"
ServerName hush-app-backend
<Directory "D:/local/hush-master/hush-app/web/backend/">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
RewriteEngine on
RewriteRule !\.(php|htm|js|ico|gif|jpg|png|css|swf|pdf|doc|xls|txt|ppt|zip|rar)$ index.php
</Directory>
</VirtualHost>

Listen 8002
<VirtualHost *:8002>
DocumentRoot "D:/local/hush-master/hush-app/web/frontend/"
ServerName hush-app-frontend
<Directory "D:/local/hush-master/hush-app/web/frontend/">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
RewriteEngine on
RewriteRule !\.(php|htm|js|ico|gif|jpg|png|css|swf|pdf|doc|xls|txt|ppt|zip|rar)$ index.php
</Directory>
</VirtualHost></span>
<span style="font-size:18px;">
</span>




以上的代码是设置了端口的,因为我的Apache的端口设置了8080,用8080的话会直接跳到htdoc那个文件夹,所以改成了8001和8002,这个一定要注意。C:/windows/system32/drivers/etc/host文件可以不用改,不改的话就用127.0.0.1:8001或8002访问,也可以用localhost:8001访问,但是如果Apache设置的是80端口的话,那就必须改了:host文件最下面添加如下代码:

<span style="font-size:18px;">127.0.0.1 hush-app-frontend
127.0.0.1 hush-app-backend</span>
另外80端口的httpd-vhosts.conf文件代码如下:
<span style="font-size:18px;"><VirtualHost *:80>
DocumentRoot "D:/local/hush-master/hush-app/web/backend/"
ServerName hush-app-backend
<Directory "D:/local/hush-master/hush-app/web/backend/">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
RewriteEngine on
RewriteRule !\.(php|htm|js|ico|gif|jpg|png|css|swf|pdf|doc|xls|txt|ppt|zip|rar)$ index.php
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "D:/local/hush-master/hush-app/web/frontend/"
ServerName hush-app-frontend
<Directory "D:/local/hush-master/hush-app/web/frontend/">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
RewriteEngine on
RewriteRule !\.(php|htm|js|ico|gif|jpg|png|css|swf|pdf|doc|xls|txt|ppt|zip|rar)$ index.php
</Directory>
</VirtualHost></span>
5.打开D:\local\hush-master\hush-lib\Hush\Db中的Config.php,
<span style="font-size:18px;">abstract class Hush_Db_Config
{
/**
* 默认数据库参数
* @static
*/
const DEFAULT_TYPE = 'MYSQLI';
const DEFAULT_HOST = '127.0.0.1';
const DEFAULT_PORT = '3306';
const DEFAULT_USER = 'root';
const DEFAULT_PASS = '1234';</span>


按上面的代码修改,密码自己改,类型不要动,如果出现无法访问的情况应该是初始化hush-master的时候数据库类型设置错,mysql和mysqli两种中试试另一种。

6.大功告成,重启Apache。对于Apache无法启动的情况,用命令行启动Apache(打开命令行,输入D:进入D盘,然后输入cd D:\local\Apache24\bin,然后再输入httpd -h是帮助,httpd -k start是启动,httpd -k restart是重启),查看错误。

最后附上各种资源,包括PHP+Mysql+Apache环境搭建包+HushFramework框架+ZendFramework框架+SamrtyFramework框架。

PHP开发交流群:452809188

资源
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: