2008年12月30日星期二

2009新概念

2009新概念
一个中心:一切以健康为中心。
两个基本点:遇事潇洒一点,看世糊涂一点。
三个忘记:
忘记年龄,
忘记过去,
忘记恩怨。
四个拥有:
无论你有多弱或多强,一定要
拥有真正爱你的人,
拥有知心的朋友,
拥有向上的事业,
拥有温暖的住所。
五个要:
要唱,
要跳,
要俏,
要笑,
要苗条。
六个不能:
不能饿了才吃,
不能渴了才喝,
不能困了才睡,
不能累了才歇,
不能病了才检查,
不能老了再后悔。
看到了,
给你每一个珍惜的朋友!元旦快乐!

2008年12月19日星期五

LAMP配置流程

LAMP 安装说明
php5.0 要求libxml2-2.6.0以上更高的版本,这一解析器提供php5.0 新的XML API
===============================================================================================================================================
安装 libxml2
tar -zxvf libxml2-2.6.19.tar.gz
cd libxml2-2.6.19
./configure --prefix=/usr/local/libxml2
make
make install
这一步结束时,libxml2被安装在/usr/local/下。
================================================================================================================================================
安装 zlib
tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/usr/local/zlib
make
make install
这一步结束时,zlib被安装在/usr/local/下。
===============================================================================================================================================
安装 libpng
tar -zxvf libpng-1.2.10.tar.gz
cd libpng-1.2.10
cp scripts/makefile.linux makefile
make
make install
注意:这里的makefile不是用./configure 生成的,而是直接从script/目录里拷一个
这一步结束时,zlib被安装在/usr/local/lib下
=============================================================================================================================================
安装 freetype
tar -zxvf freetype-2.2.1.tar.gz
cd freetype-2.2.1
./configure --prefix=/usr/local/freetype
make
make install
这一步结束时,freetype被安装在/usr/local/lib下
============================================================================================================================================

安装 jpeg6
建立目录
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/include
mkdir /usr/local/jpeg6/man
mkdir /usr/local/jpeg6/man/man1
tar -zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
make
make install
注意:这里./configure一定要带--enable-shared参数,不然,不会生成共享库
=============================================================================================================================================
安装 gd
tar -zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr/local/gd --with-png=/usr/local/lib --with-freetype=/usr/local/freetype --with-jpeg=/usr/local/jpeg6
make && make install
==============================================================================================================================================
安装 curl 支持ftp库函数
tar -zxvf curl-7.15.0.tar.gz
cd curl-7.15.0
./configure --prefix=/usr/local/curl
make && make install
===============================================================================================================================================
安装 Apache2
以Apache使用php有两种方式:作为动态模块,其在运行状态时可以载入到web服务器,
或者作为静态模块,其可直接编译到web服务器代码中。对于文本,我们着重于第一种方式。
为了能让Apache2.0模块使php动态载入,Apache服务器必须以动态共享对象(DSO,Dynamic Shared Object)编译。
可以通过传递 --enable-so 参数到 Apache 2
tar -jxvf httpd-2.2.2.tar.bz2
cd httpd-2.2.2
./configure --prefix=/usr/local/apache2 --enable-so --enable-dav --enable-rewrite make && make install
//切记要支持Zend Optimizer不可加 --with-mpm=worker选项
这一过程将会设置,编译,以及将服务器安装到/usr/local/下。
启动apache守护进程:
/usr/local/apache2/bin/apachectl start (开启 start 关闭 stop 重启 restart)
打开浏览器,输入http://localhost 就能看到一个apache的欢迎页面了,这表示我们已经成功的安装了apache2 。
==============================================================================================================================================
安装 Mysql5
groupadd mysql
useradd -g mysql mysql

