Need help with MrCoderStackBlog?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

MrCoderStack
137 Stars 5 Forks 26 Commits 0 Opened issues

Description

laravel5.5 react做后台hexo-next主题的blog站,php开发

Services available

!
?

Need anything else?

Contributors list

# 183,547
PHP
Shell
springb...
springb...
3 commits

mrcoderBlog

php 7.2+ Mysql 5.6+ license

20190124开源声明

总花费大约一周时间,陆陆续续开发,laravel+react+next主题的博客系统日渐丰满,是时候分享成果了。喜欢的请star一下。系统会持续更新。

DEMO:

http://www.wrsee.com

效果

前台 前台 前台 前台 前台 前台

背景

博主一直使用git page + hexo搭建个人的博客,奈何,渐渐发现了问题

  • seo差的几乎没有
  • 访问速度慢的掉渣

于是本着不重复造轮子的前提下,github上看了开源的blog系统,发现很多都不符合个人的风格,审美,可能是博主用惯了hexo的主题,终下决心自己开发一套。

技术

完全重新开发是不可能的

  • 后台(顺带学习了一下react) 参考 https://github.com/SadCreeper/laravel-react-blog这位兄跌的开源项目,做了很多更改&优化
  • 前端 参照hexo的next主题,开发了一套,兼容同学们自己开发多个主题

