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 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值