Total Pageviews

Saturday 25 January 2014

iNews是一套开源的极简社区程序(基于php+mysql)

一、目标与使用方法

iNews是一套开源的极简社区程序,我们的目标是让开发者轻松获得一个与 Hacker News 一般,并且更漂亮、又能跨终端(Responsive 适配)运行的分享网站。

二、快速上手:

  • 安装:在自己的服务器上运行 iNews 程序
  • 配置:网站信息、管理员(审批权限)、邮件发送与邮件服务器设置等

三、反馈

四、运行在 iNews 程序中的网站

from https://github.com/Trimidea/inews
----------------

环境要求

  • PHP 5.3.9+
    • php-mcrypt
    • php-pdo
    • php-pdo-mysql
    • php-mbstring
  • Composer (MAC下brew install composer或去官网composer)
  • Apache/Nginx
  • Mysql 5.1+
  • Git

安装

如果是cPannel等虚拟主机,需要在相应界面进行修改,不需要操作命令行

获取源代码

git clone git@github.com:Trimidea/inews.git
cd 程序根目录
composer install(composer设置好了才能执行这一步)

配置环境

export PAGON_ENV=production

修改配置

cd 程序根目录
cp config/develop.php config/production.php
vim config/production.php
# 0.1.9起,支持通过env文件指定配置
echo "production" > config/env
具体说明可以参照 配置说明 正式环境需要删除debug配置

初始化

./bin/task db:init
用来初始化数据库
这步出问题:
首先检查你的mysql相关的东西都有没有装好
其次看看你的mysql有没有正常启动
最后看看你production.php文件里数据库的root用户密码有没有写对

升级数据库

./bin/task db:migrate
初始化和升级都需要执行,确保数据库是最新的版本

定时任务

[root@localhost]#: crontab -e
把下面文字加到定时任务里。
*/10 * * * * 程序根目录/bin/task job:point
用来计算积分和排名

配置主机

如果是Apache

<VirtualHost *:80>
    DocumentRoot "程序根目录" #比如/usr/local/src/inews
    ServerName example.com
    SetEnv PAGON_ENV production

    <Directory 程序根目录>
        Options FollowSymLinks
        AllowOverride All
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

如果是Nginx+FPM

server {
    listen 80;

    root 程序根目录; #比如/usr/local/src/inews
    index index.php index.html index.htm;

    server_name example.com;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
        expires 30d;
        add_header Pragma public;
        add_header Cache-Control "public";
    }

    location ~ \.php$ {
        # PHP的支持根据自己的情况进行配置
        # 9000是FPM的默认端口
        fastcgi_pass 127.0.0.1:9000;
        include fastcgi_params;
    }
}
FPM配置添加环境变量
env[PAGON_ENV] = production 
 
from https://github.com/Trimidea/inews/blob/master/docs/01-Install.md