ArchLinux 安装

目前有少量ubuntu用户切换到了 Arch, 就抽空试用了一下。

ubuntu易用,资料全; arch简洁,更新更快,一开始的配置多一些, 据说速度快,但是我用gnome感觉不明显,而且 arch的稳定性还有些问题,习惯了ubuntu作为办公开发平台了, 主流的软件都会支持ubuntu, 就懒得折腾了。

Arch Linux 将简洁定义为一个轻量级基础结构,没有任何不必要的添加、修改和复杂,使得每个用户都可以按照他们的需要打造自己的系统。简而言之,即优雅、极简之道。

参考 :

http://fantlam.blogbus.com/logs/19353117.html

http://abitno.me/archlinux-2009-2-install-config

http://cbkid.blogbus.com/logs/36637166.html

http://forum.ubuntu.com.cn/viewtopic.php?f=155&t=110488&start=45

http://www.archlinux.org.cn/main/node/9/68

分享家:Addthis中国

Apache, Nginx性能比较, Nginx完胜

本文为yaozer原创, 文章比较长, 先放结论:  不管是用ab, 还是webbench进行并发测试, 10个并发用户访问时, apache与nginx差别不大,  但是随着并发量增加, 100个并发用户访问时, nginx优势巨大, 测试结果是apache的 6~8 倍.nginx 完胜!

使用软件ab, webbench进行测试Apache, Nginx性能, 测试页面为Magento 1.4.2.0的首页,环境如下:

测试环境:
IBM x3250 服务器 xeox 2.4G, 4G RAM, 250G RAID1
Centos 5.5, apache 2.2.17, mysql 5.1.52, nginx 0.9.3, php 5.2.16, magento1.4.2.0

webbench小巧简单, 测试结果如下:

—————————————-开始 webbench 测试 ———————————————————–

Apache Nginx Apache Nginx
webbench -c 10 -t 30 webbench -c 10 -t 30 webbench -c 100 -t 30 webbench -c 100 -t 30
10个并发用户访问30s 10个并发用户访问30s 100个并发用户访问30s 100个并发用户访问30s
速度 (页面/分钟) 1678 1618 1902 15432
速度 (字节/秒) 311045 299464 339006 1184762
成功请求个数 839 809 951 7716
失败请求个数 0 0 0 0
CPU占有率 90.30% 78.60% 99.90% 83.20%

webbench测试结论:
10个并发用户访问时, apache速度略优于nginx, 但是CPU占有率明显高于nginx;
100个并发用户访问时, nginx优势巨大,速度是apache的8倍左右, CPU占有率明显低于apache.

—————————————-开始 ab 测试 ———————————————————–

Apache Nginx Apache Nginx
ab -c 10 -n 1000 ab -c 10 -n 1000 ab -c 100 -n 1000 ab -c 100 -n 10000
文档长度(字节): 10684 10684 10684 3696
并发数: 10 10 100 100
测试运行时间(秒): 34.886 38.412 27.091 4.547
成功请求个数: 1000 1000 1000 1000
失败请求个数: 0 0 110 117
非2xx常规响应: 0 0 110 883
总传输字节: 11122000 11105000 10129032 4709431
HTML 传输直接: 10684000 10684000 9712262 4513596
平均每秒请求个数 28.66 26.03 36.91 219.91
每次请求平均时间 (ms毫秒): 348.861 384.12 2709.072 454.732
在某时间内(ms毫秒), 请求得到响应的比例
50.00% 318 326 2838 174
66.00% 373 423 3130 200
75.00% 412 461 3368 350
80.00% 430 477 3612 522
90.00% 478 523 4123 646
95.00% 523 565 4509 946
98.00% 599 683 5009 1590
99.00% 1016 787 5388 3150
100% (longest request) 1304 1233 5956 3578
CPU 88.80% 83.00% 99.90% 82.50

测试结论:
10个并发用户访问时, apache速度略优于nginx, 但是CPU占有率高于nginx;
100个并发用户访问时, nginx优势巨大,速度是apache的6倍左右,  CPU占有率明显低于apache.

