分类存档: 互联网

树莓派安装LNMP(DietPi)

最近拿到朋友的一个树莓派,因为自己用的就是linux桌面环境,再用它装桌面环境没什么意思,打算做一个精简的web server。

操作系统如果选择Raspbian,除了Wheezy(Debian7)版本,已经有了Jessie(Debian8)版本,Jessie最近还出了一个light版,也就是精简版本的,不带桌面环境。

另一个选择就是DietPi,在Raspbian基础上精简的,也相当不错。

都试了试,感觉还是后者更精简一些,后者是Raspbian light版所占空间的一半,大概600多M,才300来个包,而前者则有400多个包。

下面简单说一下在Linux下安装配置DietPi(Jessie)的过程:

1、DietPi下载地址:http://fuzon.co.uk/phpbb/viewtopic.php?f=8&t=9

下载之后,解压,dd刻录到tf卡上:

dd if=DietPi_v94_RPi-\(Jessie\).img of=/dev/mmcblk0

2、如果用dhcp方式,把卡插上就可以启动了,不过,由于默认是dhcp,想连接的话,还需要想办法获取其ip来ssh连接,因此,建议配置成静态ip,配置方法:

在linux下,修改tf卡上的文件:

vi /run/media/linux/1263ae8d-aaf3-41b6-9ac0-03e7fecb5d6a/etc/network/interfaces

将其中的

# Ethernet
#auto eth0
iface eth0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1

改为:

# Ethernet
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1

无线网卡的(前提是无线网卡已经驱动起来,且有无线网络可用):

# Ethernet
auto wlan0
iface wlan0 inet static
address 192.168.1.101
netmask 255.255.255.0
gateway 192.168.1.1
wpa-ssid mywifi
wpa-psk mypassword

如果想修改源,则修改下面文件:

vi /run/media/linux/1263ae8d-aaf3-41b6-9ac0-03e7fecb5d6a/etc/apt/sources.list

这个版本的DietPi还有wheezy的源,删掉:

