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 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试