Laravel is an open source PHP framework, designed for the faster development of MVC web applications in PHP. This article will help you to install Laravel 5 PHP Framework on Ubuntu 15.04 LTS, 14.04 LTS, 12.04 LTS, Debian and LinuxMint operating systems.
Step 1 – 安装 LAMP
To start with Laravel, we first need to set up a running LAMP server. If you have already running LAMP stack skip this step else use followings commands to set up lamp on Ubuntu system.
Install PHP 5.6
- $ sudo apt-get install python-software-properties
- $ sudo add-apt-repository ppa:ondrej/php
- $ sudo apt-get update
- $ sudo apt-get install -y php5.6 php5.6-mcrypt php5.6-gd
Install Apache2
- $ apt-get install apache2 libapache2-mod-php5
Install MySQL
- $ apt-get install mysql-server php5.6-mysql
Step 2 – 安装 Composer
Composer is required for installing Laravel dependencies. So use below commands to download and use as a command in our system.
建立自己规划的目录 例如 我希望我的目录在 /home/baron/
- useradd baron
- mkdir /home/baron/
- chown -R baron:baron /home/baron/
- cd /home/baron/
- $ curl -sS https://getcomposer.org/installer | php
- $ sudo mv composer.phar /usr/local/bin/composer
- $ sudo chmod +x /usr/local/bin/composer
Step 3 – 安装 Laravel
现在您已经安装了composer,我们可以用它来安装Laravel。 我们希望安装Laravel /home/baron/website 目录。Laravel安装最新版本,你可以输入:
cd /home/baron/
sudo composer create-project laravel/laravel /home/baron/website
Installing laravel/laravel (v5.3.16)
- Installing laravel/laravel (v5.3.16) Loading from cache
Created project in /home/crm/web-crm
> php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 61 installs, 0 updates, 0 removals
- Installing vlucas/phpdotenv (v2.4.0) Downloading: 100%
- Installing symfony/polyfill-mbstring (v1.3.0) Downloading: 100%
- Installing symfony/var-dumper (v3.1.9) Downloading: 100%
- Installing symfony/translation (v3.1.9) Downloading: 100%
- Installing symfony/routing (v3.1.9) Downloading: 100%
- Installing symfony/process (v3.1.9) Downloading: 100%
- Installing psr/log (1.0.2) Downloading: 100%
- Installing symfony/debug (v3.1.9) Downloading: 100%
- Installing symfony/http-foundation (v3.1.9) Downloading: 100%
- Installing symfony/event-dispatcher (v3.2.2) Downloading: 100%
- Installing symfony/http-kernel (v3.1.9) Downloading: 100%
- Installing symfony/finder (v3.1.9) Downloading: 100%
- Installing symfony/console (v3.1.9) Downloading: 100%
- Installing swiftmailer/swiftmailer (v5.4.5) Downloading: 100%
- Installing paragonie/random_compat (v2.0.4) Downloading: 100%
- Installing ramsey/uuid (3.5.2) Downloading: 100%
- Installing jakub-onderka/php-console-color (0.1) Downloading: 100%
- Installing jakub-onderka/php-console-highlighter (v0.3.2) Downloading: 100%
- Installing dnoegel/php-xdg-base-dir (0.1) Downloading: 100%
- Installing nikic/php-parser (v3.0.2) Downloading: 100%
- Installing psy/psysh (v0.8.1) Downloading: 100%
- Installing nesbot/carbon (1.22.1) Downloading: 100%
- Installing mtdowling/cron-expression (v1.1.0) Downloading: 100%
- Installing monolog/monolog (1.22.0) Downloading: 100%
- Installing league/flysystem (1.0.32) Downloading: 100%
- Installing symfony/polyfill-util (v1.3.0) Downloading: 100%
- Installing symfony/polyfill-php56 (v1.3.0) Downloading: 100%
- Installing jeremeamia/superclosure (2.3.0) Downloading: 100%
- Installing doctrine/inflector (v1.1.0) Downloading: 100%
......
......
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
The compiled class file has been removed.
> php artisan key:generate
Application key [base64:iudMCCDQtp4DKZQ9jEAXHmlXprpfYFZBCSr7FI8D7ww=] set successfully.
ls
app bootstrap composer.lock database package.json public resources server.php tests
artisan composer.json config gulpfile.js phpunit.xml readme.md routes storage vendor
指定版本
- composer create-project laravel/laravel /var/www/laravel 4.2
权限的设定 根据自己的需求自定义
- sudo chown -R :www-data /var/www/laravel
- sudo chmod -R 775 /var/www/laravel/app/storage
Step 4 – Nginx + php-fpm
Nginx 的配置
- server {
- listen 192.157.228.47:8082;
- server_name 192.157.228.47;
- root /home/crm/web-crm/public;
- access_log /var/log/nginx/mysql.rive.com-access.log;
- error_log /var/log/nginx/mysql.rive.com-error.log;
- set $root_path /home/crm/web-crm/public;
- allow 221.226.186.102;
- allow 121.225.75.245;
- allow 106.187.53.193;
- allow 47.90.42.218;
- allow 110.10.178.82;
- deny all;
- #auth_basic "Restricted Please Tell Me Who Are You?";
- #auth_basic_user_file /etc/nginx/pwd/rive.pwd;
- location / {
- index index.php index.html index.htm;
- try_files $uri $uri/ index.php$uri?$args;
- }
- location ~ \.php$ {
- root $root_path;
- proxy_intercept_errors on;
- proxy_buffer_size 128k;
- proxy_buffers 4 128k;
- fastcgi_keep_conn on;
- fastcgi_buffers 16 128k;
- fastcgi_buffer_size 128k;
- #fastcgi_pass 127.0.0.1:9000;
- fastcgi_pass unix:/run/php/php5.6-fpm.sock;
- fastcgi_read_timeout 240;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
- #include fastcgi_params.conf;
- }
- }
参考
https://www.digitalocean.com/community/tutorials/how-to-install-laravel-with-an-nginx-web-server-on-ubuntu-14-04
How To Install Laravel 5 Framework on Ubuntu 16.04, 14.04 & LinuxMint
没有评论