分類
音乐

一個兒童的共產主義夢想 VS Which Side Are You On

一個兒童的共產主義夢想 - 周雲蓬

Which Side Are You On? - The Weavers


一個兒童的共產主義夢想-周雲蓬


大雨嘩嘩下喲 北京來電話
大雨嘩嘩下喲 北京來電話
去當兵 去當兵
他讓我去當兵
我還沒長大 我還沒長大

樓上和樓下 電燈和電話
樓上和樓下 電燈和電話
一拉燈 一拉燈
屋子裏亮通通
自來水擰一下
水流嘩啦啦

二零零零年 四個現代化
二零零零年 四個現代化
假話 空話 大話和廢話
不如去喝酒 喝醉了說胡話
不如去睡覺 睡著了說夢話

Which Side Are You On? - The Weavers

Which side are you on? (4)
Come all of you good workers,
Good news to you I'll tell
Of how the good old union
Has come in here to dwell.

Which side are you on? (4)
My daddy was a miner
And I'm a miner's son,
And I'll stick with the union
'Til every battle's won.

Which side are you on? (4)
They say in Harlan County
There are no neutrals there;
You'll either be a union man,
Or a thug for J. H. Blair.

Which side are you on? (4)
Oh workers can you stand it?
Oh tell me how you can.
Will you be a lousy scab
Or will you be a man?

Which side are you on? (4)
Don't scab for the bosses,
Don't listen to their lies.
Us poor folks haven't got a chance
Unless we organize.

本文更新於 2018/11/08。

分類
說說

發光的臉

白露以後,太陽在七點前就會落山。下班路上經過公交站,每個等車的人的臉上都反著手機屏幕的光。他們在做什麼呢?看娛樂新聞,看政治軍事,看朋友圈,發微信。內心或喜或悲,並不溢於言表。不知道他們的精神世界是豐富還是匱乏。#Matrix#

但這仍是進步,人們可以在有限的情況下來選擇自己想要的信息,而不是完全被動的接收信息。這時最重要的問題是信息的獲取,信息的來源,信息的類型,信息的作用都值得稍微思考一下。否則即使是自己選的新聞娛樂,依舊和聽只有一個電台的收音機是一樣,除了做一下背景音消除一下尷尬,沒有任何意義。

吃飯工作睡覺XX,很重要,但肯定不是全部。

分類
說說

節日

有一天,兩國冰釋前嫌,好的如膠似漆,國民甚至可以選擇另一個國家的節假日作為自己的節假日。 於是節日分配成了人事部門的一項重要任務,做得好大家都能選到自己想要放假的日子,公司還能不停轉,一舉兩得。做不好當然就是比較慘。不過也有一些豪氣的公司兩邊都放假,不過這種一般是有兩地員工。而我的小姨子就是一名普通的人事。
分類
說說

1609051753

天氣轉涼。

十一去台灣。

順利的話十二月去沖繩。

還要找學車的信息和學車,可是學了應該也不會經常開,會不會忘了呢。

深大在高爾夫球場養黑山羊挺好的。幾年前奄奄一息的大樹,在大樹營養快線的幫助下也起死回生了。

使用WordPress安卓客戶端,過了這麼多年,感覺還是不怎麼好用。

#代碼測試。
分類
Linux

Monitorix查看Centos系統負載

Monitorix安裝

Monitorix is a free, open source, lightweight system monitoring tool designed to monitor as many services and system resources as possible. 本文是在Centos上安裝Monitorix。

#先安裝依賴
yum install rrdtool rrdtool-perl perl-libwww-perl perl-MailTools perl-MIME-Lite perl-CGI perl-DBI perl-XML-Simple perl-Config-General perl-HTTP-Server-Simple perl-IO-Socket-SSL
#3.8.1是20160810最新版
rpm -ivh http://www.monitorix.org/monitorix-3.8.1-1.noarch.rpm
#添加到開機啟動
chkconfig --level 35 monitorix on
#啟動Monitorix
service monitorix start

這時,只要訪問在本地訪問http://localhost:8080/monitorix/Monitorix即可查看系統狀態了。

Monitorix配置

Centos中Monitorix的配置文件位於/etc/monitorix/monitorix.conf,下面的設置都是在這個文件中修改。

給Monitorix設置密碼很簡單,參考這裡http://www.monitorix.org/documentation.html#4。其中提到的用戶名密碼默認保存在/var/lib/monitorix/htpasswd裡面。關於密碼加密,我是用的這個https://github.com/mikaku/Monitorix/raw/master/docs/htpasswd.pl,下載後./htpasswd.pl執行,輸入密碼即可得到加密後的密碼,把加密後的密碼放到用戶名:後面即可。

