安装
1. 将压缩包下载到/var/www/目录中并解压
wget https://github.com/SSilence/selfoss/releases/download/2.15/selfoss-2.15.zip
2. 给相应的文件夹权限
chmod 775 data/cache data/favicons data/logs data/thumbnails data/sqlite public/ controllers/
3. 创建并修改应用配置文件
https://selfoss.aditu.de/docs/administration/options/
cp defaults.in config.in 按照官网修改相应信息
4. 为应用创建nginx配置
cd /etc/nginx/conf.d/ sudo editor selfoss.conf
其中selfoss内容如下:
server {
listen 0.0.0.0:80;
listen 443 ssl;
server_name localhost;
root /var/www/selfoss/;
access_log /var/log/nginx/rss.access.log;
error_log /var/log/nginx/rss.error.log;
location ~* \ (gif|jpg|png) {
expires 30d;
}
location ~ ^/favicons/.*$ {
try_files $uri /data/$uri;
}
location ~ ^/thumbnails/.*$ {
try_files $uri /data/$uri;
}
location ~* ^/(data\/logs|data\/sqlite|config\.ini|\.ht) {
deny all;
}
location / {
index index.php index.html index.htm;
try_files $uri /public/$uri /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "session.gc_maxlifetime=86400";
include fastcgi_params;
}
}
5. 用户权限
sudo chown -R www-data:www-data /var/www/selfoss/
6. 重启nginx
sudo systemctl restart nainx.service sudo systemctl enable nginx.service
7. 定时更新源
sudo crontab -e 添加:*/30 * * * * /usr/bin/curl -Ls 'http://rss.yourdomain.com/update' >/dev/null sudo systemctl start cron
8. 登录
访问https://your_selfoss_url.com/password,获取哈希后的密码,填入到ini中,登录即可
设置代理
在/selfoss/spouts/rss/feed.php 中为rss feed模块设置代理
参考:https://github.com/fossar/selfoss/issues/871
在154行左右
@$this->feed->set_feed_url(htmlspecialchars_decode($params[‘url’]));
@$this->feed->set_autodiscovery_level( SIMPLEPIE_LOCATOR_AUTODISCOVERY | SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY);
$this->feed->set_useragent(\helpers\WebClient::getUserAgent(array(‘SimplePie/’.SIMPLEPIE_VERSION)));
下面添加
$this->feed->set_curl_options(array(CURLOPT_PROXY => ‘localhost:9050‘, CURLOPT_PROXYTYPE => ‘CURLPROXY_SOCKS5’));
问题解决
502错误
查看日志发现是[error] 38134#38134: *25 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: “GET /update HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host: “127.0.0.1”
重启 php7.2-fpm.service:sudo systemctl restart php7.2-fpm.service
为了保证php7.2-fpm.service崩溃自动重启:
1. 建立 sudo mkdir /etc/systemd/system/php7.2-fpm.service.d
2. 在php7.2-fpm.service.d目录里面,建立override.conf,内容是
[Service]
Restart=always
RestartSec=10
3. sudo systemctl daemon-reload
4. sudo systemctl restart php7.2-fpm.service
升级php7.4问题
Ubuntu18只能源码安装php7.4
源码下载
wget https://github.com/php/php-src/archive/php-7.4.15.tar.gz --no-check-certificate 或者 wget http://be2.php.net/get/php-7.4.15.tar.gz/from/this/mirror -O php-7.4.15.tar.gz
安装依赖
sudo apt install -y gcc make openssl curl libbz2-dev libxml2-dev libjpeg-dev libpng-dev libfreetype6-dev libzip-dev libssl-dev libsqlite3-dev libcurl4-openssl-dev libgmp3-dev libonig-dev libreadline-dev libxslt1-dev libffi-dev
解压配置
tar -xzvf php-7.4.15.tar.gz cd php-src-php-7.4.15
configure配置,放到/usr/local/php74目录
./configure --prefix=/usr/local/php74 --enable-fpm --enable-mbstring --enable-bcmath --enable-fileinfo --with-openssl --with-zlib --with-iconv --with-curl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pear --enable-xml --enable-sockets --enable-soap --enable-cli
编译安装
sudo make && sudo make install
配置PHP-FPM服务
sudo cp /usr/local/php74/etc/php-fpm.conf.default /usr/local/php74/etc/php-fpm.conf sudo cp /usr/local/php74/etc/php-fpm.d/www.conf.default /usr/local/php74/etc/php-fpm.d/www.conf
修改监听配置
sudo vi /usr/local/php74/etc/php-fpm.d/www.conf
# 找到以下行并修改(建议使用sock文件): listen = /run/php/php7.4-fpm.sock
创建Systemd服务文件
sudo vi /etc/systemd/system/php7.4-fpm.service
添加以下内容:
[Unit] Description=The PHP 7.4 FastCGI Process Manager After=network.target [Service] Type=simple PIDFile=/run/php74-fpm.pid ExecStart=/usr/sbin/php74-fpm --nodaemonize --fpm-config /usr/local/php74/etc/php-fpm.conf ExecReload=/bin/kill -USR2 $MAINPID [Install] WantedBy=multi-user.target
开启服务
sudo systemctl daemon-reload sudo systemctl start php7.4-fpm sudo systemctl enable php7.4-fpm
修改/etc/nginx/conf.d/selfoss.conf下面部分改成php7.4等
location ~ \.php$ { fastcgi_pass unix:/run/php/php7.4-fpm.sock;
遗留问题
nginx跨域不生效