How to set up SQLITE for laravel webserver?

I want to use SQLITE for my laravel5 project on my webserver. I migrated my local laravel 5 project onto my AWS ec2 lamp Ubuntu server. http://realtoraxe.com/realtoraxe/public/ but it shows

InvalidArgumentException in SQLiteConnector.php line 34: Database does not exist.

I changed the database.php set for sqlite

 <?php
 return array(
    'default' => 'sqlite',
    'connections' => array(
    'sqlite' => array(
    'driver'   => 'sqlite',
    'database' =>    'http://realtoraxe.com/realtoraxe/storage/database.sqlite',
    'prefix'   => '',
     ),
   ),
  );
 ?>

and I changed the .env to

APP_ENV=local
APP_DEBUG=true
APP_KEY=mystring
DB_CONNECTION=sqlite
CACHE_DRIVER=file
SESSION_DRIVER=file

when I do php artisan migrate it says there is no database

I think what I wrote as the path for the database in the database.php is wrong and do I may need to somehow write where my ip adress is in the .env file? I have been googling all night and can't seem to figure this out.

Upvotes: 2

Views: 13463

Answers (3)

user5205015
user5205015

Reputation:

For default laravel 5.2+ installation:

create an sqlite database file

$ cd storage
$ touch database.sqlite
$ cd ..

make it writeable

$ chmod -R 777 storage

at ".env" file:

DB_CONNECTION=sqlite
DB_DATABASE=storage/database.sqlite

and remove or comment all other DB_* records

If you prefer to use relative path, instead of absolute to database file at "config/database.php"

instead of:

'database' => env('DB_DATABASE', database_path('database.sqlite')),

write:

'database' => __DIR__ . '/../' . env( 'DB_DATABASE' ),

now, laravel app will be able to find sqlite file, and php artisan will work too

Upvotes: 5

The Surrican
The Surrican

Reputation: 29866

You dont need to edit the .php files at all. You can all do it in the .env file, since the files in the config directory are written to first use the values from the .env file, and if they are not defined, fall back on what is defined there.

env('DB_CONNECTION','mysql') would yield the value from the .env file, and only if it is not defined fall back to mysql.

So in your .env file just put the following:

DB_CONNECTION=sqlite DB_DATABASE=database/database.sqlite and create a file called database.sqlite in your database directory (thats where its supposed to be by convention.). That's it.

Upvotes: 9

Alexey Mezenin
Alexey Mezenin

Reputation: 163768

Why are you using HTTP link? I guess it should link to a .sqlite DB file:

'database' => __DIR__.'/../database/production.sqlite',

http://laravel-recipes.com/recipes/118/setting-up-the-sqlite-database-driver

Upvotes: 2

Related Questions