Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to get the php-microframework Silex up and running with lighty (local installation for debugging) on my ubuntu machine. The phpinfo() gets processed properly by the webserver.

Here is my lighttpd.conf

server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_redirect",
#   "mod_fastcgi",
"mod_rewrite",  
)    

#server.document-root        = "/var/www"
server.document-root        = "~/projects/silex"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"

index-file.names            = ( "index.php", "index.html",
                            "index.htm", "default.htm",
                           " index.lighttpd.html" )

url.access-deny             = ( "~", ".inc" )

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

## Use ipv6 if available
#include_shell "/usr/share/lighttpd/use-ipv6.pl"

dir-listing.encoding        = "utf-8"
server.dir-listing          = "enable"

scompress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/x-javascript", "text/css", "text/html",         "text/plain" )

include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

fastcgi.server = ( ".php" => ((
        "bin-path" => "/usr/bin/php-cgi",
        "socket" => "/tmp/php.sock"
        )))
url.rewrite-once = (
# configure some static files
"^/assets/.+" => "$0",
"^/favicon\.ico$" => "$0",

"^(/[^\?]*)(\?.*)?" => "/index.php$1$2"
)

As you can see above I've added the rewrite-rules mentioned in the silex documentation. Everytime I access the document root folder and navigate to the index.php the webserver delivers the page as is and promt plain php.

For sure, the group www-data is added to the document root and has read/write/execute rights.

The module fastcgi was loaded using lighttpd-enable-mod fastcgi followed by a /etc/init.d/lighttpd force-reload.

Navigating to localhost, localhost/index.php or localhost/web/index.php retrieves a 404 status code.

Below is the folder structure:

├── composer.json 
├── composer.lock
├── index.php.old
├── vendor
│   ├── autoload.php
│   ├── composer
│   │   ├── autoload_classmap.php
│   │   ├── autoload_namespaces.php
│   │   ├── autoload_real.php
│   │   ├── ClassLoader.php
│   │   └── installed.json
│   ├── doctrine
│   │   ├── common
│   │   └── dbal
│   ├── monolog
│   │   └── monolog
│   ├── pimple
│   │   └── pimple
│   ├── silex
│   │   └── silex
│   ├── swiftmailer
│   │   └── swiftmailer
│   ├── symfony
│   │   ├── browser-kit
│   │   ├── config
│   │   ├── console
│   │   ├── css-selector
│   │   ├── dom-crawler
│   │   ├── event-dispatcher
│   │   ├── filesystem
│   │   ├── finder
│   │   ├── form
│   │   ├── http-foundation
│   │   ├── http-kernel
│   │   ├── locale
│   │   ├── monolog-bridge
│   │   ├── options-resolver
│   │   ├── process
│   │   ├── routing
│   │   ├── security
│   │   ├── serializer
│   │   ├── translation
│   │   ├── twig-bridge
│   │   └── validator
│   └── twig
│       └── twig
└── web
    └── index.php

Thanks in advance!

share|improve this question
    
So does /index.php (with no additional path or query parameters) not get executed? –  mgorven Mar 12 '13 at 0:32
    
If I put a simple 'Hello World' or phpinfo() in index.php it will be evaluated and executed as it should be. When I'm using Silex related stuff, nothing happens - I get only the plain php code. I assume that maybe something is wrong with the rewrite rule. –  pschmidt Mar 12 '13 at 17:05
    
Please give an example of a URL which doesn't execute the PHP. –  mgorven Mar 12 '13 at 17:36
    
I've updated the post with more information. The index.php.old file was renamed just for debugging. –  pschmidt Mar 13 '13 at 1:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.