I am trying to run a laravel project on a remote server without executing artisan command. The design is executing properly. But I am not able to connect with the database. I edited the.env and databse.php file as per my requirements. Here I am attaching the connection code
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mydb
DB_USERNAME=user
DB_PASSWORD=secret
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'mydb'),
'username' => env('DB_USERNAME', 'user'),
'password' => env('DB_PASSWORD', 'secret'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
What should i do for this issue?
Steps for running laravel project without executing artisan command
Need to install laravel framework on /var/www/html/laravel
Change the index.php file to
require DIR .'/vendor/autoload.php';
$app = require_once DIR .'/bootstrap/app.php';
Edit server.php
if ($uri !== '/' && file_exists( DIR .'/public'.uri)) { return false; }
require_once DIR .'/index.php';
Create laravel.conf file in /etc/apache2/sites-available/
Listen 8000
<VirtualHost *:80>
ServerName ip_of_server
ServerAdmin username@ipaddress
DocumentRoot /var/www/html/laravel // specify the project location
<Directory /var/www/html/laravel>
Options Indexes MultiViews
AllowOverride None
Require all granted
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
http://ip of the vm/index.php
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.