關於Monitorix配置其實還有很多可以貼,等下次安裝的時候再詳細記錄下,普通看官方文檔就好。通常檢測網卡要設置一下,一般都不是eth0。

如果nginx的代理是https,那麼需要在配置文件httpd_builtin中添加https_url = y,這樣圖片才能也走https。

nginx代理配置

在nginx增加如下配置
……
location /monitorix {
#    auth_basic "Restricted";
#    auth_basic_user_file /etc/monitorix/monitorix-users;

    include proxy_params;
    proxy_pass		http://127.0.0.1:8080/monitorix;
    allow		127.0.0.0/8;


    # since 3.5.0 version
    location ~ ^/monitorix/(.+\.png)$ {
        alias /var/lib/monitorix/www/$1;
    }
}
……

其中的proxy_params,nginx似乎沒有自帶的文件,我参考了https://www.howtoforge.com/tutorial/how-to-install-nginx-as-reverse-proxy-for-apache-on-ubuntu-16-04/,其中這麼寫:

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

client_max_body_size 100M;
client_body_buffer_size 1m;
proxy_intercept_errors on;
proxy_buffering on;
proxy_buffer_size 128k;
proxy_buffers 256 16k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_max_temp_file_size 0;
proxy_read_timeout 300;

然後service nginx restart重啟nginx就可以了。

CentOS6.4安裝perl-HTTP-Server-Simple

CentOS6.4執行上面依賴包安裝後提示"No package perl-HTTP-Server-Simple available.",可參考perl-HTTP-Server-Simple-0.42-1.el6.noarch.rpm進行安裝。

本文更新於 2018/03/09。

分類
Linux

CentOS6.6體驗_HTTPS

獲取免費SSL證書

接上篇:CentOS6.6體驗_LNMP。下面將在nginx中配置Let's Encrypt頒發的免費SSL證書。安裝方式參考Certbot,文章寫的很清楚,這個方法我沒有試。

另一種安裝方式是Using Free SSL/TLS Certificates from Let’s Encrypt with NGINX,我用這個裝的,挺方便的。其中提到的文件/etc/letsencrypt/configs/my-domain.conf可以放在/etc/letsencrypt/my-domain.conf。這裡把證書生成後的nginx站點配置抄一下:

server {
    listen 443 ssl default_server;
    server_name my-domain;

    #ssl on;#有的網站配置中有寫這一句,但是這篇文章中並沒有,我也沒加,沒發現有什麼問題
    ssl_certificate /etc/letsencrypt/live/my-domain/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/my-domain/privkey.pem;

    ...
}

檢查nginx站點配置並重啟nginx

nginx -t && nginx -s reload

把http重定向到https

下面兩種方法據說第一種比第二種快,我也不知道為什麼,希望大神解答。

server {
    listen 80;
    server_name domain.com;
    return 301 https://$server_name$request_uri;
}
server {
    listen 443 ssl;
    server_name domain.com;
    ssl on;
    # other
}
server {
    listen 80;
    server_name domain.com;
    rewrite ^(.*) https://$server_name$1 permanent;
}
server {
    listen 443 ssl;
    server_name domain.com;
    ssl on;
    # other
}

自動更新Let's Encrypt的免費SSL證書(未完成)

按照參考鏈接Using Free SSL/TLS Certificates from Let’s Encrypt with NGINX設置好定時任務後發現renew‑letsencrypt.sh並沒有執行成功。因爲腳本中第一行需要選擇1還是2,自動運行時並沒有給出。所以我還是自己手動執行一下那個腳本,也不費事。

nginx配置HSTS

HTTP Strict Transport Security (通常简称为HSTS) 是一个安全功能,它告诉浏览器只能通过HTTPS访问当前资源, 禁止HTTP方式.

server {
    listen 443 ssl;
 
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
 
    # This 'location' block inherits the STS header
    location / {
        root /usr/share/nginx/html;
    }
 
    # Because this 'location' block contains another 'add_header' directive,
    # we must redeclare the STS header
    location /servlet {
        add_header X-Served-By "My Servlet Handler";
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
        proxy_pass http://localhost:8080;
    }
}

本文更新於 2016/10/28。

分類
Linux

CentOS6.6體驗_LNMP

常用命令

