Laravel 5 installation on Ubuntu 14.04: Difference between revisions

→‎Post-installation updates: add a note for Nginx users
→‎Installation: add b.style to div.cli containers
→‎Post-installation updates: add a note for Nginx users
 
(9 intermediate revisions by 2 users not shown)
Line 29: Line 29:
Download Laravel installer using Composer.
Download Laravel installer using Composer.


<source lang="bash" highlight="1">
<div class="cli">
mhan@brahms:~$ composer global require "laravel/installer=~1.1"
<span style="color:#00ff00;">mhan</span><span style="color:#444444;">@</span><span style="color:#00cccc;">brahms</span><span style="color:#999999">:</span><span style="color:blue;">~</span><span style="color:#cccccc;">
Changed current directory to /home/mhan/.composer
$ <b class="color:white;">composer global require "laravel/installer=~1.1"</b>
./composer.json has been created
</span><br>
Loading composer repositories with package information
<span style="color:#00aa00">Changed current directory to /home/mhan/.composer<br>
Updating dependencies (including require-dev)
./composer.json has been created<br>
  - Installing symfony/process (v2.6.4)
Loading composer repositories with package information<br>
    Down    Downloading: 100%
Updating dependencies (including require-dev)<br></span>
 
&nbsp;&nbsp;<span style="color:#cccccc"><nowiki>- Installing</nowiki></span> <span style="color:#00aa00">symfony/process </span><span style="color:#cccccc">(</span><span style="color:#aaaa00">v2.6.4</span><span style="color:#cccccc">)</span><br>
  - Installing symfony/console (v2.6.4)
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#cccccc"><nowiki>Downloading: </nowiki></span><span style="color:#aaaa00">100%</span><br>
    Down    Downloading: 100%
<br>
 
&nbsp;&nbsp;<span style="color:#cccccc"><nowiki>- Installing</nowiki></span> <span style="color:#00aa00">symfony/console </span><span style="color:#cccccc">(</span><span style="color:#aaaa00">v2.6.4</span><span style="color:#cccccc">)</span><br>
  - Installing guzzlehttp/streams (2.1.0)
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#cccccc"><nowiki>Downloading: </nowiki></span><span style="color:#aaaa00">100%</span><br>
    Down    Downloading: 100%
<br>
 
&nbsp;&nbsp;<span style="color:#cccccc"><nowiki>- Installing</nowiki></span> <span style="color:#00aa00">guzzlehttp/streams </span><span style="color:#cccccc">(</span><span style="color:#aaaa00">v2.1.0</span><span style="color:#cccccc">)</span><br>
  - Installing guzzlehttp/guzzle (4.2.3)
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#cccccc"><nowiki>Downloading: </nowiki></span><span style="color:#aaaa00">100%</span><br>
    Down    Downloading: 100%
<br>
 
&nbsp;&nbsp;<span style="color:#cccccc"><nowiki>- Installing</nowiki></span> <span style="color:#00aa00">guzzlehttp/guzzle </span><span style="color:#cccccc">(</span><span style="color:#aaaa00">4.2.3</span><span style="color:#cccccc">)</span><br>
  - Installing laravel/installer (v1.2.0)
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#cccccc"><nowiki>Downloading: </nowiki></span><span style="color:#aaaa00">100%</span><br>
    Down    Downloading: 100%
<br>
 
&nbsp;&nbsp;<span style="color:#cccccc"><nowiki>- Installing</nowiki></span> <span style="color:#00aa00">laravel/installer </span><span style="color:#cccccc">(</span><span style="color:#aaaa00">v1.2.0</span><span style="color:#cccccc">)</span><br>
symfony/console suggests installing symfony/event-dispatcher ()
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#cccccc"><nowiki>Downloading: </nowiki></span><span style="color:#aaaa00">100%</span><br>
symfony/console suggests installing psr/log (For using the console logger)
<br><span style="color:#cccccc">
Writing lock file
symfony/console suggests installing symfony/event-dispatcher ()<br>
Generating autoload files
symfony/console suggests installing psr/log (For using the console logger)</span><br>
</source>
<span style="color:#00aa00">Writing lock file<br>
Generating autoload files</span>
</div>


Instead of adding <span class="shell">~/.composer/vendor/bin</span> to the PATH environment variable, I simply made a symbolic link to it in <span class="shell">~/bin/</span> folder.
Instead of adding <span class="shell">~/.composer/vendor/bin</span> to the PATH environment variable, I simply made a symbolic link to it in <span class="shell">~/bin/</span> folder.
Line 75: Line 77:
Compiling views<br>
Compiling views<br>
Application key [CJwBsllwDbWLlxy7zH7zRATmSu2laUyA] set successfully.<br>
Application key [CJwBsllwDbWLlxy7zH7zRATmSu2laUyA] set successfully.<br>
<span style="color: yellow">Application ready! Build something amazing.</span>
<span style="color: #aaaa00">Application ready! Build something amazing.</span>
</span>
</span>
</div>
</div>
Line 104: Line 106:
Update <span class="package">app.url</span>, <span class="package">app.timezone</span><ref name="timezone">''PHP Manual''. Program documentation. ''PHP Manual''. N.p., n.d. Web. 26 Feb 2015. <http://php.net/manual/en/timezones.php>.</ref>.
Update <span class="package">app.url</span>, <span class="package">app.timezone</span><ref name="timezone">''PHP Manual''. Program documentation. ''PHP Manual''. N.p., n.d. Web. 26 Feb 2015. <http://php.net/manual/en/timezones.php>.</ref>.


