Saturday, September 12, 2020

install wordpress with php7 on aws ec2 t2.micro

 AWS EC2 t2.micro's default PHP version is 5.4, which is not supported by wordpress anymore.

Here is the bootstrap to install latest wordpress with PHP7 on AWS EC2 t2.micro


#!/bin/bash

yum update -y

amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2

yum install httpd -y

cd /var/www/html

wget https://wordpress.org/latest.tar.gz

tar -xzf latest.tar.gz

cp -r wordpress/* /var/www/html/

rm -rf wordpress

rm -rf latest.tar.gz

chmod -R 755 wp-content

chown -R apache:apache wp-content

sudo echo "


# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>

# END WordPress


" > .htaccess

chkconfig httpd on

systemctl start httpd


Sunday, August 30, 2020

马刺王朝 - 高祖本纪

高祖邓肯,维尔京岛人,沉稳重诺,寡言语,能服众,喜怒不形于色。少习泳,后改篮球。大学时展露头角。时人皆敬畏乔皇,高祖不以为然,曰:彼亦人也,吾何惧哉?

高祖97年入马刺,每战必身先示卒,后虽伤,然马刺众人皆愿推高祖为首。时值公牛朝乔皇暴政,天下苦之,四海鼎沸。高祖乃拜波波为军师,罗宾逊为上将,整军欲讨。军未发,乔皇已退,公牛解体。天下无主,群雄逐鹿。

高祖率军,讨平诸侯,称帝,立马刺王朝。


时有湖人奥尼尔怒曰:乔皇退,天下能者居之。吾力服诸侯,湖人名门望族。马刺素无名望,邓肯乳子何能,而独称帝?吾必讨之!奥尼尔号霸王, 力能扛鼎,诸侯皆惧,谓此巨灵转世也。

更有科比相助。科比号飞侠,曾与乔皇大战,不落下风。乔皇亦惊,谓后生可畏。

前公牛朝丞相杰克逊亦投霸王,王喜,呼为亚父。由是不服朝廷。

高祖曰:联初定王业,亦知诸侯不服者甚众,当亲往讨之。遂领兵与湖人战,不利。


其时马刺上将年迈,高祖左右无人,乃下招贤令。01年选帕克于草莽,02年招马努于欧陆。

帕克,法兰西人,用兵神速,号跑车,高祖拜为讨虏将军。

马努,潘帕斯人,号妖刀,用兵虚虚实实,神鬼莫测。然其人持才傲物,不按号令。

高祖虑之,问于波波:此狂生,用之何益?波波曰:自乔皇退位,公牛解体,天下群雄并起。然富莫如湖人,强莫如霸王,勇莫如飞侠。

圣城疲弊,君虽英雄盖世,然欲以一己之力,扭转乾坤,吾未见胜算也。马努虽狂,然其用兵,有乔皇之风。君止欲强,则君一人足矣,马努无所用。必欲破飞侠,灭霸王,成大业,非得此人相助不可。愿君勿疑,拜其为讨逆将军。君稳如泰山而镇全军,二讨勇悍而为先锋,上将虽老,余威犹在,如是,则大业可成。

高祖大悟,遂拜马努为讨逆将军。自是马刺文有波波,武有二讨,军势复振,03年六战灭湖人于圣城,世人皆惊。

网之基德窃喜,曰:霸王来,吾不敢不服。今霸王不在,邓肯何人?天下必入吾手。

高祖曰:霸王以暴治天下,令诸侯只知霸道,不知王道。联今当以王道取天下!遂六战破网,基德拜服,马刺王业复兴。同年,上将隐退。


湖人虽败,霸王飞侠皆不忿。亦求贤。邮差自盐湖城往,手套自西雅图投,一时云龙风虎,天下震怖。独高祖笑曰:此乌合众也。

04年再战,彼时霸王飞侠罅隙已成,虽一时天意,湖人涉险退马刺。然已成强弩之末,未能复辟。湖人遂散。


此时高祖,放眼宇内,无堪与敌者。乃于05年再举王旗。后虽一时失利于达拉斯,然马刺雄强,甲于天下,高祖雄略,举世无匹。07年有詹姆斯者,亦不世出之俊杰也。高祖与之战,连破之。

高祖亦知詹姆斯英才天纵,他日替兴王朝者,必其人也。乃语之曰:虽不在今日,然以君之才,必成大业。

詹姆斯后投热火,欲以龙王闪电为辅以成大业。


后高祖,二讨年岁渐长,诸侯渐叛。 然马刺再得一员良将,名伦纳德,其人手长掌大,寡言少语,不怒自威,颇有高祖之风。高祖喜之,欲付之以大事。

或天意使然,高祖于13年率马刺众将战热火,再遇詹姆斯,不敌。高祖怒,曰:乳子无他,但凭一时佼幸尔,吾必报之! 次年,高祖整军再讨热火,大破之,灭其国。詹姆斯遁回克里夫兰。诸侯惧,谓曰:高祖,二讨老而弥坚,又有伦纳德不亚詹皇,吾辈恐终为其下矣。

高祖乃逊位于伦纳德。


16年,高祖年迈,退隐。高祖所立马刺王朝,上承公牛,退纽约,败湖人,破网,拔活塞,斩骑士,灭热火。雄视天下22年,令诸侯膝行,称为常盛。

Saturday, May 7, 2016

which, whereis & locate

"which" command to find out if a relevant binary is already in your search path. For example: which php

"whereis" searches a broader range of system directories and is independent of your shell's search path.

"locate" consults a precompiled index of the file system to location filenames that match a particular pattern. "locate" can find any type of files as well, and its database is updated periodically by the updatedb command.

Friday, October 19, 2012

NETWORKING:packet addressing


network packets must be properly addressed in order to reach their destinations. Several addressing schemes are used in combination:
• MAC (media access control) addresses for use by hardware
• IPv4 and IPv6 network addresses for use by software
• Hostnames for use by people


Hardware (MAC) addressing
Each of a host’s network interfaces usually has one link-layer MAC address that distinguishes it from other machines on the physical network, plus one or more IP addresses that identify the interface on the global Internet. This last part bears repeating: IP addresses identify network interfaces, not machines.

IP addressing

The mapping from IP addresses to hardware addresses is implemented at the link layer of the TCP/IP model

Hostname “addressing”


Ports
IP addresses identify a machine’s network interfaces, but they are not specific enough to address individual processes or services, many of which may be actively using the network at once. TCP and UDP extend IP addresses with a concept known as a port



NETWORKING: TCP/IP components


TCP/IP is a protocol “suite,” a set of network protocols designed to work smoothly together. It includes several components:

• IP, the Internet Protocol, which routes data packets from one machine to another (RFC791)
• ICMP, the Internet Control Message Protocol, which provides several kinds of low-level support for IP, including error messages, routing assistance, and debugging help (RFC792)
• ARP, the Address Resolution Protocol, which translates IP addresses to hardware addresses (RFC826)2
• UDP, the User Datagram Protocol, which provides unverified, one-way data delivery (RFC768)
• TCP, the Transmission Control Protocol, which implements reliable, full duplex, flow-controlled, error-corrected conversations (RFC793)

These protocols are arranged in a hierarchy or “stack”, with the higher-level protocols making use of the protocols beneath them.



Saturday, March 3, 2012

PHP5.4 short array syntax

We used to define an array using the array() language construct:
array(
 key => value,
 key2 => value2,
 key3 => value3,
)

As of PHP 5.4 you can also use the short array syntax, which replaces array() with [].
$array = [
 "foo" => "bar",
 "bar" => "foo"
];
Good to see that we have another flexibility and can be lazier. But, to developers who highly agree with Python's philosophy 'There should be one-- and preferably only one --obvious way to do it', this may not be necessarily good. Another rule must be added in their development teams to specify which style should be used in projects.

Monday, November 21, 2011

find tables of a particular storage engine in mysql


If you have a database with some tables using MyISAM and some using InnoDB, you probably want to find out which tables are using InnoDB. 



SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'database_name' AND ENGINE = 'InnoDB';



It is also easy to find out a specific table's storage engine:



SELECT ENGINE FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'database_name' AND TABLE_NAME= 'table_name';