距离上一次的laravel学习又过去了N长时期,期间跑去学习了React和React Native...无限的辛酸史。
终于又开始回来学习laravel了,因为时间过长,因此此次计划从零开始,边温习边写我的网站。OK,Let`s go!php
环境:Linux centOS 7
+ Nginx
+ MySql
+ PHP
。需使用:git
+ composer
。这里的环境我直接使用了lnmp.org上现成的包,具体的安装流程介绍的很清楚。html
在laravel项目的根目录下(如下使用author
代替)初始化项目以前记得安装git
nginx
git init
因为github
的关系,我将远程仓库设在了oschina上,使用和github
基本一致。以后在本地laravel
git remote add origin http://git.oschina.net/xxx/xxx.git git pull origin master git add <文件名,能够输入多个用空格隔开> git commit -m "第一次提交" git push origin master
以上就完成了项目文件提交至远程库。注:vender文件夹无需提交。git
首先安装git
以及composer
github
yum install git git config --global user.name "你的名字或昵称" git config --global user.email "你的邮箱" curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer // 以上将下载并全局安装composer
接下来添加虚拟主机,具体的操做在这个教程里。根据文章里的操做,咱们配置好了虚拟主机,接下来打开并修改xxxx.conf
文件,这里是要作一些改动以适应laravel
。虚拟主机配置文件在:/usr/local/nginx/conf/vhost/域名.conf
,修改为如下的样子:bootstrap
server { listen 80; root /home/wwwroot/author/public/; #这里是项目根目录,必定要写上public,由于入口index.php在这里 index index.php; server_name your_IP; #your_IP,这里修改你的地址,如下内容无需改动 location / { try_files $uri $uri/ index.php?$query_string; } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
打开/home/wwwroot/
文件夹,输入git clone <your project>
,将刚刚提交的程序克隆到这里接着再cd <projiet name>
,输入浏览器
composer install
这里可能有两个错误提示:服务器
权限问题、为wwwroot
文件添加写的权限chmod -r 775 wwwroot
composer
安装完成后提示错误
[Symfony\Component\Process\Exception\RuntimeException] The Process class relies on proc_open, which is not available on your PHP installation.
打开php.ini
,找到disable_functions = ...
删掉后面的proc_open
, proc_get_status
。
chown www:www -R /home/wwwroot/author
对网站目录进行权限设置,为storage
和bootstrap/cache
文件夹添加775权限chmod -R 775 <dir>
.
大功告成!
后续的操做,本地编写网站程序,及时经过git
更新至服务器。
若是你也对laravel感兴趣而且刚刚入门,说不定咱们能够好好交流一下:lwx12525@outlook.com
.