Linux Laravel Installation

Source: Internet
Author: User
Tags sqlite database

First step: Install PHP Suite

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

of these requirements are satisfied by the Laravel Homestead virtual machine:    * PHP >= 5.5.9 * OpenSSL 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)

install php5 libapache2-mod-php5 php5-mcrypt php5-curl php5-gd php5-json php5-mysqlnd opensslapt-get install mysql-server libapache2-mod-auth-mysql php5-mysql curl基本上这里安装完成,larvel的所需东西都齐全了。
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执行,以便生成一个composer.phar包mv composer.phar /usr/local/bin/composer # 将生成的composer包放到一个存放命令包的目录,以便系统的$PATH能够搜索到这个命令,这样就可以在命令行直接使用composer命令了。

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.

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

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:

不建议:/etc/profile : 在登录时,操作系统定制用户环境时使用的第一个文件 ,此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行。 不建议: /etc /environment : 在登录时操作系统使用的第二个文件, 系统在读取你自己的profile前,设置环境文件的环境变量。 建议:~/.profile :  

For example:

# ~/.profile: executed by Bourne-compatible login shells.if [ "$BASH" ]; then if [ -f ~/.bashrc ]; then . ~/.bashrc fifimesg nexport PATH=$PATH:/root/.composer/vendor/bin/
Fourth step: Create a Laravel Application project

After installing the 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:

1 /root/blog//root/blog/├── app├── bootstrap # 需要有apache的写入权限 ├── config├── database├── public    #apache的document目录需要指向它├── resources├── storage # 需要有apache的写入权限├── 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 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, there is also a cache directory, The file used to hold the framework auto-generated can speed up the framework startup. Config directory: As the name implies, contains the configuration files for all applications. database directory: Contains the database 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 the compiled Blade template, the file-based session, the 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, the framework directory is used to hold the files and cache files generated by the framework, and 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

use Apache to serve your Laravel application, be 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

/etc/apache2/sites-enabled/000-default.conf 

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

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<virtualhost *:8011># The SERVERNAME directive sets the request scheme, hostname and port that# The server uses to identify itself. This was used when creating# redirection URLs. In the context of the virtual hosts, the ServerName# specifies hostname must appear in the request ' s Host:header to# match this virtual host. For the default virtual host (this file) this# value was not decisive as it was used as a last resort host regardless.# However, must set it for any further virtual host explicitly.#ServerName www.example.comDocumentroot/var/www/html/laravel-v5.1.4/public #这里laravel New Blog will create a local directory, you need to move the entire blog directory in 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 is # 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 di sabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf</VirtualHost>         
2. Configure Open Mod_rewrite

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

<Directory /var/www/>        Options Indexes FollowSymLinks        AllowOverride None        Require all granted</Directory>

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
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/

Linux Laravel Installation

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.