Laravel5 installation database configuration template routing installation;
Windows installation
PHP version = is required and mcrypt encryption extension is enabled
Do not want to install can be downloaded from the https://github.com/overtrue/latest-laravel here to sort out the good, unzip it to use
First, wait for the installation of cpmposer. if openssl is prompted, open the PHP. INI configuration file and remove the comments before extension = php_openssl.dll, which is about 887th lines.
The copmposer installation process will not be mentioned.
The installation process of Laravel 5 is started below, github has Download, here share a network disk connection: http://pan.baidu.com/s/1dD50dWH
Download and decompress the package. you can decompress the package to the root directory of the website. I will decompress the package to F:/laravel [of course, this is not my root directory, you need to configure the virtual host].
As we all know, the installation of composer in China is slow, and laravel is recommended for image installation.
Modify the composer. json file of the laravel Directory
Add the following brackets before the end of the end:
, "repositories": [ {"type": "composer", "url": "http://comproxy.cn/repo/packagist"}, {"packagist": false} ]
Try http://pkg.phpcomposer.com if not available/
Right-click the folder and choose install
The installation will be completed in a few minutes!
At this time, you will find that there are multiple vendor folders in the directory.
Laravel's default homepage is server. php. you need to configure it to open the httpd. conf configuration file.
Find [about 249th rows or less]
DirectoryIndex index.html index.php index.htm l.php server.php
Restart server. php.
Try to go to the browser to open the http://t.com ghost, depending on your own installation.
So far, the installation has been successful. the reason for the slow opening is that Google fonts are used. you can use CDN in China, find the F: \ laravel \ resources \ views folder, and open welcome. blade. php file, change the fifth line
360 front-end Public Library: http://libs.useso.com/
Next, try to write a method,
Find the F: \ laravel \ app \ Http folder, open routes. php, and add
/*|--------------------------------------------------------------------------| Application Routes|--------------------------------------------------------------------------|| Here is where you can register all of the routes for an application.| It's a breeze. Simply tell Laravel the URIs it should respond to| and give it the controller to call when that URI is requested.|*/ Route::get('/', 'WelcomeController@index'); Route::get('home', 'HomeController@index'); Route::controllers([ 'auth' => 'Auth\AuthController', 'password' => 'Auth\PasswordController',]);Route::get('hi', function(){ return "hi";});
Open browser input http://t.com/public/hi
Refer, this is the route.
To directly access the public project folder, you can configure vhost
DocumentRoot "F:\laravel\public" ServerName t.com ServerAlias t1.zy62.com
Options FollowSymLinks ExecCGI AllowOverride All Order allow,deny Allow from all Require all granted
2. linux installation
Laravel must support mcrypt in PHP> 5.4.
Download the great god from the https://github.com/overtrue/latest-laravel here, unzip it to use
Nginx pseudo-static: [I use LNMP here]
server { listen 80; #listen [::]:80; server_name laravel.zy62.com; index index.html index.htm index.php default.html default.htm default.php; root /home/wwwroot/laravel.zy62.com/public; include other.conf; #error_page 404 /404.html; location ~ .*\.(php|php5)?$ { try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; }if (!-d $request_filename) { rewrite ^/(.+)/$ /$1 permanent; } # removes trailing "index" from all controllers if ($request_uri ~* index/?$) { rewrite ^/(.*)/index/?$ /$1 permanent; } # unless the request is for a valid file (image, js, css, etc.), send to bootstrap if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?/$1 last; break; } access_log /home/wwwlogs/laravel.zy62.com.log access; }
Fcinclude GI. conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_param QUERY_STRING $query_string;fastcgi_param REQUEST_METHOD $request_method;fastcgi_param CONTENT_TYPE $content_type;fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_NAME $fastcgi_script_name;fastcgi_param REQUEST_URI $request_uri;fastcgi_param DOCUMENT_URI $document_uri;fastcgi_param DOCUMENT_ROOT $document_root;fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param GATEWAY_INTERFACE CGI/1.1;fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr;fastcgi_param REMOTE_PORT $remote_port;fastcgi_param SERVER_ADDR $server_addr;fastcgi_param SERVER_PORT $server_port;fastcgi_param SERVER_NAME $server_name; # PHP only, required if PHP was built with --enable-force-cgi-redirectfastcgi_param REDIRECT_STATUS 200;
ERROR: An another FPM instance seems to already listen on/tmp/php-cgi-714ms.com.sock
Solution:
/Root/lnmp reload
Database configuration: \ config \ database. php
'mysql' => [ 'driver' => 'mysql', 'host' => 'localhost', //'host' => env('DB_HOST', 'localhost'), 'database' => 'test', //'database' => env('DB_DATABASE', 'forge'), 'username' => 'root', //'username' => env('DB_USERNAME', 'forge'), 'password' => 'qaz123', //'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, ],
View, pass value:
Route:
Route::get('/hi',function(){ //echo 123; return View::make('hi')->with('name','laravel');//way1});
Create the hi. blade. php file under laravel \ resources \ views.
Test