tar -zxvf mysql-5.0.17.tar.gz
cd mysql-5.0.17
./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --with-extra-charsets=all --with-big-tables --with-charset=utf8 --with-collation=utf8_unicode_ci
make
make install
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql/
bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql var
chgrp -R mysql .
启动服务:
/usr/local/mysql/share/mysql/mysql.server start (启动start 关闭stop 重启restart)
键入mysql回车就可已看到欢迎界面。说明我们已成功安装了mysql
说明:
--with-extra-charsets=all 对多语言支持
--with-unix-socket-path=/usr/local/mysql/var/mysql.sock 这个是指定mysql服务启动后。联机套接字文件所处的位置和文件名,也就是说,如果mysql服务器成功启动后,就能在/usr/local /mysql/var.采用这一选项,通常会出错,建议不配置用默认的。默认会在/tmp/mysql.sock.
目录中看到mysql.sock文件。

如果编译时出现了以下错误:
checking for tgetent in -ltermcap... no
checking for termcap functions library... configure: error: No curses/termcap library found
说明 curses/termcap 库没有安装
去下载一个ncurses-5.6.tar.gz,
wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz
tar zxvf ncurses-5.6.tar.gz
cd ncurses-5.6
./configure --prefix=/usr --with-shared --without-debug
make
make install clean
然后再重新编译Mysql进行安装。

1、
mysql的自启动我解决了,在/etc/rc.d/rc.local里加
/usr/local/mysql/bin/mysqld_safe -u mysql &

2、
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig –level 345 mysql on
/etc/init.d/mysql start

==================================================================================
安装 php5
tar -zxvf php-5.1.6.tar.gz
cd php-5.1.6
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs
--with-config-file-path=/etc --with-libxml-dir=/usr/local/libxml2
--with-zlib-dir=/usr/local/zlib --with-curl=/usr/local/curl
--with-gd=/usr/local/gd --with-jpeg-dir=/usr/local/jpeg6
--with-png-dir=/usr/local/lib --with-freetype-dir=/usr/local/freetype
--with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config
--with-openssl --enable-gd-native-ttf --enable-mbstring --enable-ftp
--enable-bcmath --enable-sockets --enable-zip --enable-soap
--enable-calendar //切记要支持Zend Optimizer不可加 --enable-debug选项
make
make install
cp php.ini-dist /etc/php.ini


编译php时出现

./configure: /usr/local/apache2/bin/apxs: /replace/with/path/to/perl/interpreter:
bad interpreter: No such file or directory
这是找不到perl解释器的缘故。
修改/usr/local/apache2/bin/apxs文件中:
/replace/with/path/to/perl/interpreter
把他替换成perl所在的路径如/opt/ActivePerl-5.8/bin/perl,
(如果你下载的是active perl5.8的rpm,他默认安装路径是/opt/ActivePerl-5.8/bin/perl)


=============================================
整合apache2和php5
apache 配置文件及目录是:
/usr/local/apache2/conf/httpd.conf
apache 默认存放主页的位置是:
/usr/local/apache2/htdocs
以下是配置文件里面的信息:(有的地方要做修改)
ServerRoot "/usr/local/apache2"
这是指定apache程序所在的目录,比如日志文件、配置文件等目录。
DocumentRoot "/usr/local/apache2/htdocs"
这个是存放网页的目录

这一句应该和DocumentRoot的目录保持一致。
找到 DirectoryIndex index.html
改为 DirectoryIndex index.html index.html.var index.htm index.php
找到 AddType application/x-gzip .gz .tgz
加 AddType application/x-httpd-php .php (注意空格)
AddType application/x-httpd-php-source .phps
添加 AddDefaultCharset utf8 使apache默认支持utf8字符集
保存配置文件就重启apache 的守护进程。
/usr/local/apache2/bin/apachectl restart

下载源码包 make && make install 之后, apache 并不会自动往 init.d 里面添加自己的 httpd service。需要手工把 apache 安装目录的 bin/apachectl 拷贝一份到 /etc/init.d/httpd 。如果想让 httpd service 能够在不同的运行级别下都能自动启动,还需要 vi /etc/init.d/httpd ,在 #!/bin/sh 下面增加几行 chkconfig 需要的内容:

