环境: nginx + php + mysql
laravel : 5.5
开发环境的搭建略过
安装 laravel
composer create-project laravel/laravel [project-name] --prefer-dist "5.5.*"
测试安装是否成功
cd project-name
php artisan server
浏览器输入: http://127.0.0.1:8000 ,出现如下界面表示安装成功
配置
composer 安装,根目录下已经创建 .env 文件, 其他方式安装的:
cp .env.example .env
生成key:
php artisan key:generate
.env 配置
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:************
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
# 数据库配置
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=wbSina
DB_USERNAME=root
DB_PASSWORD=root
BROADCAST_DRIVER=log
CACHE_DRIVER=file # 缓存驱动
SESSION_DRIVER=file # session 存储驱动
SESSION_LIFETIME=120
QUEUE_DRIVER=sync # 队列驱动
# redis 配置
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
# 邮件配置
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
tips: 项目中可根据实际情况进行配置
nginx 配置
server {
listen 80;
server_name wb.leesin.me;
root "D:\sinaWb\public";
location / {
index index.html index.htm index.php;
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
#autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
host ip 映射:
127.0.0.1 wb.leesin.me
重启 service php7.0-fpm restart
访问: http://wb.leesin.me
git 管理代码
在github、gitlab、coding、码云 中创建空仓库
cd project-name
git init
在 .gitignore 中添加忽略文件
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
npm-debug.log
yarn-error.log
.env
git remote add origin 仓库地址
git add . && git commit -m 'first commit'
git push -u origin master
此时就可以开始进行开发了