dragon19720808 2014-12-14 18:27
浏览 59

找不到GID请求的angularjs slim 404

I have browsed through the related posts here, but i cannot seem to get my application working.

I decided to use generator-angular-php to quickly setup an end-to-end application.

When i use grunt serve the application seem to work as intended, so i decided to put it, as is, on my apache server. I build it with grunt, and copied the files in the dist-folder to my /var/www//public_html/

The structure is as follows:

  • /public_html/
    • index.html
    • styles : css
    • views : view partials .html
    • scripts : angularjs controllers
    • api
      • index.php
      • .htaccess #1
      • vendor
        • autoload.php
        • slim
          • slim
            • index.php
            • .htaccess #2
            • Slim
              • slim php files eg Route.php
        • plenty of other dirs, eg. sebastian, doctrine...
      • tests
      • src : the example Api
The .htaccess #1 looks as follows:
 RewriteEngine On    
 RewriteCond %{REQUEST_FILENAME} !-f    
 RewriteCond %{REQUEST_FILENAME} !-d    
 RewriteRule ^ index.php [QSA,L]    

The first index.php contains

<?php
error_reporting(-1);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
date_default_timezone_set('UTC');

try {

    // Initialize Composer autoloader
    if (!file_exists($autoload = __DIR__ . '/vendor/autoload.php')) {
        throw new \Exception('Composer dependencies not installed. Run `make install --directory app/api`');
    }
    require_once $autoload;

    // Initialize Slim Framework
    if (!class_exists('\\Slim\\Slim')) {
        throw new \Exception(
            'Missing Slim from Composer dependencies.'
            . ' Ensure slim/slim is in composer.json and run `make update --directory app/api`'
        );
    }

    // Run application
    $app = new \Api\Application();
    $app->run();

} catch (\Exception $e) {
    if (isset($app)) {
        $app->handleException($e);
    } else {
        http_response_code(500);
        header('Content-Type: application/json');
        echo json_encode(array(
            'status' => 500,
            'statusText' => 'Internal Server Error',
            'description' => $e->getMessage(),
        ));
    }
}

The .htaccess #2 looks as follows:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA]

The second index.php contains php code to:

-Slim Framework and register its PSR-0 autoloader.
-Instantiate a Slim application
-Define the Slim application routes (get, post, put etc

In my site-enable file for my site i have:

<VirtualHost *:80>
    ServerAdmin hanto899@myphpportfolio.com
    ServerName myphpportfolio.com
    ServerAlias www.myphpportfolio.com
    DocumentRoot /var/www/myPhpPortfolio/public_html
    ErrorLog /var/www/myPhpPortfolio/public_html/error.log
    CustomLog /var/www/myPhpPortfolio/public_html/access.log combined

    <Directory "/var/www/myPhpPortfolio/public_html">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

I have enabled the rewrite-mod.

However, when i open up my site in a browser, i get an:

GET http://myphpportfolio.com/api/features 404 (Not Found)

with the response:

{"status":404,"statusText":"Not Found","description":"Resource \/features using GET method does not exist."}

I haven't altered the code in any way, and since it works durig grunt serve, I am guessing it should work without any alterering (?) This is giving me more gray hairs, and I am out of ideas...what am I missing!

  • 写回答

1条回答 默认 最新

  • dongyin4202 2015-08-20 01:39
    关注

    Check permissions on the copied file and ownership.

    When grunt builds and creates the final directory, it may change permissions and possibly ownership of the output files from /dist. chmod 755 -R the html directory with your website and possibly change owner(root?).

    Also, those generators are sometimes configured to put out multiple builds builds....one for testing and one for live hosting.

    For example, grunt test might output the images to a temp directory while grunt build outputs to /dist/images.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?