Hello, I am assuming you already have digital ocean account and your droplet. Here are the prerequisites:
- Ubuntu 14.04
- LAMP installed
- You have SSH access
To check once that LAMP is installed and running, you can open the default page of the server by typing the IP address. You should see a default page from Apache. If you see it, great. Let’s get it rolling and in next 20 minutes you will be able to installe everything needed to get your Laravel 5 app up and running.
Step 1: Install Composer
Composer is a dependency manager for PHP. It’s great tool to setup libraries and automatically resolve dependency on the fly. I recommend using it even when there are no
curl -sS https://getcomposer.org/installer | php
Now when composer is installed it will produce a file named composer.phar. Phar is nothing but a PHP archive. You need to move this file to a place from where it’s accessible globally.
mv composer.phar /usr/local/bin/composer
Note: You might need to update permissions of the folder. It works perfectly fine on the droplet with Ubuntu image but it may require permission. Just use chown and or chmod to change permissions or ownership.
Step 2: Install Mcrypt Extension
Laravel 5 requires mcrypt php extension installed. Please follow these steps to setup mcrypt and have Apache load it. Type following commands to update DB and find mcrypt installation.
sudo updatedb locate mcrypt.ini
Should show it located at /etc/php5/mods-available. Now let’s locate the extension file
Edit mcrypt.ini and change extension to match the path to mcrypt.so, example:
php5enmod mcrypt - (optional since its already enabled during phpmyadmin setup)
Verify that new files exists here (they should be auto created from the issue above)
ls -al /etc/php5/cli/conf.d/20-mcrypt.ini ls -al /etc/php5/apache2/conf.d/20-mcrypt.ini
Otherwise do the following
Create symbol links now
ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/cli/conf.d/20-mcrypt.ini ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/apache2/conf.d/20-mcrypt.ini
service apache2 restart
Step 3: Setup Laravel 5
Now we are ready to setup Laravel 5. Please note that Laravel runs from public folder which makes it little tricky to setup as compared to other php applications.
Install Laravel 5 in /var/www/folder
Install Laravel 5 using composer create-project command.
composer create-project laravel/laravel --prefer-dist
This will create a folder laravel in your /var/www/. Now we have to move the contents of public folder from within laravel to /var/www/html/ folder. After that please edit index.php file to point to correct path for autoload.php. There are 2 lines you can easily find and edit the path with ../laravel to point it correctly to laravel folder.
Step 4: Enable Apache mod_rewrite
Apache uses mod_rewrite to make pretty URLs work. By default it’s disabled on the Apache so we need to enable it to get our app work properly.
sudo a2enmod rewrite
service apache2 restart
Step 4: Change Permissions
You might need to change permissions of the www folder to make it work. It is required if your application will be uploading files and storing on server etc.
# Group Writable (Group, User Writable) $ sudo chmod -R gu+w www # World-writable (Group, User, Other Writable) $ sudo chmod -R guo+w www