xampp+yii2环境搭建

来源:互联网 发布:知乎 梵高 被高估 编辑:程序博客网 时间:2024/05/16 11:18
php配置文件说明http://www.cnblogs.com/xiaoshi1991/archive/2012/09/18/2690608.html

php开发流程
1、配置php开发环境,使用xampp
https://www.apachefriends.org/zh_cn/download.html

2、配置apache中的httpd-vhost.conf
     该文件中有两个默认的虚拟主机
    而实际上,这两个虚拟主机是不存在的,在没有配置任何其他虚拟主机时,可能会导致访问localhost时出现如下提示:
     Forbidden
  You don't have permission to access /index.php on this server
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/Applications/XAMPP/xamppfiles/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/Applications/XAMPP/xamppfiles/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error_log"
    CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
我的配置文件
配置虚拟主机,还需要将httpd.conf中的虚拟主机的注释去掉,相当于启用虚拟主机
# Virtual hosts
Include etc/extra/httpd-vhosts.conf

<VirtualHost jiuyuan:80>
    #ServerAdmin 737333500@qq.com
    DocumentRoot "/myspace/workspace/webdesign/html/jiuyuan"
    ServerName jiuyuan
    ServerAlias www.jiuyuan.com
    DirectoryIndex index.html
    <Directory "/myspace/workspace/webdesign/html/jiuyuan">  
        #Options -Indexes FollowSymLinks  
        #AllowOverride None  
        #Order allow,deny  
        #Allow from all  
        Require all granted 
    </Directory> 
    ErrorLog "logs/error_log"
    CustomLog "logs/access_log" common
</VirtualHost>

<VirtualHost phpfirst:80>
    #ServerAdmin 737333500@qq.com
    DocumentRoot "/myspace/workspace/webroot/phpfirst"
    ServerName phpfirst
    ServerAlias www.phpfirst.com
    DirectoryIndex index.html index.php
    <Directory "/myspace/workspace/webroot/phpfirst">  
        #Options -Indexes FollowSymLinks  
        #AllowOverride None  
        #Order allow,deny  
        #Allow from all  
        Require all granted 
    </Directory> 
    ErrorLog "logs/error_log"
    CustomLog "logs/access_log" common
</VirtualHost>
还需要在etc/hosts加上一条127.0.0.1 jiuyuanny
配置后需要终端关闭hosts对应进程sudo killall -HUP mDNSResponder
访问地址如下
http://jiuyuanny/jiuyuan/pages/product.html

1)在httpd.conf文件中已经配置了local访问的路径,默认是/Applications/XAMPP/xamppfiles/htdocs目录

3、安装php-eclipse,也可以使用sublime等工具

4、使用框架yii2
     
你可以通过Composer来安装这个模板。从这里下载Composer:http://getcomposer.org/,或者在Linux/Unix/MacOS平台上运行如下命令:
1
curl -s http://getcomposer.org/installer | php

然后你可以使用如下命令创建一个基础应用程序:

1
php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic /path/to/yii-application

 在Web服务器配置文件中设置 document root 目录为 /path/to/yii-application/web,你可以使用 URLhttp://localhost/ 来访问这个应用。
也可以在虚拟服务器中配置一个节点,用来访问这个目录的内容

问题
1、下载的过程中可能会遇到下载bootstrap没有权限的问题,需要你输入对应的网址获取token,然后在命令行中粘贴token,注意是不可见的
88785ac9dfda7f2e102ae962c8e6f256e98bdcc4

2、配置hosts和虚拟主机后,重启apache和hosts进程,正常的话就会出现yii界面,是用bootstrap构建的界面,还有可能会缺少jquery或者bootstrap文件,1)可以将bower下面bower-assert的文件移动到bower下面
2)可以在目录下面 /path/to/yii-application/vendor/yiisoft/yii2/base 
   第456行将目录bower改为bower/bower-assert
这样就可以直接通过配置在hosts中的域名访问虚拟主机,从而访问yii2了

0 0
原创粉丝点击