WitekO's avatar

Lumen - routing not working - beginer

Hi

I instaled lumen with default settings and add virtual host www.localhost.com to apache2. When I type http://localhost.com browser show word "Lumen" - lumen work. I create another route "/test" but it is not working when type http://localhost.com/test

All settings are default

routes.php:

$app->get('/', function () use ($app) { return $app->welcome(); });

$app->get('/test', function () { return 'Test dzialania LUMENTest dzialania LUMEN'; });

PS. sorry for my english. I come from Poland

0 likes
3 replies
jimmck's avatar

Create a virtual host named lumen. What server are you running?

<VirtualHost lumen:80>
ServerName lumen
DocumentRoot "/Users/jimm/GitHub/lumen/public"
</VirtualHost>
<Directory "/Users/jimm/GitHub/lumen/public">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
#   onlineoffline tag - don't remove
     Order Deny,Allow
     #Deny from all
     Allow from all
     Allow from 127.0.0.1
     #Allow from ::1
     Allow from localhost
     Allow from lumen
</Directory>
WitekO's avatar

I use apache2 installed on xubuntu. Why virtual host name is "lumen"?

To configure I used: http://saravanan.tomrain.com/installing-laravel-lumen-with-apache-server/ and https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts

It is my virtual host settings:

<VirtualHost *:80>
ServerName localhost.com ServerAlias www.localhost.com ServerAdmin admin@localhost.com DocumentRoot /var/www/html/cpf_WebService/public/ ErrorLog ${APACHE_LOG_DIR}/cpf_WebService_error.log CustomLog ${APACHE_LOG_DIR}/cpf_WebService_access.log combined

and default .htaccess in myProj/public folder:

Options -MultiViews RewriteEngine On # Redirect Trailing Slashes... RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L]

I configure my virtaul host like you wrote but not working - "The requested URL /test/ was not found on this server"

WitekO's avatar

I solved problem

Solution:

  1. enable model rewrite: sudo a2enmod rewrite && sudo service apache2 restart

  2. Copy .htaccess from slim/slim folder to folder with my index.php (/myapp/)

  3. correct virtual host : <VirtualHost *:80> ServerName localhost.com ServerAlias www.localhost.com ServerAdmin [email blocked] DocumentRoot /var/www/html/cpf_WebService/public/

ErrorLog ${APACHE_LOG_DIR}/cpf_WebService_error.log CustomLog ${APACHE_LOG_DIR}/cpf_WebService_access.log combined

#########ADDED ##################### <Directory "/var/www/html/cpf_WebService/public/"> AllowOverride All Order allow,deny Allow from all ##############################

Please or to participate in this conversation.