# chkconfig: 2345 70 30
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd

关键是 chkconfig: 2345 70 30 这一行,第一个数字 2345 表示让 apache 在 2345 这四个级别都自动运行;第二个数字 70 表示进程启动的优先级;第三个数字 30 表示进程停止的优先级。修改保存之后执行 /sbin/chkconfig httpd reset ,chkconfig 就自动在各个级别的 rc*.d 中增加 httpd 的 link 。要查看 chkconfig 是否 reset 正确,通过命令 /sbin/chkconfig --list httpd 就可以查看当前 httpd service 被配置在哪几个运行级别自启动。

注意:
每次更改配置文件。要重启服务。
对存放网页的目录执行:命令chmod 755 目录名 或者 chmod -R 755 目录名

编辑php.ini文件,找到
;default_charset="iso-8859-1"
增加一行:default_charset="utf8"

以上步骤都执行完后。在/usr/local/apache2/htdocs/里编辑文件进行测试。
phpinfo.php
里面的内容:
phpinfo();
?>
在浏览器地址栏中输入:
http://localhost/phpinfo.php
出现php说明页面说明安装成功。
安装过程相当简单,网上很多这种文档,整理的也很详细,我就不多废话了。就具体就在fedora6下碰到的问题说明一下: 接下: ===========================================================================================

安装时的问题及解决方法

安装php5的过程中会自动在/usr/local/apache2/conf/httpd.conf里添加:
LoadModule php5_module modules/libphp5.so
重新启动apache报如下错误:
httpd: Syntax error on line 53 of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
解决办法:
chcon /usr/local/apache/modules/libphp5.so -t shlib_t
原因是Linux有一个SELinux保护模式引起的。
关闭SELINUX的方法:
vi /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disabled
保存,重起电脑即可.
FC5 中的SELinux 代表了用户,程序以及进程间相互交流的主要变化。

=============================================
安装phpMyAdmin2.8.1
unzip phpMyAdmin2.8.1.zip
cp -r phpMyAdmin2.8.1 /usr/local/apache2/htdocs
cd /usr/local/apache2/htdocs/phpMyAdmin2.8.1/libraries
cp config.default.php ../config.inc.php
gedit config.inc.php
找到$cfg['Servers'][$i]['auth_type'] = 'config'; // Authentication method (config, http or cookie based)?一行(大概在71行)将值改为http 或 cookie,随自己喜欢
==================================================================================
安装Zend optimizer3.2.8
这可能是最简单也是最容易出问题的地方(我在此吃尽苦头)
tar -zxvf ZendOptimizer-3.2.8-linux-glibc21-i386.tar.gz
cd ZendOptimizer-3.2.8-linux-glibc21-i386
./install
安装完后重启apache,在phpinfo.php的欢迎页面第二个域你会看到:
---------------------------------------------------------------------------------------------------------------------------------------------------
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with Zend Extension Manager v1.2.0, Copyright (c) 2003-2007, by Zend Technologies
with Zend Optimizer v3.2.8, Copyright (c) 1998-2007, by Zend Technologies
Zend logo

执行 /usr/local/php5/bin/php -v 应该看到:
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with Zend Extension Manager v1.2.0, Copyright (c) 2003-2007, by Zend Technologies
with Zend Optimizer v3.2.8, Copyright (c) 1998-2007, by Zend Technologies