#檢查更新
yum check-update
#執行更新
yum update
#安裝軟件,如nano
yum install nano
#查看CentOS版本號
cat /etc/redhat-release
#查看CentOS位數
getconf LONG_BIT
#安裝編譯組件
yum install gcc gcc-c++ make openssl-devel
或者
sudo yum groupinstall 'Development Tools'

首先還是用LNMP練手

參考http://www.krizna.com/centos/install-lemp-on-centos-6/

nginx

nginx官網下載源碼自己編譯安裝也是極好的,可以參考http://www.runoob.com/linux/nginx-install-setup.html

#用rpm添加nginx官方repository
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
#檢查更新
yum check-update
#安裝nginx
yum install nginx
#啓動nginx
service nginx start
#添加到開機自動啓動
chkconfig nginx on

nginx默認目錄:
Default document root directory: /usr/share/nginx/html
Default configuration file: /etc/nginx/nginx.conf
Default Virtual host config directory: /etc/nginx/conf.d/
Default Virtual host config file: /etc/nginx/conf.d/default.conf

mysql

yum install mysql mysql-server
service mysqld start
chkconfig mysqld on
#初始化mysql
/usr/bin/mysql_secure_installation

額,默認好像是5.1的,如果想安裝新版本可以從mysql官方源安裝。

rpm -ivh https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm
#默認5.7,如果要5.6,執行下面兩條命令
yum-config-manager --disable mysql57-community
yum-config-manager --enable mysql56-community
#查看現在庫里的mysql版本
yum repolist enabled | grep mysql
#安裝mysql
yum install mysql-community-server
service mysqld start
mysql_secure_installation
chkconfig mysqld on

新建用戶及數據庫可參考mysql tricks

安裝默認php5.3

#這裏默認是5.3.3,更高版本請跳過這一節往下看
yum install php-fpm php-mysql
#把php-fpm配置文件中到用戶從apache改爲nginx
nano /etc/php-fpm.d/www.conf
    #修改如下兩行
    user = nginx
    group = nginx
service php-fpm start
chkconfig php-fpm on

添加一個Virtual Host測試下,新建文件/etc/nginx/conf.d/phptest.conf,寫入下面內容,並且重啓nginx使之生效 sudo service nginx reload:

server {
    listen       8080;                          # listen port
    server_name  localhost;                     # Server name
    location / {
        root   /usr/share/nginx/html;           # Document root
        index index.php  index.html index.htm;
    }
    location ~ \.php$ {
        root           /usr/share/nginx/html;   # Document root
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

新建/usr/share/nginx/html/info.php測試下安裝是否成功:

<?php
phpinfo();
?>

升級或安裝php5.5

#rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
nano /etc/yum.repos.d/remi.repo
#修改其中[remi]和[remi-php55]兩部分中的enabled值爲1。
service httpd stop
service mysqld stop
#如果已經安裝了php要升級則執行
yum update -y
#如果是首次安裝則執行下面兩行
sudo yum install mysql-server
sudo yum install php php-mysql
service httpd start
service mysqld start
#更新下mysql
mysql_upgrade -u root -p
#php到配置文件夾/etc/php-fpm.d下會有php.conf.rpmnew,將其命名爲php.conf
#如果使用nginx,要修改user和group值爲nginx

phpmyadmin

yum install phpmyadmin

新建一個文件/etc/nginx/conf.d/phpMyAdmin.conf,內容爲

server {
    listen 8080; 
    location ~ \.php$ {
        root           /usr/share/phpMyAdmin;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
    location / {
        root           /usr/share/phpMyAdmin;
        index          index.php;
    }
}

還有兩點需要注意:

#修改php session到權限爲777
chmod 777 /var/lib/php/session
#mbstring missing
#去掉/etc/php.ini中mbstring前的;
#403
https://mos.meituan.com/library/17/how-to-install-phpmyadmin-on-centos6/


配置網卡相關:

#nano etc/sysconfig/network-scripts/ifcfg-eth0
ONBOOT=yes
NM_CONTROLLED=no
#如果要配置靜態ip
BOOTPROTO=static
    #並增加
IPADDR=192.168.1.42
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=114.114.114.114
DNS2=4.4.4.4
#重啓網絡服務 /etc/init.d/network restart
#修改hostname
#nano /etc/sysconfig/network
HOSTNAME=www.fortytwo.com
    #並在host中增加條目
#nano /etc/hosts
192.168.1.42 www.fortytwo.com

本文更新於 2016/12/27。