sudo apt-get update sudo apt-get install -y language-pack-en-base locale-gen en_US.UTF-8 sudo apt-get install software-properties-common sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php sudo apt-get update
sudo apt-get install nginx
sudo apt install -y php7.0 php7.0-mysql php7.0-fpm php7.0-curl php7.0-xml php7.0-mcrypt php7.0-json php7.0-gd php7.0-mbstring php7.0-zip php-mongodb php-memcached php-redisphp
sudo apt-get -y install mysql-server-5.7
修改php配置
sudo vim /etc/php/7.0/fpm/php.ini // 將cgi.fix_pathinfo=1這一行去掉註釋,將1改成0 sudo vim /etc/php/7.0/fpm/pool.d/www.conf // 配置這個 listen = /var/run/php/php7.0-fpm.sock sudo service php7.0-fpm restart
修改nginx配置
sudo vim /etc/nginx/sites-available/default
Nginx 基礎配置以下:html
listen 80; listen [::]:80; root /var/www/html/laravel/public; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name localhost; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ /index.php?$query_string; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
重啓nginx service nginx restart
注意:laravel的storage 文件夾須要777權限 chmod -R 777 storage/
git clone 項目
git clone https://github.com/3w27/laravel50.git
注意:git不提交.env和vendor/ 因此clone下來的代碼中沒有這兩個
.env: cp 項目目錄/.env.example 項目目錄/.env
配置應用程序密鑰:若是這密鑰沒有被配置的話,你的用戶 sessions 和其餘的加密數據都是不安全的!
cd 到項目根目錄,運行php artisan key:generate
vendor:須要安裝composer
安裝composer:
下載composer.phar
curl -sS https://getcomposer.org/installer | php
下載composer.phar
curl -sS https://getcomposer.org/installer | php
下載完成以後將它放在系統 PATH 中,供全局調用。
mv composer.phar /usr/local/bin/composer cd 項目目錄下 composer install //執行命令 結束後項目目錄下就有了vendor文件夾完成以後,訪問localhost ,就會出現laravel的歡迎界面