分類
网站

WGS-84 To GCJ-02 經緯度在線轉換

之前一直在用http://api.zdoz.net提供的免費接口做GPS坐標轉火星坐標,也挺好用,直到發現了hiwanz的https://github.com/hiwanz/wgs2mars.js,這樣就可以減少一次網絡請求。

緯度Latitude:   
經度Longitude:
緯度Latitude:   
經度Longitude:

在開放街圖中查看原始位置

在谷歌地圖中查看轉換後的位置

本文更新於 2021/05/04。

分類
网站

中文WebFont體驗

Webfont中文字體效果

春有百花秋有月

3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679

這裡使用了字蛛來製作中文webfont,它的作用是可以根據需要展現的中文來製作網頁字體文件,這樣就避免了中文字體文件過大的問題。使用字蛛需要Node.js,那麼就來安裝。

CentOS安裝Node.js

由於我已經使用了epel-release庫,所以只要yum install nodejs就搞定了,如果沒有使用epel-release庫,可以通過yum install epel-release來使用。

#查看node.js版本
node --version
#通常我們都需要npm這個包管理器
yum install npm
#我用的CentOS6,默認安裝的版本太低,升級node.js我用的nvm,node版本管理器
#使用下面的命令來安裝給當前用戶(檢查下網址,畢竟是要執行的東西)
curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash
#想要使用nvm還有執行下下面命令先
source ~/.bash_profile
#現在可以吃用nvm查看可以安裝的node.js版本了
nvm list-remote
#選擇需要安裝的版本,然後安裝
nvm install v5.12.0
#把5.12.0設置為默認版本
nvm alias default v5.12.0
nvm use v5.12.0

使用字蛛

字蛛的文檔寫的不夠傻瓜,我是試了幾次才成功的,說說我的方法。首先準備好需要的ttf字體文件如OCR.ttf,然後準備一個網頁html文件如下:

<!-- index.html -->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<style>
@font-face {
  font-family: 'OCR';
  src: url('font/OCR.eot');
  src:
    url('font/OCR.eot?#font-spider') format('embedded-opentype'),
    url('font/OCR.woff') format('woff'),
    url('font/OCR.ttf') format('truetype'),
    url('font/OCR.svg') format('svg');
  font-weight: normal;
  font-style: normal;
}
p {
    font-family: 'OCR';
}
</style>
</head>
<body>
<p>這裡是需要用的字體文件的文字。</p>
</body>
</html>

我新建了一個font文件夾,這樣做出來的字體就會保存在font里而不是覆蓋同目錄下的font文件。原字體文件和html文件和font文件夾處於同一目錄中。接下來就很簡單了,安裝字蛛並執行。

#安装字蛛
npm install font-spider -g
#使用字蛛
font-spider index.html

打開font文件夾,就可以看到生成的各種webfont字體文件了。使用的方法和上面html里是一樣的,就不重複說了。

本文更新於 2022/01/28。

分類
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。

分類
程序

蛋國志

蛋國志

Emanon目前呆過福利最好的公司的遊戲終於公測了!蛋國志Facebook蛋國志谷歌市場。投放谷歌市場時應該鎖了區,所以大家可以通過APKPure搜索包名com.koogame.eggworld.ganpu01並選擇馬來西亞區進行下載體驗。

我的感覺是,遊戲很萌!蛋蛋們很可愛又各有特點,配樂也很有意思,作為遊戲,各個角色的配比也比較用心,總之還是很值得玩一玩的。我覺得萌度已經達到了The Battle Cats的高度,而且還比The Battle Cats耐玩,至少一開始是這樣。技能描述的小動畫我也很喜歡,藏的好深的。

蛋国志是一款有趣又有料的休闲竞技策略手游。耳熟能详的历史名将,变身创意有趣的蛋蛋人,来到独一无二的的蛋世界。

作为指挥官的你,要做的事情很简单,也很不简单!那就是:收集和培养你的英雄、搭配和调教你的阵容,努力成为最厉害的蛋国指挥官!

作为小编的我,小小剧透一下,在这个精彩有趣的蛋世界,包括但不限于的组合有: 关羽林冲姜子牙、荆轲黄忠诸葛亮、吕布貂蝉花木兰…各种奇葩各种组合,多人在线同场竞技,看看你的阵容谁能破?


新版本已經取消了鎖區,大家可以直接從谷歌市場下載玩耍了。而且上面提到的好玩的技能動畫現在只有在facebook才能看到,遊戲里還沒加上。另外告訴新手一個機密,能賣諸葛亮的時候趕緊買一個,保證一段時間內所向無敵!還有就是不充值並不影響遊戲體驗。


2017-06-15 時隔一年有新版本哦,新版有了新玩法和酷炫的皮膚,在酷市場下載蛋國志,在谷歌市場下載蛋國志。除了新增玩法和皮膚之外,人物的屬性似乎也有調整,當年法海加花木蘭加李白簡直天下無敵,現在要重新找個組合了。

本文更新於 2017/06/15。

分類
网站

Vesta面板與WordPress

Hostodo的主機,之前是花落無聲在玩,wupo.info寄存在上面。現在快期後,我續了費,昨天重裝了系統,記錄下。

首先到Vesta面板把網站備份下載下來,可以下做好的備份,也可以當時生成一個新備份。Hostodo重裝系統是很方便的,在後台選版本,然後等個幾分鐘就可以了。VestaCP的安裝也非常簡單,直接按官網首頁的三條命令安裝即可。我不知道默認安裝的組建是怎樣的,反正最後一條安裝的命令,我是在官網主頁生成的安裝參數,選擇的是nginx+php-fpm。安裝很快就完成,中間什麼都不用設,然後登錄VestaCP就可以新增網站了。

由於我之前不是管理員,所以我按之前的,給自己分配了普通用戶名,然後以普通用戶登錄,新增網站,新建數據庫,然後就進phpMyAdmin把之前數據庫導入。把備份的網站的public_html恢復到相應文件夾,這樣普通網站就完成了。VestaCP很方便開啟ssl,我用到是sslforfree提供的Let's Encrypt頒發的三個月免費證書,只要把證書文件粘貼到VestaCP就可以里,非常方便。

最後發現Wordpress前台自定義二級頁面都是VestaCP的404,後台卻完全正常。經過搜索,解決辦法為,在/home/yourName/conf/web/nginx.conf或snginx.conf中添加rewrite語句:

server{
    ……
    location / {
        try_files $uri $uri/ /index.php?$args;
        ……
    }
}

修改文件上傳大小上限

由於我有最高權限,所以我是修改/etc/php.ini來實現的,修改如下參數:

upload_max_filesize = 16M
post_max_size = 32M
max_execution_time = 300

最後在Vesta CP頂部/Server/php-ftm/重啟服務即可。

修改Vesta自帶的證書

自帶的證書是自簽發的不說,有效期也只有一年。想使用自己的證書,只需要用自己申請的證書(如Let's Encrypt)替換如下證書即可

cp /home/42/conf/web/ssl.admin.wupo.info.pem /usr/local/vesta/ssl/certificate.crt
cp /home/42/conf/web/ssl.admin.wupo.info.key /usr/local/vesta/ssl/certificate.key
service vesta restart

然後就可以用https://admin.wupo.info:8083/login訪問了。當然域名要記得指向這裡。

本文更新於 2018/03/12。