PHP整理架

我的朋友PHP

2009年7月25日 #

[置顶]在一家生活资讯网站的PHP笔试受到打击,讲一下题目吧

以往见到过多装B的面试官,都不如今天的这位有派——笔试完了直接托前台告知请回,这算是我经历过的最丢人的一次面试吧。
虽然心里五味杂陈,总算是服气这次笔试的题目,确实是自己功力有限。当即在大雨里跺脚指天,想要抓一把素质,那么先把代表性的题目在这里记录一下:

1.你是网站的负责人,有一天发现网站突然出现了很多不良的访问来源,这将会对网站有不利的影响,这时,需要你设计一套拦截、屏蔽系统来处理这个问题。请设计出此套系统的基本结构图、流程图。

2.用PHP或者python,或者其他你熟悉的语言,写一个定时任务,要求每5分钟抓取一次某网站(例如:http://www.baidu.com,http://www.kuxun.com),要求当获取内容中url不同时,生成新的文件。

3.有一天突然你接到一个朋友的短信,说网站中订票功能用不了了,你会怎么解决,请详细写出解决办法。

4.请推理出现在域名为.cn的每天访问量为10人次/天的网站数量。

5.例如:(这是我上京东复制的)
Host www.360buy.com
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11
Accept */*
Accept-Language zh-cn,zh;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset gb2312,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive
X-Requested-With XMLHttpRequest
Referer http://www.360buy.com/
Cookie __utma=97936925.1908988227742847700.1248432869.1248432869.1248432869.1; __utmz=97936925.1248432869.1
.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); 360buy.com_prodlook=162988

a:如果没有host,网站能正常访问吗?
b:Accept-Encoding gzip,deflate代表什么,什么时候可以使用?

大概写对了,请教同事后再来写答案。

有同仁会给我回复吗?

posted @ 2009-07-25 02:47 小博 阅读(1622) | 评论 (1)编辑 收藏

2010年7月30日 #

用户的$home/.dmrc已被忽略,这将无法保存 默认会话和语

用户的$home/.dmrc已被忽略,这将无法保存 默认会话和语言

权限管理,一不小心就搞出这种情况:

开机进入登录界面,输入用户名、密码回车后提示:“用户的$home/ .dmrc已被忽略,这将无法保存 默认会话和语言。该文件应该由用户所有,并且权限设置为644。用户的$home目录应由用户自己所有,别的用户也无法写入。

解决办法:
chmod 755 -R /home/用户名
chmod 644 /home/用户名/.dmrc

posted @ 2010-07-30 10:03 小博 阅读(513) | 评论 (0)编辑 收藏

2010年2月3日 #

Linux下安装最新Apache2.0.52+PHP5+GD2+MySQL等

Linux下安装最新Apache2.0.52+PHP5+GD2+MySQL等

来源:中国智慧在线( http: //article.21e.cn )

以下经过测试在red hat 9 和red hat A 3上通过!

如果你机器里原来装有了PHP或者APACHE的RPM或者低版本.你可以现删除,删除安装简洁一些,不过我的实际操作过程是煤油删除,而直接安装的.当然你也可以跟我一样!
首先,服务器GCC要有,不然什么都不能做.可以用gcc -v来查看是否安装了GCC,

#gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-34)

有以上类似信息说明已有GCC,没有就现安装吧,至于如何安装,我就不说了,可以用光盘安装或者是下载源文件都可以,当然你的版本不一定是3.2.3!

请下载以下所有的东西:

httpd-2.0.X.tar.gz 版本最好是下载最新的啦,下载地址:http://www.apache.org
MySQL-client-4.0.20-0.i386.rpm
MySQL-server-4.0.20-0.i386.rpm(如果你打算升级mysql的话请下载,下载地址:http: //www.mysql.org 当然也是下载最新的版本最好了,由于我不打算安装mysql,就省略了,安装的时候的步骤也是先安装mysql!)
php-5.0.X.tar.gz 下载地址:http://www.php.net
ZendOptimizer-2.5.3-linux-glibc21-i386.tar.gz
zend的最新版安装是好像有点问题,就下载这个版本就可以,zend用来加速php,你可以选择不安装!下载地址:http: //www.zend.com
gd-2.0.28.tar.gz 这个软件的下载地址,php推荐的是:http://www.boutell.com/gd/ 但是由于某些原因,开发者不支持gif图像的创建,这有点不太方便,所以,我下载了个支持gif图像的,也就是打了gif补丁的:http: //www.rime.com.au/gd/
libxml2-2.X.X.tar.gz 下载地址:
zlib-1.X.X.tar.gz 忘记了,自己找一下吧
jpegsrc.v6b.tar.gz 下载地址:ftp://ftp.uu.net/graphics/jpeg/
libpng-1.2.5.tar.gz 下载地址:http://www.libpng.org/pub/png/libpng.html
freetype2-X.X.tar.gz 下载地址:http://www.fretype.org

xpm-3.4k-2.i386.rpm 忘记了,自己找一下吧

以上都是我下载的官方地址,软件的版本中的X,你自己看看你想用哪个版,不过最好是用最新稳定版本的!如果你以前安装过上述软件的其他版本,你也可以选择不安装!

安装MYSQL 服务器:
#rpm -ivh MySQL-server-4.0.20-0.i386.rpm
#rpm -ivh MySQL-client-4.0.20-0.i386.rpm
安装好后试试能不能用
#mysql 如果设置了密码后测试方法是(mysql -u root -proot -h localhost 注意的是-p后煤没有空格,直接跟密码)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 27651 to server version: 4.0.20-standard
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

说明可以了!
请自己改mysql的密码,方法不说了!

安装XPM ( (X-Windows Pixelmaps)彩色图象文件格式,XPM(XPixMap)图形格式在X11中是一个标准格式,它把图形保存成ASCII文本,一个XPM的定义不仅仅是ASCII形式,它的格式还可以是 C源代码形式的,可以直接将它编辑到自己的应用程序中去。 )

#rpm -ivhxpm-3.4k-2.i386.rpm

安装libxml (Libxml2 是一个xml c语言版的解析器)
# tar -zxf libxml2-2.6.16.tar.gz
# cd libxml2-2.6.16
# ./configure (xml默认安装就可以,不要指定路径了,因为安装时php可能找不到它,PHP5只支持libxml2-2.5.10以上版本)
# make
# make install

安装zlib (Zlib是一个压缩和解压模块)
# tar -zxf zlib-1.2.2.tar.gz
# cd zlib-1.2
# ./configure --prefix=/usr/local/zlib2 (注意,如果您以前没有安装zlib,可以不指定路径,我是没有删除以前的低版本才指定的!以下雷同!)
# make
# make install

安装jpeg
# tar -zxf jpegsrc.v6b.tar.gz
# cd jpeg-6b/
# ./configure --prefix=/usr/local/jpeg6
# make
# make install-lib
如果你选择默认安装,可能很顺利,指定路径后,请先创建以下文件夹
错误提示:...... /usr/bin/install -c -m 644 jconfig.h /usr/local/jpeg6/include/jconfig.h
/usr/bin/install: 无法创建一般文件‘/usr/local/jpeg6/include/jconfig.h’: 没有那个文件或目录
make: *** [install-headers] Error 1
# mkdir /usr/local/jpeg6
# mkdir /usr/local/jpeg6/include
# mkdir /usr/local/jpeg6/lib
# make install-lib
# make install

安装时如果错误提示:
/usr/bin/install: 无法创建一般文件‘/usr/local/jpeg6/lib/libjpeg.a’: 没有那个文件或目录
make: *** [install-lib] Error 1
创建如下文件夹:
# mkdir /usr/local/jpeg6/lib
# make install
/usr/bin/install -c cjpeg /usr/local/jpeg6/bin/cjpeg
/usr/bin/install: 无法创建一般文件‘/usr/local/jpeg6/bin/cjpeg’: 没有那个文件或目录
make: *** [install] Error 1
# mkdir /usr/local/jpeg6/bin
/usr/bin/install -c -m 644 ./cjpeg.1 /usr/local/jpeg6/man/man1/cjpeg.1
/usr/bin/install: 无法创建一般文件‘/usr/local/jpeg6/man/man1/cjpeg.1’: 没有那个文件或目录
make: *** [install] Error 1
# mkdir /usr/local/jpeg6/man
# mkdir /usr/local/jpeg6/man/man1
# make install
好了,直到安装成功!

安装libpng:
# tar -zxf libpng-1.2.7-config.tar.gz
# cd libpng-1.2.7-config
# ./configure --prefix=/usr/local/libpng2
# make
# make install

安装freetype: (Freetype是一个操作字体的函数库,它不但可以处理点阵字体,也可以处理多种矢量字体,包括truetype字体,为上层应用程序提供了一个统一的调用接口。
# tar -zxf freetype-2.1.9.tar.gz
# cd freetype-2.1.9
# ./configure --prefix=/usr/local/freetype2
# make
# make install

安装gd库:
# tar -zxf gd-2.0.26gif.tar.gz
# cd gd-2.0.26gif
# ./configure --prefix=/usr/local/gd2 --with-zlib=/usr/local/zlib2/ --with-png=/usr/local/libpng2/ --with-jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype2/ (请指定及格插件的安装路径,否则安装php的时候可能出错!)
# make
# make install

安装apache,(php5安装环境需要apache2.0.46以上版本,下载的时候注意!)
#tar zxvf httpd-2.0.50.tar.gz
#cd httpd-2.0.50
#./configure --prefix=/usr/local/apache2 --enable-module=so
#make
#make install

安装php5:
# tar -zxf php5-200411260130.tar.gz
# cd php5-200411260130
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/libpng2/ --with-gd=/usr/local/gd2/ --with-freetype-dir=/usr/local/freetype2/ --enable-trace-vars --with-zlib-dir=/usr/local/zlib2/ -with-mysql=/var/lib/mysql
# make
# make install
# cp php.ini-dist /usr/local/php/lib/php.ini

安装libxml的时候如果指定了路径,make的时候可能出错,所以,我安装的时候没指定!
我MAKE PHP4.3.8 和5的时候都遇到:
ext/gd/gd.lo(.text+0x63a): In function `zm_deactivate_gd':

/root/software/php-4.3.8/ext/gd/gd.c:385: undefined reference to `gdFreeFontCache'

collect2: ld returned 1 exit status

make: *** [sapi/cli/php]Error 1
另外还有一个错误可能是什么: libphp.lo的错误(错误当时没有纪录,忘记了,大概是!)
是因为GD库的freetype没装,或者是安装gd库的时候煤油指定插件的路径!!

复制PHP.INI文件到正确位置
在PHP目录下运行
#cp php.ini-dist /usr/local/php/lib/php.ini

编辑apache配置文件httpd.conf
#vi /usr/local/apache2/conf/httpd.conf

要改的有如下几处:

一般都在
#AddType application/x-tar .tgz
下加一行
#LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
或者是AddType application/x-httpd-php .php .phtml
如果你搜索其它地方没有以下这行

LoadModule php5_module modules/libphp5.so
请把上面的#号去掉

还有找到
DirectoryIndex index.html index.html.var
在后面加 index.php 让它把index.php做为默认页

找到
# don't use Group #-1 on these systems!
把下面的用户名和组改为
User apache
Group apache
(原来好像是nobody)

再找
#ServerName
把#去掉,后面的IP改成你的IP.

找到
DocumentRoot "/usr/local/apache2/htdocs"
把/usr/local/apache2/htdocs改为你存放网页文件的路径

为了让中文网页没乱码
找到
AddDefaultCharset iso8859-1
把后面的iso8859-1改为gb2312 或者是干脆off
其他的选项就自己修改吧!或者到http://article.21e.cn 有一个专门的httpd.conf的说明!

保存httpd.conf文件.

启动apache
# /usr/local/apache2/bin/apachectl start
如果没有出错,写一个测试页放到你网页目录下.访问就应该可以看到php的版本等信息了!

如无意外.PHP脚本已经可以连接mysql了.

用ZendOptimizer加速PHP

#tar zxvf ZendOptimizer-2.5.3-linux-glibc21-i386.tar.gz
#cd ZendOptimizer-2.5.3-linux-glibc21-i386
#./install.sh
安装的时候注意输入正确的安装apache的路径等内容!
安装完毕,再看看phpinfo页面的zend选项就发现了!!

如果你以前的apache没有删除,而你又想使用
# /etc/init.d/httpd restart
这样重起apache的话,那就修改/etc/init.d/httpd这个文件,修改其中的apahce的三个路径就可以了!!

好了,终于安装完毕,你的机器已经是最新的apache+php+mysql+gd.......了,恭喜!!

艾,累死我了,整整弄了好几天!!休息了!!~(安装的时候,可能安装的时候和写不不是很一样,不过大同小异!)

同时感谢以前那几位辛苦的安装者,参照你们的文章我才得以顺利安装成功,虽然还是用了好几天!~

posted @ 2010-02-03 11:53 小博 阅读(414) | 评论 (0)编辑 收藏

2010年2月2日 #

linux安装时的安装语句

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/lib --enable-track-vars --with-xml --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config

http://rental.zhupiter.com/postshow_305_1_1.html

http://p.imxy.net/187


posted @ 2010-02-02 18:04 小博 阅读(247) | 评论 (0)编辑 收藏

Installing Apache 2 httpd with ssl and PHP support

Installing Apache 2 httpd with ssl and PHP support

Compiling Apache used to be easy. Over the years it has gotten more and more complex, and the latest versions can be a nightmare even for experienced administrators to compile. Each version of Apache also puts its config files and log files in a different place. Many people have trouble configuring the "prefork" version that is installed by SuSE, because instead of one config file, the prefork version (at least the one supplied by SuSE) has 13 of them. Since apache needs to be updated and reinstalled frequently, most users are better off compiling apache from source from the very beginning. This also helps your users by ensuring that their html files (and your config files) are always in the same place.

PHP5 is recommended over PHP4 because it is much easier to install. It is recommended to compile php as a shared library instead of hard-coding it into apache. The old ".o" and "mod_php4.c" files will be replaced by a single php library. This page will also concentrate exclusively on apache 2.x.

STEP 1: Install SSL

Install new openssl from www.openssl.org (openssl-0.9.6g.tar.gz)

Openssl installs everything in /usr/local/ssl/lib, while SuSE installs it in /usr/lib/. Be sure to copy the new version to /usr/lib or specify "--prefix=/usr/lib" during the config step.
    ./config
make
make test
make install
./config shared
make
make install
cd /usr/local/ssl/lib
cp * /usr/lib
lcdonfig
If it gives the following error:
    BEGIN failed--compilation aborted at /usr/lib/perl5/5.00503\
/Pod/Usage.pm line 412.
copy the files manually
    cp libcry* /usr/lib/ 
cp libssl* /usr/lib/
cp libcry* /usr/local/ssl/lib
cp libssl* /usr/local/ssl/lib
Restart Samba and Apache, otherwise Samba, apache, and possibly other applications will crash silently.

STEP 2: Unpack Apache

PHP places files in the Apache source tree that are necessary to create a version of Apache that supports PHP. Untar Apache and type './configure'. Do not skip this step. Then install PHP before continuing.

STEP 3: Install PHP

Use the latest versions of Apache and PHP to avoid incompatibilities, compilation problems, and potential security problems. If you use modules in apache, it may be necessary to reinstall them as well.

PHP can be configured with apxs or using command-line options. In this document we will use apxs. If you use apxs, make sure the correct apxs (/usr/sbin/apxs, /usr/sbin/apxs2, /usr/local/apache/bin/apxs, or /usr/local/apache2/bin/apxs) is being used by specifying something like "--with-apxs=/usr/sbin/apxs". If you specify the wrong apxs, it will say something like:
  configure: error: You have enabled Apache 2 support 
while your server is Apache 1.3.
Please use the appropiate switch --with-apxs (without the 2)
Since apxs is part of Apache, if apxs is not present, you must compile and install apache twice--once to create apxs, and once to create a version of apache that works with php. For Apache 2.x you need to use apxs2. Apache creates a version of apxs2, but unfortunately calls it apxs. This is the version needed by php. It's necessary to make it executable and then copy it somewhere in your path (such as /usr/sbin/). See also "./configure --help" and "sapi/apache2filter/README".

  1. Install python and python-devel from original linux CD if python is not present.
  2. Obtain the libxml2 tar file from
      ftp://ftp.gnome.org/mirror/gnome.org/sources/libxml2/2.6/
  3. Compile and install libxml2
      ./configure --enable-ipv6=no
    make
    make install
  4. According to the documentation, libxml2-devel is also needed. However, this turned out not to be true.
  5. If you don't have an apxs already, go back to the apache directory and install apxs by compiling and installing a minimal apache with no arguments as described below in Step 4. Then return to the php directory and type:
     ./configure --with-apxs2=/usr/local/apache2/bin/apxs \
    --with-apache2=/home/tjnelson/apache/httpd-2.0.50 \
    --enable-shared --with-mysql=/usr/bin/mysql
    Substitute the actual location of your apxs. In our situation, we had to use a different command for each of our computers that use php with apache (This section is only of local interest. Please skip to the next section if you are not me.):
    entropy

    cd /usr/local/lib/perl5/site_perl
    cp /usr/lib/perl5/5.8.1/strict.pm .
    cd -
    ./configure --with-apxs2=/usr/local/apache2/bin/apxs \
    --with-apache2=/home/tjnelson/apache/httpd-2.0.50
    make
    edit Makefile to remove install-pear from install_targets
    su
    make install
    libtool --finish /home/tjnelson/php/php-5.2.1/libs
    cd /etc/rc.d
    ./apache2 restart
    test web server to make sure it actually started

    protein

    install libxml2 and libxml2-sources from ftp://xmlsoft.org/
    ./configure --with-apache=/home/tjnelson/apache/httpd-2.0.50

    engram

    ./configure --with-apxs2=/usr/local/apache2/bin/apxs \
    --with-apache2=/home/tjnelson/apache/httpd-2.0.50 \
    --enable-shared --enable-mbstring
    make
    edit Makefile to remove install-pear from install_targets
    su
    make install
    libtool --finish /home/tjnelson/php/php-5.2.1/libs
    cd /etc/rc.d
    ./apache2 restart
    test web server to make sure it actually started
    The mysql option is only needed if you have mysql installed.
    Be sure to specify building shared libraries or you'll end up with useless static libraries.

  6. Next build php, and install it as root. Make sure you have a working httpd.conf before installing php, because it will modify your httpd.conf file.
      make clean
    make
    su
    make install
    make install-modules (optional)
    libtool --finish /home/tjnelson/php/php-5.2.1/libs
    The 'make install' command should say something about libphp5.so, and not libphp5.a. Shared (.so) libraries are needed to interface with apache.

On some computers, php installation hangs during the "make install" command during PEAR installation. If you don't need pear, this problem can be solved by editing the php makefile and removing "install-pear" from the line that starts with "install_targets".

By default it installs php in /usr/local/bin. You need to find and get rid of any old versions of php (e.g., in /usr/bin). If you make a mistake and start compiling with the wrong options, be sure to type "make clean" before running make a second time. Also, don't add too many options to php or it will prevent apache from compiling. (It may even prevent 'configure' from working.)

Next copy php.ini-dist to the appropriate place (normally /etc/php.ini or /usr/local/lib/php.ini) and edit it as necessary to set PHP options. The most common option is to allow uploads. This is essential for applications like squirrelmail. If uploads are not allowed, or the maximum filesize is too small, squirrelmail will allow incoming mail but silently drop outgoing mail with no warning and no messages to any logfile. It can be a royal pain to find this problem.
  ln -s /etc/php.ini /usr/local/lib/php.ini
  file_uploads = On
;upload_tmp_dir =
upload_max_filesize = 200M

STEP 4: Install Apache

Un-mangle the documentation filenames so you can read the documentation:
   cd htdocs/manual
mmv -r "*.html.en" "#1.html"
mmv -r "*.html.html" "#1.html"

  1. Enabling Proxy in Apache: If your server is well protected from the Internet, you can activate the http proxy feature in Apache by adding
    --enable-proxy 
    to the configure command. (note: it used to be called "--enable-module=proxy", but this seems not to work anymore. If in doubt whether the option is enabled, look at config.log). If you use modules, there needs to be a "LoadModule" line in your httpd.conf file. (This is done automatically by the make install script unless it finds a pre-existing httpd.conf file).

    Then make the appropriate changes to your /etc/httpd/httpd.conf file as shown below. If the server is exposed to the Internet, you will eventually get hit with spammers and people trying to access porn. The documentation states that adding the following to your httpd.conf will prevent these attacks:
    <Directory proxy:*>
    Order Deny,Allow
    Deny from all
    Allow from yournetwork.example.com
    </Directory>
    However, in my experience, this doesn't always work. If you want secure proxying, you're better off with a full-featured proxy like squid.

  2. Compile apache
    Run 'configure' and 'make'.
       cd /home/tjnelson/apache/httpd-2.0.50
    ./configure --enable-module=so \
    --with-apxs2=/usr/local/apache2/bin/apxs \
    --enable-ssl --enable-includes --sysconfdir=/etc/httpd \
    --enable-proxy (optional)
    make
    Many other options are available. Unfortunately, they are poorly documented. You can find a few by typing configure --help. The only way I know of to find the rest of them is by reading the configure file.
  3. Check httpd before installing it. This will ensure that the desired modules are included and that it can find its libraries:
       make
    ldd ./src/httpd
    It should say something like
       libpam.so.0 => /lib/libpam.so.0 (0x40028000)
    libcrypt.so.1 => /lib/libcrypt.so.1 (0x40031000)
    libresolv.so.2 => /lib/libresolv.so.2 (0x40064000)
    libm.so.6 => /lib/libm.so.6 (0x40075000)
    libdl.so.2 => /lib/libdl.so.2 (0x40099000)
    libnsl.so.1 => /lib/libnsl.so.1 (0x4009d000)
    libexpat.so.0 => /usr/lib/libexpat.so.0 (0x400b3000)
    libc.so.6 => /lib/libc.so.6 (0x400d5000)
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
    In Apache 2, the httpd in the top directory is just a script, but the commands are similar to Apache 1.x:
       ldd ./.libs/httpd
    libssl.so.0.9.6 => /usr/lib/libssl.so.0.9.6 (0x40029000)
    libcrypto.so.0.9.6 => /usr/lib/libcrypto.so.0.9.6 (0x40057000)
    libaprutil-0.so.0 => /usr/local/apache2/lib/libaprutil-0.so.0 (0x40115000)
    libgdbm.so.2 => /usr/lib/libgdbm.so.2 (0x4012b000)
    libdb-4.0.so => /usr/lib/libdb-4.0.so (0x40133000)
    libexpat.so.0 => /usr/lib/libexpat.so.0 (0x401cb000)
    libapr-0.so.0 => /usr/local/apache2/lib/libapr-0.so.0 (0x401ed000)
    librt.so.1 => /lib/librt.so.1 (0x4020d000)
    libm.so.6 => /lib/libm.so.6 (0x4021f000)
    libcrypt.so.1 => /lib/libcrypt.so.1 (0x40242000)
    libnsl.so.1 => /lib/libnsl.so.1 (0x40276000)
    libdl.so.2 => /lib/libdl.so.2 (0x4028c000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x40290000)
    libc.so.6 => /lib/libc.so.6 (0x402a6000)
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
    ./httpd -l
    Compiled in modules:
    core.c
    mod_access.c
    mod_auth.c
    mod_include.c
    mod_log_config.c
    mod_env.c
    mod_setenvif.c
    mod_proxy.c
    proxy_connect.c
    proxy_ftp.c
    proxy_http.c
    mod_ssl.c
    prefork.c
    http_core.c
    mod_mime.c
    mod_status.c
    mod_autoindex.c
    mod_asis.c
    mod_cgi.c
    mod_negotiation.c
    mod_dir.c
    mod_imap.c
    mod_actions.c
    mod_userdir.c
    mod_alias.c
    mod_so.c
    Notice that mod_php is not listed because it's not compiled into apache.

  4. Install apache and set up configuration file

    Remove /usr/local/apache/conf/, /usr/local/apache2/conf/, and /etc/httpd/ if they exist so Apache creates a new one. It is much easier to edit a working httpd.conf than to modify a non-working one. Note that "--sysconfdir=/etc/httpd" will prevent it from creating a conf file if one already exists in the /etc/httpd directory.
       su
    mv /etc/httpd /etc/httpd.bak
    mv /usr/local/apache/conf /usr/local/apache/conf.bak
    mv /usr/local/apache2/conf /usr/local/apache2/conf.bak
    make install
    Apache 2.0 installs in /usr/local/apache2/bin, /usr/local/apache2/lib, etc.

    Edit httpd.conf:

    • Change the default port from 8080 to 80.
    • Set the correct document root so it points to your Web pages
        DocumentRoot "/usr/local/httpd/htdocs"
      (This must be done in two places)
    • Change the user from nobody to wwwrun
    • Enable proxy if desired
          ProxyRequests On
      <Directory proxy:*>
      Order deny,allow
      Deny from all
      Allow from .brneurosci.org
      </Directory>
      ProxyVia On
    • Add access controls if desired
    • Remove any lines that refer to php3 or php4. These often cause problems.
    • Enable FollowSymlinks in /etc/httpd/httpd.conf or /usr/local/apache/conf/httpd.conf if there are links in the path of any html files. Make sure apache has execute permission in user's home directories if files are located there (i.e., permissions in /home should be 711), or you will get "Forbidden You don't have permission to access x on this server" when a browser tries to follow a symlink.
    • Add the following at the end, if the php installation script didn't already add them:
        LoadModule php5_module        modules/libphp5.so
      # or, for some systems:
      # LoadModule php5_module /usr/local/apache/libexec/libphp5.so

      # This line is necessary to allow inline php statements in your
      # html pages.
      AddType application/x-httpd-php .php .htm .html
      #AddType application/x-httpd-php .php4
      AddType application/x-httpd-php-source .phps
      AddHandler php5-script php
      DirectoryIndex index.html index.php
      AddType text/html php
      AddType application/x-httpd-php-source phps
      The installation script for php5 should add the appropriate php5 lines automatically. However, it doesn't remove the php4 lines if they're present. These should be removed manually, because loading two different versions of php simultaneously is a frequent source of problems and php crashes.
  5. Start apache

    Make a link at /usr/local/apache2/conf/, if it exists, so there's no doubt as to which httpd.conf it will use.
     ln -s /etc/httpd/httpd.conf /usr/local/apache2/conf/httpd.conf
    Stop the currently-running httpd (by typing "/etc/rc.d/apache stop") and start the new one:
     cd /etc/rc.d
    ./apache stop
    /usr/local/apache/bin/apachectl start
    Make sure it's running on port 80 and not 8080:
     netstat -na | grep 80 
    tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
    Make sure the correct version is running:
     ps -aux | grep http
    root 21194 0.0 0.3 3988 1868 ? S Sep18 0:00 /usr/local/apache/bin/httpd
    wwwrun 21197 0.0 0.3 4068 2016 ? S Sep18 0:00 /usr/local/apache/bin/httpd
    Copy the new startup script to /etc/rc.d (or edit the old script)
     cd /etc/rc.d
    mv apache apache.bak
    cp /usr/local/apache2/bin/apachectl /etc/rc.d/apache2

  6. Test apache and php
    1. Test with a browser to see if you can reach "http://localhost" and "http://localhost/manual". Create a file called "test.php" in the htdocs directory containing the line:
       <? phpinfo(); ?>
      It should be:
       -rw-r--r--    1 root     root           17 Sep 18 21:29 test.php
    2. Copy your html files into the htdocs directory and see if you can reach "http://yoursite.com/test.php". It should print a purple PHP page showing the current version of php and current setup, showing today as the build date. This may take a couple of tries -- for example, it may work with "myhost.somewhere.org" but not with "localhost/test.php".
      Now copy your html files to /usr/local/apache/htdocs.
    3. Install the new startup script:
       mv /etc/rc.d/apache /etc/rc.d/apache.bak
      cp /usr/local/apache/bin/apachectl /etc/rc.d/apache
      One annoyance with apache is that if there's a problem in your httpd.conf file, quite often it will simply say
       ./apachectl start: httpd could not be started
      giving you no clue what the problem is.
    4. If you have other servers: lather, rinse, repeat.

Problems

  1. Blank screen

    Users see a blank screen or unprocessed php directives when viewing any php page, including test.php.
    Solution: Check the apache logs (error_log). One possibility is that php is crashing. The first line in the log below shows that PHP is configured correctly. The second line shows that it's crashing.
     Apache/2.0.48 (Unix) mod_ssl/2.0.48 OpenSSL/0.9.7c PHP/4.3.1 
    PHP/5.0.3 configured -- resuming normal operations
    [notice] child pid 2257 exit signal Segmentation fault (11)
    One solution is to recompile and reinstall php. Another reason php may crash is that your httpd.conf file contains references to both php4 and php5. If you try to load both versions, it will crash. It's also important to remove any pre-existing versions of php that may be on your system, e.g.:
     mv /usr/bin/php /usr/bin/php.bak
    ln -s /usr/local/bin/php /usr/bin/php
    to make sure the system is using the correct one.

    Additional troubleshooting steps

    To troubleshoot php, it is necessary to trick it into printing error messages.

    • The easiest way to know whether apache has loaded the php module is to include the "LoadModule" line twice. It should say:
            [warn] module php5_module is already loaded, skipping
    • Click "View page source" to find out whether Apache is interpreting the php. If the php source code is visible, it means Apache is not translating the php. If you get an empty HTML file (<HTML><body></body></html>) it is bad news. The php website does not acknowledge this problem, even though it seems to be very widespread. Typically there are no error messages regardless of the settings in php.ini, and all php pages produce a white blank page and nothing else. The problem is that no error messages are produced, making it quite difficult to diagnose. The blank page problem will sometimes occur on one computer but not another.
    • From the command line, go to the htdocs directory and type
      php test.php

      On a computer in which php is properly set up, this should print several pages of text. On a computer that has the blank screen problem, you will get something like this:
      Fatal error: Call to undefined function phpinfo() in 
      /usr/local/apache2/htdocs/test.php on line 1
      Finally, a real error message. This message means that either the wrong php is being executed, or that php is using an old library somewhere that doesn't have the phpinfo function. You have to find this library and eliminate it.
    • Well, this is as far as I have gotten so far with this bug.
  2. Pages not being rendered in Unicode.
    Be sure to comment out the default charset in httpd.conf; otherwise, pages will appear in 8859-1 (Western) characters even when the user's browser is set to Auto-Detect.
    #AddDefaultCharset ISO-8859-1
  3. Compilation error in apache.
    ssl_engine_pphrase.c: In function 'ssl_pphrase_Handle_CB':
    ssl_engine_pphrase.c:683: error: 'PEM_F_DEF_CALLBACK' undeclared \
    (first use in this function)
    Edit ./modules/ssl/ssl_engine_pphrase.c and change all occurrences of PEM_F_DEF_CALLBACK to PEM_F_PEM_DEF_CALLBACK.
  4. Apache does not start up.
    API module structure `php5_module' in file /usr/lib64/apache2/libphp5.so \
    is garbled - perhaps this is not an Apache module DSO?
    This means you have to compile php and apache2 again, using a different apxs2 script. This script might be called apxs or apxs2. In this case, it happened to be called apxs, but was actually apxs2.
    cd; cd apache/httpd-2.0.50
    find . | grep apxs
    su
    cp ./support/apxs /usr/sbin/apxs
    chmod a+x /usr/sbin/apxs
    exit
    cd; cd php/php-5.2.1
    ./configure --with-apxs2=/usr/sbin/apxs \
    --with-apache2=/home/tjnelson/apache/httpd-2.0.50 \
    --enable-shared
    make clean
    make
    su
    make install
    libtool --finish /home/tjnelson/php/php-5.2.1/libs
    make install (It gives a more informative message the second time.)
    exit

    cd; cd apache/httpd-2.0.50
    ./configure --enable-module=so --with-apxs2=/usr/sbin/apxs \
    --enable-ssl --enable-includes --sysconfdir=/etc/httpd
    make clean
    make
    su
    make install
    exit

    cd; cd php/php-5.2.1
    find . | grep libphp5.so
    cp /usr/lib64/apache2/libphp5.so /usr/lib64/apache2/libphp5.so.bak
    cp ./libs/libphp5.so /usr/lib64/apache2/libphp5.so
    exit

posted @ 2010-02-02 17:02 小博 阅读(853) | 评论 (0)编辑 收藏

linux学习小步走(3)

linux卸载apache php mysql

卸载步骤如下:
卸载Mysql
[root@localhost ~]# rpm -qa|grep mysql
mod_auth_mysql-2.6.1-2.2
php-mysql-4.3.9-3.15

mysql-devel-4.1.20-1.RHEL4.1
mysql-4.1.20-1.RHEL4.1
mysqlclient10-3.23.58-4.RHEL4.1
libdbi-dbd-mysql-0.6.5-10.RHEL4.1

说明:rpm –qa | grep mysql 命令是为了把mysql相关的包都列出来,我上面的例子是Linux AS4默认安装mysql的rpm软件包列表,如果是别的Linux版本列出来的列表有可能会不一样,不过不用担心,不管是什么,卸载都从最下面的一个包开始,直到卸载掉第一个为止。

比如:在这个例子中,我们应该先卸载libdbi-dbd-mysql-0.6.5-10.RHEL4.1 方法如下:rpm –e -dbd-mysql-0.6.5-10.RHEL4.1

说明:rpm –e 是卸载rpm包的命令,后面是包名称,最后的版本号是不用打的,比如我们下一步卸载mysqlclient10-3.23.58-4.RHEL4.1包,方法如下:

rpm –e mysqlclient

卸载Apache
[root@localhost ~]# rpm -qa|grep httpd
httpd-manual-2.0.52-25.ent
system-config-httpd-1.3.1-1
httpd-2.0.52-25.ent
httpd-suexec-2.0.52-25.ent

说明:方法跟卸载Mysql一样,不用说了吧

卸载PHP
[root@localhost ~]# rpm -qa|grep php
php-odbc-4.3.9-3.15
php-4.3.9-3.15
php-mysql-4.3.9-3.15
php-pear-4.3.9-3.15
php-ldap-4.3.9-3.15
php-pgsql-4.3.9-3.15

说明:方法跟卸载Mysql一样,不用说了吧

注意:卸载的时候如果卸载不掉,系统一般会提示包的依赖关系,并且列出依赖的包的名称,先卸载提示依赖的包就可以了。

如果实在实在有卸载不掉的包,可以加—nodeps这个参数来卸载,比如我们卸载php-4.3.9-3.15,实在卸不掉了。

就用:
[root@localhost ~]# rpm -e php-4.3.9-3.15 –nodeps

posted @ 2010-02-02 16:03 小博 阅读(227) | 评论 (0)编辑 收藏

linux学习小步走(2)

安装mysql的时候遇到一点麻烦,刚开始的时候使用的是rpm的安装文件,因为没有下载到server,只是client,所以只好换了源代码的安装包,参照的教程是http://www.bitscn.com/server/app/200607/51537.html 
另外也参照了:
  shell>   groupadd   mysql(不要变这个名字)  
  shell>   useradd   -g   mysql   mysql(不要变这个名字)  
  shell>   tar   zxvf   mysql-VERSION.tar.gz  
  shell>   cd   mysql-VERSION  
  shell>   ./configure   --prefix=/usr/local/mysql   --with-charset=gb2312  
  shell>   make  
  shell>   make   install  
  shell>   scripts/mysql_install_db  
  shell>   chown   -R   root     /usr/local/mysql  
  shell>   chown   -R   mysql   /usr/local/mysql/var  
  shell>   chgrp   -R   mysql   /usr/local/mysql  
  shell>   cp   support-files/my-medium.cnf   /etc/my.cnf  
  shell>   /usr/local/mysql/bin/mysqld_safe   --user=mysql   &  
   
  这样进入:  
  shell>   cd   /use/local/mysql/bin  
  shell>   ./mysql   -u   root   -p(我也不知道问什么要加个./)  
  enter   password:回车就OK了  
   
  开机自动加载MySQL  
   
  /usr/local/mysql/share/mysql/mysql.server复制到/etc/init.d  
  shell>chkconfig   –add   mysql.server使MySQL在开机时自动运行 

中间怎么装mysql都装不上,原来是出了这个错误:
No curses/termcap library found

最后使用这个命令排除:
yum install libcurses-devel
yum install ncurses5-devel

(这两个其中之一)
最后安装:
./configure --prefix=/usr/local/mysq;make;make install

posted @ 2010-02-02 15:04 小博 阅读(229) | 评论 (0)编辑 收藏

linux学习小步走(1)

终于受不了一直当个低等菜鸟了,所以决定系统的学下知识,至少把自己的代码库建起来~
首先第一步是学linux,今天开始装centOs,用虚拟机来的~步骤都比较简单,一路默认就行啦
装上之后,开始装apache~
这时候我找到一个教程http://os.51cto.com/art/200912/168162.htm。

1. 到这里下载apache在Linux/unix下的源码(*.tar.bz2):http://httpd.apache.org/download.cgi

我在自己的用户【lin】下载了apache的2.2.14版。

2. 使用用户root登录系统,打开shell窗口。

这里我出现了两个盲区:

第一,怎么在图形界面打开shell窗口(我是白痴),后来找到答案是:右键在桌面上选择“打开终端”即可。
第二,为什么必须要root用户才能安装呢?搜索到的答案是:
1. apache 一般要 listen 80 port, 這個運作需要特權, 所以得使用 root 身分. 不過後續服務運作 apache daemon 都會切換成為一般身分提供服務運作.

2.
普通用户无法打开1024以下的端口。

3.那为什么使用3306端口的mysql也是root身份?因為只是啟動 mysqld_safe script 是使用 root 身分執行, 所以執行身分當然是 root. 不過一般都配置 mysql daemon 用 mysql 這個一般身分運作, 所以最後服務運作都還是以一般帳號提供服務來運作.

我没有尝试在【lin】用户下安装,不清楚具体的表现为何,我估计再使用上,端口会出现错误吧。


3. 进入源码文件所在的目录,执行 # tar -jxvf apache*.tar.bz2。
这部分我安装正常

4. 进入解压后的目录,执行 # ./configure、# make、# make install 、# make clean、# make distclean 即可完成安装。
【make clean是清除之前编译的可执行文件及配置文件。make distclean要清除所有生成的文件】
安装正常

5. 软件安装的位置是 /usr/local/apache*,配置环境时需要到这里去找相关配置文件。
跑到目录下找,果然看到了。


posted @ 2010-02-02 10:49 小博 阅读(276) | 评论 (0)编辑 收藏

2010年1月8日 #

ORA-12170 TNS 连接超时

1.开始----程序-----oracle------配置和移植工具-----Net Manager----本地----服务命名---ora11(这个是我的专用服务器) 把右边下面的主机名改成192.168.1.102

2.开始----程序-----oracle------配置和移植工具-----Net Manager----本地----监听程序---同样把右边下面的主机名改成192.168.1.102

重新连接又报了另一个错误

ora-12541:TNS:没有监听器
1.cmd---services.msc----以Oracle开头TNListener结尾的服务启动它
2.如果还没有启动,修改注册表cmd--regedit
找到HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\OracleTnsListener
添加一个字符串imagepath值为TNSLSNR.exe的路径
我的是D:\Oracle\Administrator\product\11.1.0\db_1\BIN\TNSLSNR
终于可以连接上了,高兴!


如果在本机可以正常使用,可是到局域网中的其他机器就出现“ORA-12170:TNS:连接超时
解决方法:

1.cmd-----ping ip地址 查看网络问题,看能否ping通

2.cmd-----tnsping   ip地址(或者是服务器的实例名SID)如果报“TNS-12535:操作超时”,可能是服务器端防火墙    没有关闭

3.cmd----netstat -na 查看1521端口是否关闭,如果关闭Windows XP中的防火墙设置中将1521端口设为例外

4.cmd----lsnrctl status   lsnrctl是listener-control 监听器的缩写,查看监听的状态

posted @ 2010-01-08 09:54 小博 阅读(773) | 评论 (0)编辑 收藏

2009年9月17日 #

jquery+ie6的诡异问题 关于submit()

在IE6下submit()没有作用了,其实解决办法很简单,只是不知道最后根源如何:

在ie6下
<a href="javascript:;" id="aid"> href</a>

同时jquery bind 了 其click事件
$("#aid").bind('click',function(){
    .....
    form.submit();       
    //no return;   
});

在这种情况下,点击 href会执行 click绑定的方法,但是 form.submit(),不会有任何反应。

后来在 添加 return false 后能正常运行......;



以上为这个诡异问题的解决文章,感谢作者。原文

posted @ 2009-09-17 15:10 小博 阅读(1649) | 评论 (0)编辑 收藏

2009年7月25日 #

在一家生活资讯网站的PHP笔试受到打击,讲一下题目吧

以往见到过多装B的面试官,都不如今天的这位有派——笔试完了直接托前台告知请回,这算是我经历过的最丢人的一次面试吧。
虽然心里五味杂陈,总算是服气这次笔试的题目,确实是自己功力有限。当即在大雨里跺脚指天,想要抓一把素质,那么先把代表性的题目在这里记录一下:

1.你是网站的负责人,有一天发现网站突然出现了很多不良的访问来源,这将会对网站有不利的影响,这时,需要你设计一套拦截、屏蔽系统来处理这个问题。请设计出此套系统的基本结构图、流程图。

2.用PHP或者python,或者其他你熟悉的语言,写一个定时任务,要求每5分钟抓取一次某网站(例如:http://www.baidu.com,http://www.kuxun.com),要求当获取内容中url不同时,生成新的文件。

3.有一天突然你接到一个朋友的短信,说网站中订票功能用不了了,你会怎么解决,请详细写出解决办法。

4.请推理出现在域名为.cn的每天访问量为10人次/天的网站数量。

5.例如:(这是我上京东复制的)
Host www.360buy.com
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11
Accept */*
Accept-Language zh-cn,zh;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset gb2312,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive
X-Requested-With XMLHttpRequest
Referer http://www.360buy.com/
Cookie __utma=97936925.1908988227742847700.1248432869.1248432869.1248432869.1; __utmz=97936925.1248432869.1
.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); 360buy.com_prodlook=162988

a:如果没有host,网站能正常访问吗?
b:Accept-Encoding gzip,deflate代表什么,什么时候可以使用?

大概写对了,请教同事后再来写答案。

有同仁会给我回复吗?

posted @ 2009-07-25 02:47 小博 阅读(1622) | 评论 (1)编辑 收藏

仅列出标题  下一页