The main problem of Laravel setup on codenvy is that we can not run with command
php artisan serve
even with port option because codenvy do not allow any other connection than apache's port.
So what can we do? We can install Laravel in a Subfolder.
We can use a solution whuch we read here: Installing Laravel in a Subfolder?
Typically the path to the web root is something like this
/var/www/html
All the contents of Laravel's “public” folder would go in folder:
/var/www/html/my-laravel-site
We can put the rest of Laravel folders and files in another place outside of web root :
/var/www/my-laravel/
Then for the final steps modify your “my-laravel-site/index.php” file and adjust the following two paths.
// blog/index.php change to point to /var/www/my-laravel/
require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
First in our project directory we install Laravel via Composer from terminal:
composer create-project --prefer-dist laravel/laravel my-laravel-site
(see Installing Laravel)
Then we set permissions to Laravel folders.
chmod -R 777 storage bootstrap/cache
As we said we can not start a development server with php artisan serve
so we have two options:
1.If we can use a domain name we can configure vhosts to accept by name to subfolder cause all have the same port
(see Multiple Laravel projects on the same webserver )
Example:
Listen 80
<VirtualHost *:80>
DocumentRoot "/var/www/alpha/public"
ServerName alpha.dev # Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/beta/public"
ServerName beta.dev # Other directives here
</VirtualHost>
2. If we can not use a domain names then we must make Laravel's “public” folder var/www/html/my-laravel-site
Apache's DocumentRoot directory (see Steps for configuring Laravel on Apache HTTP Server )
In this step, we’ll create a new site configuration named
laravel_project.conf
which contains our named virtual host configuration. All of the files that we’ll be working with are system files owned by the root
user, so we must use sudo
command with all of them.
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/laravel.conf
sudo nano /etc/apache2/sites-available/laravel_project.conf
Modify the laravel_project.conf
contents so that they look like this:
<VirtualHost *:8080>
ServerAdmin admin@example.com
ServerName laravel.dev
ServerAlias www.laravel.dev
DocumentRoot /var/www/html/my-laravel-site
<Directory /var/www/html/my-laravel-site/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable new virtual host anddisable the default virtual host.
sudo a2ensite laravel_project.conf
sudo a2dissite 000-default.conf
Now, we are ready to restart Apache server and see if everything works! To restart the server:
sudo services apache2 restart