rm /run/media/linux/1263ae8d-aaf3-41b6-9ac0-03e7fecb5d6a/etc/apt/sources.list.d/*

3、配置好上面东西之后,插上tf卡,启动系统。

为了省事,我一般会先设置密钥登录:

ssh-copy-id root@raspberry IP

密码为dietpi,然后:

ssh root@raspberry IP

ssh连接之后,系统会自动升级,让他自动升级,会有一系列的配置,根据自己要求修改。另外,也可以自己调用dietpi-*一系列命令来进行配置或升级等。

下面是我根据自己习惯进行的一些配置:

(1)系统默认ssh server为非常轻量的dropbear,但它不支持客户端scp上传,干掉它,安装openssh-server。

apt-get install openssh-server
apt-get purge dropbear

(2)系统默认编辑器为nano,干掉它,装vim。

apt-get install vim
apt-get purge nano

(3)系统升级

apt-get update;apt-get upgrade -y

4、安装nginx、php、mariadb:

apt-get install nginx-light php5-fpm php5-mysql mariadb-server

安装过程中需要设置mariadb的root密码。安装完成之后,这几个服务会自动启动,并添加开机启动,这也是deb系发行版的一个特色吧。

另外,由于没有ipv6地址,nginx启动会出错。

解决办法就是将/etc/nginx/sites-enabled/default中的listen 80 default_server;下面一行监听ipv6的代码删掉。

具体配置nginx/php-fpm的方法见其他文章,这里就不再写了。

最后写个phpinfo测试一下就好了。

最后:看一下安装的软件包数量及占用空间情况:

root@DietPi:/etc/nginx# dpkg --get-selections|wc -l
316
root@DietPi:/etc/nginx# df -h
文件系统        容量  已用  可用 已用% 挂载点
/dev/root       7.2G  911M  6.3G   13% /
devtmpfs        483M     0  483M    0% /dev
tmpfs           487M     0  487M    0% /dev/shm
tmpfs           487M  6.5M  481M    2% /run
tmpfs           5.0M     0  5.0M    0% /run/lock
tmpfs           487M     0  487M    0% /sys/fs/cgroup
tmpfs            10M  956K  9.1M   10% /DietPi
tmpfs            20M   24K   20M    1% /var/log
tmpfs           487M     0  487M    0% /tmp
/dev/mmcblk0p1   56M   21M   36M   37% /boot
tmpfs            98M     0   98M    0% /run/user/0

当然,如果没有无线网卡,也不连接ntfs的存储设备,还有一些包可以删掉:

apt-get purge firmware* wireless* ntfs

博客的Akismet好像出问题了,最近的评论被删除了

这两天垃圾评论泛滥,昨天清理的时候,结果把最近的几条评论删除了。。。

我的必备Chrome扩展程序

虽然不怎么用Chrome,但这个优秀的跨平台浏览器在linux下也一直装着,尝试过用它来代替firefox,但没有成功,不习惯,现在只是偶而用一下。Chrome下的扩展程序也不错。

必备扩展:

1、Neat Bookmarks(安装),灵巧实用的侧置书签扩展,总体上不如firefox的默认书签工具,不方便;

2、Sexy Undo Close Tab(安装),标签恢复工具,一般般吧;

3、Yet Another Drag and Go(安装),超级拖拽工具,不错的;

4、Proxy SwitchySharp(安装),基于 “Proxy Switchy!” 和 “SwitchyPlus” 开发的代理工具,也很不错的;

5、豆瓣FM精美版(安装),歌词同步, 去插播广告,非常不错,目前在firefox没有找到相应的工具。

我的必备firefox扩展和插件

必备的firefox扩展和插件,linux下和windows(虽然不怎么用)下都用的,记录一下:

必备扩展:

1、Tab Mix Plus(安装),增强标签页浏览功能;

2、QuickDrag(安装),扩展鼠标拖拽功能,使它可以加载链接、搜索文字或保存图片;

3、DownThemAll(安装),Firefox的批量下载工具;

4、AutoProxy(安装),不说了,你懂的;

5、NetVideoHunter(安装),在线视频下载工具。

以上为必备,其他备选的:UnMHT(查看和保存mht格式网页,安装)、FireFTP(支持sftp的ftp工具,安装)、FireSSH(网页中登录ssh,安装)、FlashGot(外部下载管理器,可以调用linux版flashget,安装)、User Agent Switcher(修改user agent,可以看迅雷看看的视频,因为迅雷喜欢苹果,不喜欢linux,安装)。

必备插件:

1、Shockwave Flash(下载),这个不用说了;

2、Aliedit(下载),淘宝登录插件。

成绩程序迁移到github

在github上建立了一个项目,把最新代码迁移到了github上面。

地址:https://github.com/zhcj/phpcj

创建和简单使用github

在linux(以gentoo为例)下如何创建和管理git项目:

1、安装git程序:

emerge -av git

2、客户端配置:
//配置用户名

git config --global user.name zhcj

//配置email

git config --global user.email zhcj@yeah.net

//修改编辑器为vi(默认为nano)

git config core.editor vi

//生成SSH public key

cd ~/.ssh
ssh-keygen -t rsa -C zhcj@yeah.net

3、服务器端配置
//注册
http://github.com/plans
//创建项目名,如phpcj
//添加客户端生成的SSH public key
.sshid_rsa.pub文件中的内容
4、初始化客户端

mkdir ~/phpcj
cd phpcj
git init
git add .
git commit -m zhcj
git remote add origin https://github.com/zhcj/phpcj.git
git push -u origin master

5、提交新修改

git commit -a
git push origin master

您的证书具有与证书授权机构发行的另一个证书同样的序列号。请获取具有唯一序列号的新证书。

firefox访问一些网站出现如下提示:

您的证书具有与证书授权机构发行的另一个证书同样的序列号。请获取具有唯一序列号的新证书。

解决办法:

首选项->高级->加密->查看证书,将该网站的证书删除,再次访问后添加证书即可。

杨致远辞职

创始人杨致远辞去雅虎董事会董事以及所有其它公司职位,立即生效。

SUNNYVALE, Calif.–(BUSINESS WIRE)– Yahoo! Inc. (NASDAQ: YHOO), the premier digital media company, today announced that Jerry Yang has resigned from its Board of Directors and all other positions with the company, effective today. In addition, Yang resigned from the Boards of Yahoo Japan Corporation and Alibaba Group Holding Limited, effective today.

In a letter to the Yahoo! Board Chairman Roy Bostock, Yang wrote:

“My time at Yahoo!, from its founding to the present, has encompassed some of the most exciting and rewarding experiences of my life. However, the time has come for me to pursue other interests outside of Yahoo! As I leave the company I co-founded nearly 17 years ago, I am enthusiastic about the appointment of Scott Thompson as Chief Executive Officer and his ability, along with the entire Yahoo! leadership team, to guide Yahoo! into an exciting and successful future.”

Yang co-founded Yahoo! Inc. in 1995 with David Filo and served as a member of the Board of Directors since March 1995 and as Chief Executive Officer from June 2007 to January 2009. The Company went public in 1996.

“Jerry Yang is a visionary and a pioneer, who has contributed enormously to Yahoo! during his many years of service,” said Roy Bostock, Chairman of the Yahoo! Board. “It has been a pleasure to work with Jerry. His unique strategic insights have been invaluable. He has always remained focused on the best interests of Yahoo!’s stakeholders, including shareholders, employees and more than 700 million users. And while I and the entire Board respect his decision, we will miss his remarkable perspective, vision and wise counsel. On behalf of the Board, we thank Jerry and wish him all the very best in his future endeavors.”

Bostock concluded, “We appreciate Jerry’s comments and share his enthusiasm for the company’s prospects. With Scott Thompson leading an outstanding team of Yahoos to deliver innovative products and an engaging customer experience, Yahoo!’s future is bright.”

“I am grateful for the warm welcome and support Jerry provided me during my early days here,” said Scott Thompson, Yahoo!’s Chief Executive Officer. “Jerry leaves behind a legacy of innovation and customer focus for this iconic brand, having shaped our culture by fostering a spirit of innovation that began 17 years ago and continues to grow even stronger today. Jerry has great confidence in the future of Yahoo!, and I share his confidence in the enormous potential of Yahoo! in the days ahead.”