pico-cms

http://picocms.org/

Pico はMarkdown 形式のテキストで記事を作成するCMS ソフトウェアです。
Debian/SH4 環境にNginx, PHP-FPM, Pico をインストールして構築してみました。

Pico の取得と展開

$ wget https://github.com/picocms/Pico/archive/master.zip -O pico.zip
$ unzip pico.zip
$ rm pico.zip

テーマの変更

https://github.com/kiiiyo/pico-theme
以下のようにthemes フォルダにbootstrap テーマファイルを展開する。

$ tree -d ./pico/themes/
./pico/themes/
├── bootstrap
│   └── assets
│   ├── css
│   ├── img
│   └── js
└── default
└── scripts
./pico/config.php
<?php 

$config['site_title'] = 'USL-5P'; // Site title
$config['base_url'] = ''; // Override base URL (e.g. http://example.com)
$config['theme'] = 'bootstrap'; // Set the theme (defaults to "default")
$config['date_format'] = 'jS M Y'; // Set the PHP date format

/*
// Override any of the default settings below:

$config['site_title'] = 'Pico'; // Site title
$config['base_url'] = ''; // Override base URL (e.g. http://example.com)
$config['theme'] = 'default'; // Set the theme (defaults to "default")
$config['date_format'] = 'jS M Y'; // Set the PHP date format
$config['twig_config'] = array( // Twig settings
'cache' => false, // To enable Twig caching change this to CACHE_DIR
'autoescape' => false, // Autoescape Twig vars
'debug' => false // Enable Twig debug
);
$config['pages_order_by'] = 'alpha'; // Order pages by "alpha" or "date"
$config['pages_order'] = 'asc'; // Order pages "asc" or "desc"
$config['excerpt_length'] = 50; // The pages excerpt length (in words)

// To add a custom config setting:

$config['custom_setting'] = 'Hello'; // Can be accessed by {{ config.custom_setting }} in a theme

*/

Nginx, PHP-FPM のインストールと設定

# apt-get install nginx php5-fpm
# mkdir /etc/nginx/ssl
# cd /etc/nginx/ssl
# openssl genrsa -des3 -out server.key 1024
# openssl req -new -key server.key -out server.csr
# cp server.key server.key.org
# openssl rsa -in server.key.org -out server.key
# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
# rm /etc/nginx/sites-enabled/default
/etc/nginx/sites-available/pico
# nginx/php5-fpm/pico
server
{
listen 80;
#server_name yourdomain.com www.yourdomain.com; # Domain name pointed to server

root /home/USERNAME/pico/; # Location of gpeasy installation root
index index.html index.htm index.php; # Default index files to try
try_files $uri $uri/ /index.php?$args; # Rewrite rules for gpeasy (pass /request as argument to cms)

#php5-fpm
location ~ \.php$
{
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

location ~ /\.ht
{
deny all;
}
}

server {
listen 443;
#server_name yourdomain.com www.yourdomain.com; # Domain name pointed to server

root /home/USERNAME/pico/; # Location of gpeasy installation root
index index.html index.htm index.php; # Default index files to try
try_files $uri $uri/ /index.php?$args; # Rewrite rules for gpeasy (pass /request as argument to cms)

#php5-fpm
location ~ \.php$
{
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

location ~ /\.ht
{
deny all;
}

ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
}
# ln -s /etc/nginx/sites-available/pico /etc/nginx/sites-enabled/pico
# service nginx restart

リモートホストに設置した場合のTIPS

sshfs を使って、リモートホストの~/pico/ をローカルホストの~/pico/ にマウントすると便利。

$ ssh-keygen
$ ssh-copy-id -i ~/.ssh/id_rsa.pub username@hostname -p 22222
$ ssh username@hostname -p 22222
$ mkdir ~/pico
$ sshfs username@hostname:/home/username/pico ~/pico -p 22222 -o reconnect