简体   繁体   中英

Laravel 4 on PHP built-in web server (CGI) instead of Apache

I am trying to run laravel4 on a service that cannot use Apache or nginx. everything is good till I wanted to use Routes on my project. I've tried using /index.php/... on the URL but could not make this work. is there any way to force laravel not to use .htaccess file or any ways to use raw PHP routing?

Try setting the "application.url" option in one of configuration files, probably in app/config/application.php or application/config/application.php:

https://github.com/laravel/laravel/blob/4cb904f44d24f856ec9c1040d2198ed8f009723b/application/config/application.php

Set it to http://127.0.0.1:54007/index.php . Now when laravel creates url it will use this as a root and the final urls should be like http://127.0.0.1:54007/index.php/account/signin .

Also you need to modify PHP Desktop settings so that it uses a fixed port. Edit settings.json file and set it like this:

"web_server": {
    "listen_on": ["127.0.0.1", 54007],

In laravel's .htaccess I've found this:

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

So it should work fine to add "/index.php" to root url, because this is what apache's mod_rewrite does.

If something doesn't work, take a look at some other files named "url.php", "uri.php".

Let us know if that works.

EDIT.
You may also try setting root url to "index.php", without the "http://". This way it wouldn't be required to set a fixed web server port.

UPDATE There was a bug in Mongoose web server in PHP Desktop, that prevented urls like "index.php/company/5" from working properly. See the __fix_mongoose_env_variables() php function in Issue 137 that fixes it:

https://code.google.com/p/phpdesktop/issues/detail?id=137

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM