安装CakePHP

时间:2015-02-03 08:06:02

标签: cakephp

我想在每个项目的xampp服务器上安装CakePHP。 根/ PROJECT1 根/项目2

我想通过localhost / project1,localhost / project2访问它。 Project1将是我的测试站点,另一个将是发布。 这是一条错误消息"无法找到project1Controller"

<VirtualHost *:80>
   ServerName localhost
   ServerAlias localhost/project1
   ServerAdmin admin@yahoo.com
   DocumentRoot "C:/root/cakephp/project1/app/webroot"
   <Directory />
      Options FollowSymLinks
      AllowOverride FileInfo
      Require all granted
   </Directory>
</VirtualHost>

<VirtualHost *:80>
   ServerName localhost
   ServerAlias localhost/project2
   ServerAdmin admin@yahoo.com
   DocumentRoot "C:/root/cakephp/project2/app/webroot"
   <Directory />
      Options FollowSymLinks
      AllowOverride FileInfo
      Require all granted
   </Directory>
</VirtualHost>

请告诉我。 谢谢

3 个答案:

答案 0 :(得分:3)

您的DocumentRoot不应该是webroot文件夹,它必须是整个Cake项目的根。尝试将其更改为:

<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost/project1
  ServerAdmin admin@yahoo.com
  DocumentRoot "C:/root/cakephp/project1"
  <Directory />
     Options FollowSymLinks
     AllowOverride FileInfo
     Require all granted
  </Directory>
</VirtualHost>

Cake的.htaccess和前端控制器将为您处理路由。您无需尝试直接访问webroot。

答案 1 :(得分:0)

我在配置Apache时遇到了同样的问题,直到我放弃并更改为Hiawatha,更容易配置,并且根据某些基准测试比Apache更快。

以下是如何使用Hiawatha-PHP-MariaDB 设置服务器的收据:

  1. 安装MariaDB

    sudo yum -y install mariadb mariadb-server
    sudo systemctl start mariadb.service
    sudo systemctl enable mariadb.service
    
  2. 配置mysql:

    sudo mysql_secure_installation
    
  3. 安装Hiawatha:

    sudo yum install yum-utils
    sudo yum-config-manager --add-repo http://repo.hiawatha.be 
    sudo rpm --import http://repo.hiawatha.be/pubkey 
    sudo yum install hiawatha
    sudo systemctl enable hiawatha.service
    
  4. 安装php5-fpm:

    sudo yum -y install php-fpm php-mysql php-cli
    sudo nano /etc/php.ini
    
  5. 设置此参数:cgi.fix_pathinfo = 0

  6. 删除评论:

    #pm.min_spare_servers = 5 
    #pm.max_spare_servers = 35
    
  7. 重启php-fpm:

    systemctl restart php-fpm.service
    
  8. 这是/etc/hiawatha/hiawatha.conf文件:

    ServerId = www-data
    ConnectionsTotal = 1000
    ConnectionsPerIP = 25
    SystemLogfile = /var/log/hiawatha/system.log
    GarbageLogfile = /var/log/hiawatha/garbage.log
    Binding {
            Port = 80
    }
    Binding {
            Port = 443
            SSLcertFile = /etc/hiawatha/serverkey.pem
    }
    
    CGIhandler = /usr/bin/php5-cgi:php,php5
    
    FastCGIserver {
            FastCGIid = PHP5
            ConnectTo = 127.0.0.1:9000
            Extension = php
    }
    
    UrlToolkit {
       ToolkitID = cakephp
       RequestURI exists Return
       Match .* Rewrite /index.php
    }
    
    Hostname = serverIpAddress
    WebsiteRoot = /var/www
    StartFile = index.html
    AccessLogfile = /var/log/hiawatha/access.log
    ErrorLogfile = /var/log/hiawatha/error.log
    UseFastCGI = PHP5
    
    VirtualHost {
            Hostname = www.example.com
            WebsiteRoot = /var/www/example.com
            StartFile = index.php
            AccessLogfile = /var/www/example.com/access.log
            ErrorLogfile =  /var/www/example/error.log
            RequireSSL = yes
            TimeForCGI = 5
            UseFastCGI = PHP5
            UseToolkit = cakephp
    }
    VirtualHost {
            Hostname = host2.example.com
            WebsiteRoot = /var/www/anotherexample
            StartFile = index.php
            AccessLogfile = /var/www/anotherexample/logs/access.log
            ErrorLogfile =  /var/www/anotherexample/logs/error.log
            RequireSSL = yes
            TimeForCGI = 5
            UseFastCGI = PHP5
            UseToolkit = cakephp
    }
    

答案 2 :(得分:0)

对于新版本(Cakephp 3.x),您只能使用

打开命令提示符并转到项目目录。在此之后运行此命令

bin\cake server

当您的命令执行时,您的默认服务器将是localhost:8765