否则就是安张出问题了。可能是编译apache画蛇添足添加了--with-mpm=worker 没有用默认的prefork模块
另一中可能就是编译php是加入了--enable-debug
zend optimizer 需要apache(perfork only) php(no debug Mod)这些在Zend optimizer User`Gurde上有说明需特别注意了
over

由于本人水平有限,遗漏 过错之处欢迎大家指正


让APACHE MYSQL 随系统启动:
编辑/etc/rc.local文件
# vi /etc/rc.local
在文件中写入
# 启动APACHE
/usr/local/apache2/bin/httpd -k start
# 启动MYSQL
/usr/local/mysql/bin/mysqld_safe --user=mysql &

2008年12月11日星期四

元旦快乐!

1、当今三大扯蛋:
靠工资买的起房那是扯蛋;
靠努力工作能升官那更是扯蛋;
说你没外遇那也绝对是扯蛋。


2、当今四大怪事:
做人的不如做狗的受宠爱;
做事的不如告密的受信赖;
在行的不如外行的提的快;
忽悠的比敬业的更豪迈。


3、当今五大谎言:
中石化说亏损;
警察说保护百姓;
小姐说俺是第一次;
老板说我亏不了你;
领导说好好干有机会。


4、现代人的五大悲哀:
一手好字被电脑废了;
一个好胃被酒废了;
一个好家被情人废了;
一个好官被人民币废了;
一个石油把大盘废了! 


5、改革六大成绩:
房产改革口袋掏空;
教育改革父母逼疯;
医疗改革提前送终;
企业改革下岗停工;
政府改革机构臃肿;
婚姻改革同居成风


值此元旦即将来临之际。

并送朋友们一副对联:
上联:该吃吃,该喝喝,遇事别往心里搁;
下联:泡泡澡,看著表,舒服一秒是一秒;
横批:元旦快乐!

2008年12月5日星期五

fdisk 删除操作

fdisk 对硬盘及分区的操作,进入fdisk 对硬盘操作阶段

  我们可以对硬盘进行分区操作,前提是您把fdisk -l 弄明白了;通过fdisk -l ,我们能找出机器中所有硬盘个数及设备名称;比如上面的例子,我们会看到两个设备一个是/dev/hda ,另一个是/dev/sda ;

  fdisk 操作硬盘的命令格式如下:

  [root@localhost beinan]# fdisk 设备

  比如我们通过 fdisk -l 得知 /dev/hda 或者 /dev/sda设备;我们如果想再添加或者删除一些分区,可以用

  [root@localhost beinan]# fdisk /dev/hda

  或

  [root@localhost beinan]# fdisk /dev/sda

  注 在以后的例子中,我们要以 /dev/sda设备为例,来讲解如何用fdisk 来操作添加、删除分区等动作;

  1、fdisk 的说明;

  当我们通过 fdisk 设备,进入相应设备的操作时,会发现有如下的提示;以 fdisk /dev/sda 设备为例,以下同;

[root@localhost beinan]# fdisk /dev/sda
Command (m for help): 在这里按m ,就会输出帮助;
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 注:l是列出分区类型,以供我们设置相应分区的类型;
m print this menu 注:m 是列出帮助信息;
n add a new partition 注:添加一个分区;
o create a new empty DOS partition table
p print the partition table 注:p列出分区表;
q quit without saving changes 注:不保存退出;
s create a new empty Sun disklabel
t change a partition's system id 注:t 改变分区类型;
u change display/entry units
v verify the partition table
w write table to disk and exit 注:把分区表写入硬盘并退出;
x extra functionality (experts only) 注:扩展应用,专家功能;

  其实我们常用的只有注有中文的,其它的功能我们不常用(呵,主要是我不会用,否则早会卖弄一下了);x扩展功能,也不是常用的;一般的情况下只要懂得 d l m p q t w 就行了;

  下面以实例操作来详述,没有例子没有办法就,新手也看不懂;

  2、列出当前操作硬盘的分区情况,用p

Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux

  3、通过fdisk的d指令来删除一个分区

Command (m for help): p 注:列出分区情况;
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
Command (m for help): d 注:执行删除分区指定;
Partition number (1-6): 6 注:我想删除 sda6 ,就在这里输入 6 ;
Command (m for help): p 注:再查看一下硬盘分区情况,看是否删除了?
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
Command (m for help):

  警告:删除分区时要小心,请看好分区的序号,如果您删除了扩展分区,扩展分区之下的逻辑分区都会删除;所以操作时一定要小心;如果知道自己操作错了,请不要惊慌,用q不保存退出;切记切记!!!!在分区操作错了之时,千万不要输入w保存退出!!!