—————————————-最终结论 ———————————————————–

最后结论, 不管是用ab, 还是webbench进行并发测试, 10个并发用户访问时, apache与nginx差别不大,  但是随着并发量增加, 100个并发用户访问时, nginx优势巨大, 测试结果是apache的 6~8 倍.

分享家:Addthis中国

ubuntu 10.10 升级卡在cups的解决办法

这是一个老问题了, 解决办法如下。 yaozer整理和撰写,转载请注明来源于yaozer博客

情况1: 仍然处于gnome桌面

解决办法:
如果是卡在“正在替换 cups ××××”这一步的话 , 方法如下可以使升级继续:

出现“正在替换 cups ××××”时,打开终端,输入:
ps ax | grep cups
然后把有cups字样的进程全部sudo kill 掉,然后再到“更新管理器”再次让系统升级,然后这次升级中,会出现“正在设置cups 1.4.4….”这里卡住的情况,在这个时候,再次输入:
ps ax | grep cups
然后会看到有一行是“start cups”的,把这一行sudo kill掉,然后升级就会继续进行。

情况2: 升级卡住后, 重启后无法进入桌面:
解决办法: 进入命令行的修复模式,
sudo /etc/init.d/cups stop
sudo update-rc.d -f cups remove
sudo /etc/init.d/smbd stop
情况1: 仍然处于gnome桌面

解决办法:
如果是卡在“正在替换 cups 1.4.4 ubuntu6XXX”这一步的话 , 方法如下可以使升级继续:

出现“正在替换 cups 1.4.4XXXXXXX”时,打开终端,输入:
ps ax | grep cups
然后把有cups字样的进程全部sudo kill 掉,然后再到“更新管理器”再次让系统升级,然后这次升级中,会出现“正在设置cups 1.4.4….”这里卡住的情况,在这个时候,再次输入:
ps ax | grep cups
然后会看到有一行是“start cups”的,把这一行sudo kill掉,然后升级就会继续进行。

情况2: 升级卡住后, 重启后无法进入桌面:
解决办法: 进入命令行的修复模式,
sudo /etc/init.d/cups stop
sudo update-rc.d -f cups remove
sudo /etc/init.d/smbd stop
sudo dpkg –configure -a

分享家:Addthis中国

使用update-rc.d管理Linux服务

在Linux系统下,一个Services的启动、停止以及重启通常是通过/etc/init.d目录下的脚本来控制的。然而,在启动或改变运行级别时,是在/etc/rcX.d中来搜索脚本。其中X是运行级别的number。本文将解释如何启动、关闭和修改服务的运行。

当你在Debian下安装一个新的服务,比如Apache2,安装完成后,默认情况下它会启动,并在下一次重启后自动启动。

但是如果你不是一直需要这个服务,只在需要的时候启用它,你可以禁用它。直到你需要使用的时候,执行如下指令:

/etc/init.d/apache2 start

要实现这个目的,你需要先在/etc/rcX.d目录中删除所有apache2的符号链接,但这个方法操作麻烦,且效率低下。因此,我们建议你使用update-rc.d命令来实现这个功能。

1、删除一个服务

如果你想手动的完全禁用Apache2服务,你需要删除其中的所有在/etc/rcX.d中的单一链路。但是如果使用update-rc.d,则非常简单:

update-rc.d -f apache2 remove

参数-f是强制删除符号链接,即使/etc/init.d/apache2仍然存在。

Note:这个命令仅仅禁止该服务,直到该服务被升级。如果你想在服务升级后仍然保持被禁用。应该执行如下的命令:

update-rc.d apache2 stop 80 0 1 2 3 4 5 6 .

2、增加一个服务

如果你想重新添加这个服务并让它开机自动执行,你需要执行以下命令:

update-rc.d apache2 defaults

并且可以指定该服务的启动顺序:

update-rc.d apache2 defaults 90

还可以更详细的控制start与kill顺序:

