composer
composer dump-autoload -o
数据库创建迁移
# 创建表php artisan make:migration create_users_table --create=users# 修改表php artisan make:migration add_votes_to_users_table --table=users# 执行数据迁移php artisan migrate
代码注解命令
Laravel 代码提示工具 Laravel IDE Helper介绍
php artisan ide-helper:generate - 为 Facades 生成注释php artisan ide-helper:models -R - 为数据模型生成注释php artisan ide-helper:meta - 生成 PhpStorm Meta file
目录权限配置
sudo chmod -R 777 storage/sudo chmod -R 777 public/sudo chmod -R 777 /alidata/log/
Nginx 配置
log_format dot '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for" "$http_xd_token" ''"$request_body" $request_time $upstream_response_time';server{listen 80;#listen [::]:80;server_name dwt.test.xyz ;index index.html index.htm index.php default.html default.htm default.php;root /alidata/www/test/public;# 位置上报打点location ~ ^/api/reportLocation{default_type application/json;access_log /alidata/log/nginx/test_dot/test_reportLocation.log dot;return 200 '{"code":200,"msg":"success"}';}location / {try_files $uri $uri/ /index.php?$query_string;}#error_page 404 /404.html;# Deny access to PHP files in specific directory#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }location ~ [^/]\.php(/|$){try_files $uri =404;fastcgi_pass unix:/tmp/php-cgi.sock;fastcgi_index index.php;include fastcgi.conf;fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/alidata/www/test/:/tmp/:/proc/";}location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${expires 30d;}location ~ .*\.(js|css)?${expires 12h;}location ~ /.well-known {allow all;}location ~ .*\.(md|sql|log|zip)?${deny all;}location ~ /\.{deny all;}access_log /alidata/log/nginx/dwt.test.xyz.log main;}
任务调度
* * * * * cd /alidata/www/xdapi.test.cn && php artisan schedule:run >> /alidata/log/schedule/test_schedule.log 2>&1
supervisorctl 相关配置
php artisan queue:work --timeout=30 --sleep=3# redis队列启动[program:test_queue]command = /usr/local/php/bin/php /alidata/www/xdapi.test.cn/artisan queue:work --timeout=30 --sleep=3process_name = %(program_name)s_%(process_num)snumprocs = 3autostart = trueautorestart = truestdout_logfile = /alidata/log/supervisor/test_queue_out.logstdout_logfile_maxbytes = 10MBstderr_logfile = /alidata/log/supervisor/test_queue_err.logstderr_logfile_maxbytes = 10MBredirect_stderr=true# nginx日志处理入队列[program:test_positionReportLogTail]command = /usr/local/php/bin/php /alidata/www/xdapi.test.cn/artisan Supervisor:PositionReportLogTailprocess_name = %(program_name)s_%(process_num)snumprocs = 1autostart = trueautorestart = truestdout_logfile = /alidata/log/supervisor/test_positionReportLogTail_out.logstdout_logfile_maxbytes = 10MBstderr_logfile = /alidata/log/supervisor/test_positionReportLogTail_err.logstderr_logfile_maxbytes = 10MBredirect_stderr=true# 重新启动配置中的所有程序sudo supervisorctl reload# 杀掉多余的 tail 进程sudo killall -q tailUbuntu上安装Supervisor,使用如下命令:sudo apt-get install supervisorsudo supervisord -c /etc/supervisor/supervisord.confsudo supervisorctl -c /etc/supervisor/supervisord.conf
# 重新启动配置中的所有程序sudo supervisorctl reloadsudo supervisorctl rereadsudo supervisorctl updatesudo supervisorctl start queue_dispose:*# 终止配置中的所有进程sudo supervisorctl stop all# 启动配置中的所有进程sudo supervisorctl start allsudo supervisorctl -c /etc/supervisor/supervisord.conf statussudo supervisorctl -c /etc/supervisor/supervisord.conf stop webWeiXinLoginList:webWeiXinLoginList_0
<a name="lT0kg"></a>## 性能优化1、开启opcache 性能提高10倍> 下面参数随着系统配置升级而升级```bash# 开启opcachecd /home/public/lnmpsudo ./addons.sh install opcache# 配置opcache/usr/local/php/etc/php.ini# 按照服务器性能配置如下参数opcache.enable=1 # 启用 OPcacheopcache.memory_consumption=512 # OPcache 的内存空间(M)opcache.interned_strings_buffer=64 # 实际字符串的空间(单位:MB)opcache.max_accelerated_files=32531 # 可以缓存多少个脚本,将这个值尽可能设置为与项目包含的脚本数接近或更大opcache.validate_timestamps=0 # 0表示不自动释放缓存,性能最佳opcache.save_comments=0 # 在脚本中保留注释,若存在库需要注释,设为1opcache.fast_shutdown=0 # 快速关闭
