About laravel5.1 Installation Experience

Source: Internet
Author: User
Tags php framework sqlite database
Recently started to open a pit, play PHP, and Laravel recently very popular, so that's it. Small white PHP Direct contact framework is really not easy, the previous Python contact with the Django Framework crossing Web documents feel reluctant to write, not too good-looking, until the laravel to see the document to know what is called metamorphosis. People with absolutely no foundation are basically hard to install and use successfully. And even if the basic PHP is a variety of troubles, mainly in the configuration of the document is not written intuitively, may be the author thought too simple, take it for granted, "This is very simple ...." , read the Laravel Chinese Web document translation, feeling is a little better, but because the direct translation, so the original translation is poor, not the problem of translation, is the source of the problem! , in the next 2 days to see the entry document, either is the same as the author, like a very good look, and then just do not understand Ah, the most direct effect is, crouching groove, how can this suddenly become like this? What about the process? , there are some because it is too old, the version has been backward, the installation method of configuration has changed, so it can not be used, so I will explore the experience put out, I was just contact, only touch the installation and simple and practical, router,midd,control,bladetemple, not in depth, After all, I also just learned PHP, the process is very bitter, relying on the previous Linux knowledge, Django Framework knowledge, HTML and CSS basic knowledge is finally a primer laravel. First, Shellfish! In order to take care of people like me, so I wrote down my notes, hoping to have a little effect on everyone. --BTW, I do not have any personal color in the previous words, I just want to say, the document to write a little better, I think that the document even you do not see, think about how others seem to feel, regardless of the author and the translator, your contribution is fruitful, but please take care of those who are not so good students , thank you, no matter what, there are you have so good PHP framework can be used, you can advertise such a good PHP framework for us to know. Thank you.

First step: Install PHP Suite

So far Laravel is 5.1 version, need to have PHP requirements, to php5.59 above

The Laravel framework has a few system requirements. Of course, all of these requirements is satisfied by the Laravel Homestead virtual machine:    * PHP >= 5.5.9    * O Penssl php Extension    * PDO php Extension    * mbstring php Extension    * tokenizer php Extension