<source lang="php">
<syntaxhighlight lang="php">
<?php
<?php
// config/app.php
// config/app.php
Line 112: Line 114:
'timezone' => 'America/Denver',
'timezone' => 'America/Denver',
..
..
</source>
</syntaxhighlight>


It may be just fine to leave the timezone to UTC if you are going to be accommodate for user's particular timezone through some means. If the application isn't going to be serving users from different time zones and you don't plan to scale it then set it to your local one.
It may be just fine to leave the timezone to UTC if you are going to be accommodate for user's particular timezone through some means. If the application isn't going to be serving users from different time zones and you don't plan to scale it then set it to your local one.
Line 120: Line 122:
<div class="cli">
<div class="cli">
<span style="color:#00ff00;">mhan</span><span style="color:#444444;">@</span><span style="color:#00cccc;">brahms</span><span style="color:#999999">:</span><span style="color:blue;">/srv/www/sanban</span><span style="color:#cccccc;">
<span style="color:#00ff00;">mhan</span><span style="color:#444444;">@</span><span style="color:#00cccc;">brahms</span><span style="color:#999999">:</span><span style="color:blue;">/srv/www/sanban</span><span style="color:#cccccc;">
$ <b class="color:white;">sudo chown -R www-data:mhan storage</b>
$ <b class="color:white;">sudo chown -R www-data:www-data storage</b>
</span><br>
<span style="color:#00ff00;">mhan</span><span style="color:#444444;">@</span><span style="color:#00cccc;">brahms</span><span style="color:#999999">:</span><span style="color:blue;">/srv/www/sanban</span><span style="color:#cccccc;">
$ <b class="color:white;">sudo chmod -R 0664 storage</b>
</span><br>
<span style="color:#00ff00;">mhan</span><span style="color:#444444;">@</span><span style="color:#00cccc;">brahms</span><span style="color:#999999">:</span><span style="color:blue;">/srv/www/sanban</span><span style="color:#cccccc;">
$ <b class="color:white;">sudo find storage -type d -exec chmod 2775 '{}' \;</b>
</span>
</span>
</div>
<div class="mw-geshi">
NOTE FOR NGINX USERS: I know this instruction was originally written for Apache web server, but if you're using Nginx and you happen to be using something else than Ubuntu, then you can replace the line that contains 'www-data' with the following:
$ sudo chown -R `grep user /etc/nginx/nginx.conf | sed 's/user //g; s/;//g'`:`grep user /etc/nginx/nginx.conf | sed 's/user //g; s/;//g'` storage
</div>
</div>


Line 149: Line 163:
If you use VIM like I do, you can insert this into your <span class="shell">~/.vimrc</span> file and just hit <code>,t</code> (comma and then t) key combination to run the unit test wherever you are under the project directory. This is a bit long because I have some repetitive bash commands to automatically detect the current application name and use that, i.d. "sanban" in this example.
If you use VIM like I do, you can insert this into your <span class="shell">~/.vimrc</span> file and just hit <code>,t</code> (comma and then t) key combination to run the unit test wherever you are under the project directory. This is a bit long because I have some repetitive bash commands to automatically detect the current application name and use that, i.d. "sanban" in this example.


<source lang="vim">
<syntaxhighlight lang="vim">
nmap ,t :!if [ -d .git ] \|\| git rev-parse --git-dir > /dev/null 2>&1; then phpunit.$(cat $(git rev-parse --show-toplevel)/phpspec.yml \| grep "namespace" \| awk '{print tolower(substr($0,20));exit}') -c $(git rev-parse --show-toplevel); else phpunit.$(cat $(git rev-parse --show-toplevel)/phpspec.yml \| grep "namespace" \| awk '{print tolower(substr($0,20));exit}'); fi<cr>
nmap ,t :!if [ -d .git ] \|\| git rev-parse --git-dir > /dev/null 2>&1; then phpunit.$(cat $(git rev-parse --show-toplevel)/phpspec.yml \| grep "namespace" \| awk '{print tolower(substr($0,20));exit}') -c $(git rev-parse --show-toplevel); else phpunit.$(cat $(git rev-parse --show-toplevel)/phpspec.yml \| grep "namespace" \| awk '{print tolower(substr($0,20));exit}'); fi<cr>
</source>
</syntaxhighlight>


In order for this to work properly your project directory has to be initialized as a git repository.
In order for this to work properly your project directory has to be initialized as a git repository.
Line 196: Line 210:
== References ==
== References ==
<div class="references-small"><references /></div>
<div class="references-small"><references /></div>
[[Category:Web development]][[Category:Laravel]]