代码部署

  • git clone https://github.com/FrCoderBlog/mrcoderBlog.git blog
  • cd blog
  • composer install
  • composer dump-autoload (加载所有类)
  • php artisan key:generate
  • 配置.env
    BLOGTHEME = next //指定主题 PUSHSTATE = off //自动推送
  • php artisan migrate (建表)
  • php artisan db:seed --class=UsersTableSeeder (填充初始密码account:[email protected], pass:admin)
  • php artisan storage:link
  • 配置主题支持 ``` cd blog vim /blog/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php 搜索auth.login为 env('BLOG_THEME').'.auth.login';
至此,blog已经可以访问了,后台地址为http://你的域名/mrcoderadmin/,不过搜索功能还不能使用


sphinx搜索引擎

  • 安装

yum install make gcc gcc++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-devel wget http://files.opstool.com/man/coreseek-4.1-beta.tar.gz tar -xzvf coreseek-4.1-beta.tar.gz cd coreseek-4.1-beta cd mmseg-3.2.14 ./bootstrap ./configure --prefix=/usr/local/mmseg3 make && make install cd .. cd csft-4.1 sh buildconf.sh(这个地方有可能生成不了configure文件,需要修改部分文件,具体内容参考http://blog.csdn.net/jcjc918/article/details/39032689) ( 错误1: 解决办法:在 csft-4.1/configure.ac 文件中,查找: ACPROGRANLIB 后面加上 AMPROGAR 最终格式为:ACPROGRANLIB AMPROGAR 再次执行 sh buildconf.sh

错误2: 'automake --add-missing' can install 'ar-lib' 在命令行执行

automake --add-missing

再次执行 sh buildconf.sh

错误3 编译的时候出现 sphinxexpr.cpp:1823:43: error: ‘ExprEval’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] T val = ExprEval ( this->mpArg, tMatch ); // 'this' fixes gcc braindamage 处理办法: #vim /usr/local/src/coreseek-4.1-beta/csft-4.1/src/sphinxexpr.cpp 1746 T val = ExprEval ( this->mpArg, tMatch ); 形式修改为 T val = this->ExprEval ( this->mpArg, tMatch ); 1777 T val = ExprEval ( this->mpArg, tMatch ); 形式修改为 T val = this->ExprEval ( this->mpArg, tMatch ); 1823 T val = ExprEval ( this->mpArg, tMatch ); 形式修改为 T val = this->ExprEval ( this->mpArg, tMatch ); 错误4 In file included from sphinxstd.cpp:24:0: pylayer.h:16:27: fatal error: Python.h: No such file or directory #include
这是由于缺少了python环境的devel支持包 解决办法:yum install python-devel )

./configure --prefix=/usr/local/coreseek --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/ --with-mysql=/usr (which mysqlconfig找到安装位置) make && make install

* 配置
mv /usr/local/coreseek/etc/sphinx.conf /etc/sphinx.conf vim sphinx.conf: (简化版的sphinx的配置) source mainsrc { type = mysql sqlhost = localhost sqluser = root sqlpass = 123456 sqldb = blog sqlport = 3306 # optional, default is 3306 sqlquerypre = SET NAMES utf8 sqlquery = \ SELECT ar.id,ar.contenthtml,ar.title,UNIXTIMESTAMP(ar.createdat) as createdat, ca.name FROM articles ar \ left join cates ca on ar.cateid = ca.id; sqlattruint = id sqlattrtimestamp = createdat sqlrangedthrottle = 0 sqlqueryinfo = SELECT ar.*, ca.name FROM articles ar left join cates ca\ on ar.cate_id = ca.id WHERE ar.id=$id; }

index main { source = mainsrc path = /usr/local/coreseek/var/data/articles docinfo = extern mlock = 0 morphology = none minwordlen = 1 charsettype = zhcn.utf-8 htmlstrip = 0 charsetdictpath = /usr/local/mmseg3/etc/ ngramlen = 0 }

indexer { memlimit = 32M } searchd { listen = 9312 listen = 9306:mysql41 log = /usr/local/coreseek/var/log/searchd.log querylog = /usr/local/coreseek/var/log/query.log readtimeout = 5 clienttimeout = 300 maxchildren = 30 pidfile = /usr/local/coreseek/var/log/searchd.pid maxmatches = 1000 seamlessrotate = 1 preopenindexes = 1 unlinkold = 1 mvaupdatespool = 1M maxpacketsize = 8M maxfilters = 256 maxfiltervalues = 4096 maxbatch_queries = 32 workers = threads # for RT to work }

建立索引命令 /usr/local/coreseek/bin/indexer -c /etc/sphinx.conf --all --rotate 启动命令 /usr/local/coreseek/bin/searchd -c /etc/sphinx.conf 搜索命令 /usr/local/coreseek/bin/search -c /etc/sphinx.conf 中国 停止命令 /usr/local/coreseek/bin/searchd -c /etc/sphinx.conf --stop

* 索引自动化建立
(项目下的crontab子目录已有,根据你实际情况修改)
建立shell脚本,主要用来执行sphinx建立索引,重启服务,同时会记录日志到该目录下的sphinx.log

cd crontab vim indexer.sh:

killall -9 searchd /usr/local/coreseek/bin/indexer -c /etc/sphinx.conf --all --rotate && /usr/local/coreseek/bin/searchd -c /etc/sphinx.conf time=

date "+%Y-%m-%d %H:%M:%S "
echo "${time} sphinx restart success" >> /usr/share/nginx/html/blog/crontab/sphinx.log
然后定时任务中每3小时执行一次该脚本:

crontab -e 0 */3 * * * /usr/share/nginx/html/blog/crontab/indexer.sh service crond restart

配置完毕,搜索功能已经可以使用

关于SEO

  • 目前支持百度

  • js被动推送 需要别人访问后会自动把链接推给百度

  • 主动推送 需要对项目下crontab目录下的push.sh进行编辑(域名需替换为实际的):

    time=`date "+%Y-%m-%d %H:%M:%S "`
    echo "${time}" `curl http://www.wrsee.com/admin-api/push` >> push.log

    编辑定时任务:

     crontab -e:
     //每天下午六点执行推送
     0 18 * * * /usr/share/nginx/html/blog/crontab/push.sh
     service crond restart
    
  • 20190124新增360搜索 百度索引起来了,关键字跑到了首页,是时候支持更多的搜索引擎了,sitemap作为一种通用的方式很受青睐,基于此,新增sitemp生成功能 每天下午六点定时生成sitemap.txt,访问方式路径为 域名/storage/sitemap.txt,物理路径为 项目目录下的public/storage/sitemp.txt

  • 一点建议 seo关键字很重要,请务必在后台配置好。

关于邮件通知

配置.env:

MAILDRIVER=smtp MAILHOST=smtp.qq.com MAILPORT=465 MAILUSERNAME=你得邮箱@qq.com MAILPASSWORD=xxxxxxx //去QQ邮箱设置中开启POP3/SMTP获取秘钥 MAILENCRYPTION=ssl MAILFROMADDRESS=你的邮箱@qq.com MAILFROMNAME=MrCoder技术栈

后台开启邮件通知即可


关于后台的开发

后台使用react + antdesign开发 进行二次开发的话需要安装node.js 这里我们推荐yarn(众所周知的原因)

curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo yum install yarn yarn -v yarn install npm run watch //实时调试 npm run dev //开发打包 npm run prod //上线打包 ```

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.