Ubuntu 14.2 64 bit (development use, mainly because PHP's package version is high enough to meet laravel requirements)

Apt-get install php5 libapache2-mod-php5 php5-mcrypt php5-curl php5-gd php5-json php5-mysqlnd opensslapt-get Install MYSQ L-server Libapache2-mod-auth-mysql Php5-mysql Curl Basically the installation is complete here, larvel all the necessary things are complete.

Step Two: Install the composer tool

Because Laravel is a trial composer to do package dependency management, including Laravel installation, it also needs to install composer https://getcomposer.org/

For composer don't need to know too much, just need to know how to use, how to install it
Execute these 2 commands without being a wall

Curl-ss Https://getcomposer.org/installer | PHP #下载composer安装文件并使用php执行 in order to generate a Composer.phar package MV Composer.phar/usr/local/bin/composer # Put the generated composer package in a directory that holds the command package so that the system's $path can search for the command, so that the composer command can be used directly at the command line.

Need to be aware of composer execution permissions

chmod +x/usr/local/bin/composer

Step Three: Install Laravel

Make sure you have composer this tool and we can install Laravel.

Composer global require "laravel/installer=~1.1"

After successful execution of this command
Will be in the local directory to generate a directory such as ~/.composer/vendor/bin, Laravel command is placed in this directory, in order to facilitate our use of laravel command, so we need to put him in the system of $path inside, Because I was executing the above command at root, my package was generated in the root directory

Export path= $PATH:/root/.composer/vendor/bin/

This command can be written in the user's environment variable configuration file.
Ubuntu Linux System environment variable configuration file:

Not recommended:/etc/profile: The first file that is used when the operating system customizes the user environment at logon, which sets the environment information for each user of the system, which is executed when the user logs on for the first time. Not recommended:/etc/environment: The second file that the operating system uses when logging on, the system sets environment variables for environment files before reading your own profile. Recommendation: ~/.profile:  

For example:

Cat ~/.profile # ~/.profile:executed by bourne-compatible login Shells.if ["$BASH"]; Then  if [-f ~/.BASHRC];    ~/.bashrc  fifimesg nexport path= $PATH:/root/.composer/vendor/bin/

Fourth step: Create a Laravel Application project

After installing the Laravel.

Laravel New Blog

Execute the new command, you can create a app,app is actually a Web site application directory

The directory schema for this project is as follows:

Tree-d-L 1/ROOT/BLOG//ROOT/BLOG/├──APP├──BOOTSTRAP # requires Apache Write permission ├──config├──database├──public    #apache的docu The ment directory needs to point to it ├──resources├──storage # need to have Apache Write permission ├──tests└──vendor

The root directory of a newly created Laravel project contains the following subdirectories:

App Directory: Contains the core code of the application, as you would have expected. We will soon delve into the details of this catalogue in greater depth. Bootstrap directory: contains several files for starting the framework and configuring the auto-load feature, as well as a cache directory to hold the auto-generated files for the framework to speed up the framework startup. Config directory: As the name implies, contains the configuration files for all applications. Database directory: Contains databases for migration and data population files. If you don't mind, you can also store the SQLite database files in this directory. The public directory contains the front controller and your assets (images, JavaScript, CSS, etc). The public directory contains the previous controller and your resource files (Pictures, JavaScript, CSS, and so on). Resources directory: Contains your views, original resource files (less, SASS, Coffeescript), and localized language files. Storage directory: Contains compiled Blade template, file-based session, file cache, and other files generated by the framework. This directory contains three subdirectories: app, framework, and logs. The app directory user holds any files used by the application, and the framework directory is used to hold the files and cache files generated by the framework; Finally, the logs directory is used to store the application's log files. The tests directory is used to store your automated test files. The Laravel default comes with an instance of PHPUnit. The vendor directory is used to store Composer dependent packages.

Fifth Step: Configure Apache

Laravel will use Mod_rewrite and. htaccess

The framework ships with a public/.htaccess file, is used to allow URLs without index.php. If you use Apache to serve your Laravel application, being sure to enable the Mod_rewrite module.

So it needs to be configured, and the following configuration is included for all Apache

1. Configure a virtual host

The Apache installation directory for Ubuntu is

/etc/apache2/

Profile/etc/apache2/ports.conf, mainly in order to configure the listening port, the default is 80, if you do not configure can also, but 80 because too many applications used, so I still configure, not configured can also. Apache2 port configuration changed to Ports.conf, I configured the 8011

Listen 8011

Configuring a virtual Host

By default there is a demo template profile 000-default.conf, which copies it as a virtual machine host profile for our own use

CP 000-default.conf testsite.conf

The main configuration port is 8011 (the listening port just configured) and the DocumentRoot directory location, which is consistent with the previous one, is the public directory

Cat/etc/apache2/sites-enabled/testsite.conf
 
  
     # The SERVERNAME directive sets the request scheme, hostname and port, the server uses to identify itself. This was used when creating # redirection URLs.      In the context of the virtual hosts, the ServerName # specifies what hostname must appear in the request ' s Host:header to # match this virtual host.     The default virtual host (this file) of this # value is not decisive as it's used as a last resort host regardless.     # However, must set it for any further virtual host explicitly. #ServerName www.example.com documentroot/var/www/html/laravel-v5.1.4/public #这里laravel New blog will create a directory locally, the entire blog needs to be     The directory is moved to the Apache DocumentRoot directory so that Apache can recognize it.     # Available Loglevels:trace8, ..., Trace1, debug, info, notice, warn, # Error, Crit, alert, Emerg.     # It's also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn errorlog ${apache_log_dir}/error.log customlog ${apache_log_dir}/access.log CombiNed # For more configuration files from conf-available/, which be # enabled or disabled at a global level, it's Possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally dis     abled with "a2disconf". #Include conf-available/serve-cgi-bin.conf
 

2. Configure Open Mod_rewrite

Found it in the/etc/apache2/apache2.conf.

 
          Options Indexes followsymlinks        allowoverride None        Require all granted

Change allowoverride None to allowoverride all

3. Check Permissions

Because Ubuntu Apache is run with Www-data users.

The easy way is to set the entire Larave directory to the Www-data user

Chown-r Www-data  /var/www/html/laravel-v5.1.4/

So there is no permission is not normal situation, but according to strict standards, only the above mentioned 3 directories have write permission.

4. Open Apache

Service Apache2 Start

Visit http://XXXX:8011 to see the words with Larave, which represent the successful installation configuration.

Check for troubleshooting and notes

1. Check the Apache2 log

/var/logs/apache2/'s Access.log and Error.log

2. Turn off SELinux and iptables

3. Here I just listed the necessary items for installation, others are non-mandatory items, you can refer to the official website documents, the remaining ones can basically be understood, even if I am such a person.

Reference:

Website
http://laravel.com/
http://laravel.com/docs/5.1

Chinese web
http://www.golaravel.com/

Composer Official website
Https://getcomposer.org/doc/00-intro.md

Original quote:
http://www.godblessyuan.com/2015/07/20/laravel5-1_install_tutorial/

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.