-
Notifications
You must be signed in to change notification settings - Fork 0
/
Install Laravel 5.2 on Ubuntu 16.04.txt
225 lines (156 loc) · 6.28 KB
/
Install Laravel 5.2 on Ubuntu 16.04.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
// basic stuff install
sudo apt-get install git
sudo apt-get install unzip
// LAMP
sudo apt-get install tasksel
sudo tasksel install lamp-server
// CURL + Composer
sudo apt-get install curl php-curl php-mcrypt php-mbstring php-gettext
// enable mods
sudo phpenmod mcrypt
sudo phpenmod mbstring
sudo a2enmod rewrite
sudo systemctl restart apache2
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
//install phpmyadmin
sudo apt-get install phpmyadmin
# later accessible through localhost/phpmyadmin
If you get a 404 error upon visiting http://localhost/phpmyadmin: You will need to configure apache2.conf to work with Phpmyadmin.
$ sudo gedit /etc/apache2/apache2.conf
Include the following line at the bottom of the file, save and quit.
$ Include /etc/phpmyadmin/apache.conf
Then, try to acccess localhost/phpmyadmin again
//Creating Laravel Project
cd /var/www/html/
sudo composer create-project laravel/laravel work --prefer-dist
sudo chmod -R 777 work
//Creating Virtual Host work.com
sudo leafpad /etc/apache2/sites-available/work.com.conf
#/etc/apache2/sites-available/work.com.conf contains following lines
<VirtualHost *:80>
ServerName work.com
DocumentRoot /var/www/html/work/public
<Directory /var/www/html/work/public>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
// enable that site
sudo a2ensite work.com
service apache2 reload
// fix hosts file
sudo leafpad /etc/hosts
#/etc/hosts contents following lines
127.0.0.1 work.com
or use this command
sudo -- sh -c "echo '\n127.0.0.1 \twork.com'>> /etc/hosts"
// make permanent aliases:
echo "alias cls='clear'" >> ~/.bash_aliases && source ~/.bash_aliases
echo "alias sudo='sudo '" >> ~/.bash_aliases && source ~/.bash_aliases
echo "alias fm='pcmanfm'" >> ~/.bash_aliases && source ~/.bash_aliases
That's it laravel is installed!
##########################################################################################################
NOW CONFIGURE WORKING ENVIRONMENT
// fix for adding repositories so you can download software from other sources
sudo apt-get install software-properties-common
// install sublime-text 3
sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer
// install sublime packages
Ctrl + ` or View/Show Console
import urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
restart sublime-text
then go to Preferences/Package Control and install
#Laravel Blade Highlighter
#Sidebar-Enhancements
#LaravelCollective HTML Form Snippets
"CodeComplice",
"Laravel Helper Completions",
"Terminal"
// this is for removing and uninstalling sublime text
sudo apt-get purge sublime-text-installer
sudo rm -r /opt/sublime_text
sudo rm -r /usr/bin/subl
sudo rm -r /usr/share/applications/sublime.desktop
sudo rm -r /home/laravel/Desktop/sublime-text.desktop
sudo rm -r /home/laravel/.config/sublime-text-3
// how to create snippets for html or any code
got to Tools/New Snippet
<snippet>
<content><![CDATA[
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>$1</title>
</head>
<body>
$2
</body>
</html>
]]></content>
<tabTrigger>html</tabTrigger>
</snippet>
paste that ^ and save as *.sublime-snippet inside sublime/packages/user folder
// change default server directory *OPTIONAL!
sudo leafpad /etc/apache2/sites-available/000-default.conf
and change the following line to what you want:
DocumentRoot /var/www/html
Also do a
sudo leafpad /etc/apache2/apache2.conf
and find this
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
and change /var/www/ to your preferred directory //mine is /var/www/html/work/public
and save it.
After you saved your changes, just restart the apache2 webserver and you'll be done :)
sudo service apache2 restart
// make laravel app to be the landing (localhost) site instead of apache2 /*optional
sudo a2dissite 000-default
// this is to enable it
sudo a2ensite 000-default
########################################################################################################
CONFIGURE SOME EXTRA STUFF TO MAKE CODING EASIER
//install form and html and input classes
../laravel_folder/composer.json
-----------------------------------------------------
"require": {
"laravelcollective/html": "5.2.*"
}
-----------------------------------------------------
../laravel_folder/config/app.php
-----------------------------------------------------
'providers' => [
// ...
Collective\Html\HtmlServiceProvider::class,
// ...
],
'aliases' => [
// ...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
// ...
],
------------------------------------------------------
in terminal go to laravel_app_folder and run
sudo composer update
That's it everything set for working with Laravel 5.2
################################################################
// install generators for migrations
sudo composer require laracasts/generators --dev
inside app/Providers/AppServiceProvider.php change public function register
public function register()
{
if ($this->app->environment() == 'local') {
$this->app->register('Laracasts\Generators\GeneratorsServiceProvider');
}
}
now you can do this
sudo php artisan make:migration:schema create_roles_table --schema="name:string"
sudo php artisan make:migration:schema remove_user_id_from_posts_table --schema="user_id:integer"
sudo php artisan make:migration:pivot tags posts