update-rc.d apache2 defaults 20 80

其中前面的20是start时的运行顺序级别,80为kill时的级别。也可以写成:

update-rc.d apache2 start 20 2 3 4 5 . stop 80 0 1 6 .

其中0~6为运行级别。

update-rc.d命令不仅适用Linux服务,编写的脚本同样可以用这个命令设为开机自动运行。

来源: http://blog.chinaunix.net/u3/108043/showart_2251855.html

分享家:Addthis中国

ubuntu10.04 的 php5.3 降级 到 php5.2

ubuntu10.04 的php版本是 php5.3, 很多程序可能不支持, 降级到php5.2 的方法如下:


01 sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr"\n" " "`


02 echo -e "Package: php5\nPin: release a=karmic\nPin-Priority: 991\n" | sudo tee /etc/apt/preferences.d/php > /dev/null
03 apt-cache search php5-|grep php5-|awk '{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}'|sudo tee -a /etc/apt/preferences.d/php > /dev/null
04 apt-cache search -n libapache2-mod-php5 |awk '{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}'| sudo tee -a /etc/apt/preferences.d/php > /dev/null
05 echo -e "Package: php-pear\nPin: release a=karmic\nPin-Priority: 991\n" | sudo tee -a /etc/apt/preferences.d/php > /dev/null

06 grep 'main restricted' /etc/apt/sources.list|grep -v "#"| seds/lucid/karmic/g | sudo tee/etc/apt/sources.list.d/karmic.list > /dev/null

07 sudo apt-get update

08 sudo aptitude install -t karmic php5-cli php5-cgi

09 sudo aptitude hold `dpkg -l | grep php5| awk '{print $2}' |tr"\n" " "`
来源:http://mrkandy.wordpress.com/2010/04/16/install-php-5-2-x-in-ubuntu-10-04-lucid/
分享家:Addthis中国

博百优怎么到处都是

现在很多个人站点上面放着不知所云的 博百优, 那到底什么是博百优呢?这原来是admin5.com发起的一个 SEO 活动。

http://bbs.admin5.com/thread-1672952-1-1.html

大赛时间 2010年4月12日至2010年7月13日
大赛举办方: admin5站长网
大赛赞助 挚盟 如果还有现金赞助包括奖品赞助请联系 qq 886128 强子
比赛关键词:博百优
参赛规则如下:
1. 所有参赛网站域名注册时间不限。
2. 所有参赛网站所做内容不限,但不能违反我国互联网相关政策。
3. 所有参赛网站优化手法不限,但不能恶意竞争,打击他人。
4. 必须是主域名首页页面关键词(例如 www.xxx.com 或xxx.com ),三级域名和二级页面无效(my.xxx.com bbs.xxx.com 等都无效)。
5. 本次大赛无需报名,团队或者个人均可直接参赛。
6. 所有排名应为搜索引擎自然排名(非竞价)。
7. 所有参赛站详细填写联系方式,方便发放奖品时准确核对相关信息。
8.本次大赛最后结束日期为:2010年7月13日12:00 到时由admin5站长网工作人员统计结果并截图公示。
9.参赛网站需要挂官方统一参赛宣传标识 (图片)。   

比赛奖励:
百度自然排名前5名(考虑谷歌的退出,谷歌组的优化比赛取消):
第一名 奖励 ¥5000元
第二名 奖励 ¥3000元
第三名 奖励 ¥2000元
第四名 奖励 ¥1000元
第五名 奖励 ¥500元
同时增设最佳设计,最佳创意,最实用网站 最活跃用户等奖项。其他外加奖励,视赞助情况而定,请关注比赛期间公告。

分享家:Addthis中国

ubuntu 10.01 restart mysql

yaozer@local:~$ sudo /etc/init.d/mysql restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql restart

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the restart(8) utility, e.g. restart mysql
mysql start/running, process 18095
yaozer@local:~$ sudo restart mysql
mysql start/running, process 18137

分享家:Addthis中国

ubuntu 10.04 倒计时

ubuntu 10.04 倒计时

分享家:Addthis中国

ubuntu 增加新硬盘

ubuntu 增加新硬盘的方法详解,  先中文概述, 英文好的,可以看后面的英文,更详细。

———————————————-中文  ubuntu 增加新硬盘的方法详解——————–

1 接上新硬盘

2 启动Ubuntu,root用户登录。

在终端输入:fdisk -l ,可以看到

—————————————————————————-

Disk /dev/sda: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0x000af383

Device Boot Start End Blocks Id System

/dev/sda1 * 1 1244 9992398+ 83 Linux

/dev/sda2 1245 1305 489982+ 5 Extended

/dev/sda5 1245 1305 489951 82 Linux swap / Solaris

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0×00000000

Disk /dev/sdb doesn’t contain a valid partition table

—————————————————————————-

这里可以看到/dev/sdb 就是我们新添加的硬盘,我们需要给新的硬盘分区。

在终端输入:fdisk /dev/sdb

之后键入:m,可以看到帮助信息,

键入:n,添加新分区

键入:p,选择添加主分区

键入:l,选择主分区编号为1,这样创建后的主分区为sdb1

之后,fdisk会让你选择该分区的开始值和结束值,开始值默认,  结束值可以输入形如  +200000M,  就是 200G 空间。

可以建立多个分区, 最后键入:w,保存所有并退出,完成新硬盘的分区。

3 格式化磁盘

在终端输入:sudo mkfs -t ext3 /dev/sdb1

用ext3格式对/dev/sdb1 进行格式化

使用1% 作为保留空间(默认为 5%, yaozer认为数据分区不需要那么多)

sudo tune2fs -m 1 /dev/sdb1

4 挂载该分区:

手动挂载:

在终端输入:mkdir /data ,创建新的硬盘的挂载点

在终端键入:mount /dev/sdb1 /data ,将该新分区挂载到/data/这个目录下开机自动挂载

修改/etc/fstab文件,添加如下行:

/dev/sdb1 /data ext3 defaults, 0 2

———————————-英文详解———————————————————–

1) Initiate fdisk with the following command:

  •   sudo fdisk /dev/sdb

2) Fdisk will display the following menu:

  •   Command (m for help): m <enter>
      Command action
       a   toggle a bootable flag
       b   edit bsd disklabel
       c   toggle the dos compatibility flag
       d   delete a partition
       l   list known partition types
       m   print this menu
       n   add a new partition
       o   create a new empty DOS partition table
       p   print the partition table
       q   quit without saving changes
       s   create a new empty Sun disklabel
       t   change a partition's system id
       u   change display/entry units
       v   verify the partition table
       w   write table to disk and exit
       x   extra functionality (experts only)
    
      Command (m for help):

3) We want to add a new partition. Type “n” and press enter.

  Command action
   e   extended
   p   primary partition (1-4)

4) We want a primary partition. Enter “p” and enter.

  Partition number (1-4):

5) Since this will be the only partition on the drive, number 1. Enter “1″ and enter.

  Command (m for help):

If it asks about the first cylinder, just type “1″ and enter. (We are making 1 partition to use the whole disk, so it should start at the beginning.)

6) Now that the partition is entered, choose option “w” to write the partition table to the disk. Type “w” and enter.

  The partition table has been altered!

7) If all went well, you now have a properly partitioned hard drive that’s ready to be formatted. Since this is the first partition, Linux will recognize it as /dev/sdb1, while the disk that the partition is on is still /dev/sdb.

Command Line Formatting

To format the new partition as ext3 file system (best for use under Ubuntu):

  •   sudo mkfs -t ext3 /dev/sdb1

To format the new partition as fat32 file system (best for use under Ubuntu & Windows):

  •   sudo mkfs -t fat32 /dev/sdb1

As always, substitute “/dev/sdb1″ with your own partition’s path.

Modify Reserved Space (Optional)

When formatting the drive as ext2/ext3, 5% of the drive’s total space is reserved for the super-user (root) so that the operating system can still write to the disk even if it is full. However, for disks that only contain data, this is not necessary.

NOTE: You may run this command on a fat32 file system, but it will do nothing; therefore, I highly recommend not running it.

You can adjust the percentage of reserved space with the “tune2fs” command, like this:

 sudo tune2fs -m 1 /dev/sdb1

This example reserves 1% of space – change this number if you wish.

  • Using this command does not change any existing data on the drive. You can use it on a drive which already contains data.

Create A Mount Point

Now that the drive is partitioned and formatted, you need to choose a mount point. This will be the location from which you will access the drive in the future. I would recommend using a mount point with “/media”, as it is the default used by Ubuntu. For this example, we’ll use the path “/media/mynewdrive”

  •   sudo mkdir /media/mynewdrive

Now we are ready to mount the drive to the mount point.

Mount The Drive

You can choose to have the drive mounted automatically each time you boot the computer, or manually only when you need to use it.

Automatic Mount At Boot

You’ll need to edit /etc/fstab:

  •   gksu gedit /etc/fstab

Add this line to the end (for ext3 file system):

  •   /dev/sdb1    /media/mynewdrive   ext3    defaults     0        2

Add this line to the end (for fat32 file system):

  •   /dev/sdb1    /media/mynewdrive   vfat    defaults     0        2

    The defaults part may allow you to read, but not write. To write other partition and FAT specific options must be used. If gnome is being used, use the right-click, mount method. Then launch the mount command from terminal, no options. The last entry should be the FAT drive and and look something like:

      /dev/sda5 on /media/mynewdrive type vfat (rw,nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,flush)

    All of the parts between the parenthesis are the mount options and should replace “defaults” in the fstab file. The “2″ at the end instructs your system to run a quick file system check on the hard drive at every boot. Changing it to “0″ will skip this. Run ‘man fstab’ for more info here.

You can now run “sudo mount -a” (or reboot the computer) to have the changes take effect.

If you want to allow a normal user to create files on this drive, you can either give this user ownership of the top directory of the drive filesystem: (replace USERNAME with the username)

  •   sudo chown -R USERNAME:USERNAME /media/mynewdrive

or in a more flexible way, practical if you have several users, allow for instance the users in the plugdev group (usually those who are meant to be able to mount removable disks, desktop users) to create files and sub-directories on the disk:

  •   sudo chgrp plugdev /media/mynewdrive
      sudo chmod g+w /media/mynewdrive
      sudo chmod +t /media/mynewdrive

The last “chmod +t” adds the sticky bit, so that people can only delete their own files and sub-directories in a directory, even if they have write permissions to it (see man chmod).

Manually Mount

Alternatively, you may want to manually mount the drive every time you need it.

For manual mounting, use the following command:

sudo mount /dev/sdb1 /media/mynewdrive

When you are finished with the drive, you can unmount it using:

sudo umount /media/mynewdrive

That’s it

https://help.ubuntu.com/community/InstallingANewHardDrive

分享家:Addthis中国

ubuntu 安装 apc 缓存

APC, Alternate PHP Cache, is now the most maintained free/open source op-code cache, and is being used more and more as it emerges to be the most stable.

The instructions here detail how to get APC running on an Ubuntu server running Gutsy Gibbon 7.10.

First, we need the pecl command so we can download and install APC from the repositories.

Do to so, we execute the following command:

aptitude install php-pear

But, this will not run on its own, we need the following package for the phpize command:

aptitude install php5-dev

We also need the apxs command, which is installed via the following package:

aptitude install apache2-dev

Now we have all the software we need, so we install apc via the pecl command:

pecl install apc

Once that finishes, we need to enable apc in Apache’s configuration. the following command should do this for us.

echo "extension=apc.so" > /etc/php5/apache2/conf.d/apc.ini

Then we restart Apache:

 /etc/init.d/apache2 restart

And we are all done. Watch for less execution time per page, and decreased memory usage per Apache process compared to what you had before.

分享家:Addthis中国
Page 1 of 612345...Last »