上班前两天-编译环境

上班第一天,鸟哥让我编译环境,说实话这个还真不会,以前虽然折腾过VPS或虚拟机,但从来不曾下足勇气去编译。。。一直都是yum或apt-get的选手。。。因为组中大家共用一个开发机,所以每个人分了个帐号,没有root权限。。。

A. 先编译apache吧

./configure –prefix=/home/guweigang/local/httpd …
配置选项在这里(中文):http://apache.jz123.cn/programs/configure.html#configurationoptions
(英文):http://httpd.apache.org/docs/2.2/zh-cn/programs/configure.html

在配置rewrite的时候,发现apache没有mod_rewrite,可能是当初编译apache的时候没有带上 –enable-rewrite选项。

重新编译mod_rewrite.so:
在apache的源码安装目录中寻找mod_rewrite.c文件
find / -name mod_rewrite.c
/home/springshine/LAMP/httpd-2.2.3/modules/mappers/mod_rewrite.c

编译:
cd /home/springshine/LAMP/httpd-2.2.3/modules/mappers/
/usr/local/apache2/bin/apxs -c mod_rewrite.c
/usr/local/apache2/bin/apxs -i -a -n mod_rewrite mod_rewrite.la
如果没出错,在/usr/local/apache2/modules/ 中就会有mod_rewrite.so了

B. MySQL

C. PHP
1.获取源码
2.解压
tar -jxvf php-5.x.x.tar.bz2
cd php-5.x.x
3.配置编译选项
./configure –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql=/path/to/mysql –with-xml –with-dom –with-openssl –enable-ftp
其中–with-apxs2=/usr/local/apache2/bin/apxs 选项和作用是:在安装里会修改APACHE配置文件,加入PHP模块,同时交将模块复制到apache的模块目录下。
4.编译并安装
make && make insatll
5.测试
1).查看/usr/local/apache2/conf/httpd.conf中是否存在并且启用下面的行
LoadModule php5_moudle moudles/libphp5.so
2).在配置文件添加下面的行,使以php为扩展名的文件会使用PHP程序来解析
AddType application/x-httpd-php .php
注:在.php前必须有空格
3).在/usr/local/apache2/htdocs下,创建一个测试文件index.php,内容如下
phpinfo();
?>
4).检测并启动服务
/usr/local/apache2/bin/httpd -S
/usr/local/apache2/bin/httpd -k start
5).测试
在浏览器中输入http://10.1.1.199/index.php
如果成功返回php的相关信息,说明安装成功.

原来编译php的时候,没有把pdo_ mysql 相关的参数带上,安装完后才发现。再重新编译有点费时间,所以决定单独来安装。

$cd $HOME/php-5.x.x/ext/pdo_mysql
$ ~/local/php/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
$ ./configure –with-php-config=PATH –with-pdo-mysq=DIR
$ make && make install

D. SVN
最新的SVN源代码包依赖sqlite和neon。。。
分别到其官网下载源代码,解压并并分别重命名文件夹为:sqlite-amalgamation和neon
然后编译安装,即可。

E. 最后在配置emacs的时候,怎么样都无法显示中文,我靠,设置语言环境也不行,最后在网上找到一个简单的方法,在~/bashrc中加入以下环境变量:
LC_CTYPE=zh_CN.UTF-8

OK,全部搞定,你也可以在直接输入$ LC_CTYPE=zh_CN.UTF-8 emacs启动emacs。

个人用户的环境配置文件是~/.bashrc,全局的环境配置文件是在./etc/profile

配置Apache+fcgid_module

请先看VC9,VC6,Thread Safe,Non Thread Safe的意思?。 PHP有两种执行方式:ISAPI 和 FastCGI。

ISAPI 执行方式是以 DLL 动态库的形式使用,可以在被用户请求后执行,在处理完一个用户请求后不会马上消失,所以需要进行线程安全检查,这样来提高程序的执行效率,所以如果是以 ISAPI 来执行 PHP,建议选择 Thread Safe 版本;

而 FastCGI 执行方式是以单一线程来执行操作,所以不需要进行线程的安全检查,除去线程安全检查的防护反而可以提高执行效率,所以,如果是以 FastCGI 来执行 PHP,建议选择 Non Thread Safe 版本。

FastCGI 又有fastcgi和fcgid两个模块,推荐使用fcgid,在apache项目的页面上有单独的链接页面。配置信息如下:

LoadModule fcgid_module modules/mod_fcgid.so

<IfModule fcgid_module>
   FcgidInitialEnv PHPRC "c:/php/"
   FcgidInitialEnv PATH "C:/php;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;"
   FcgidInitialEnv SystemRoot "C:/Windows"
   FcgidInitialEnv SystemDrive "C:"
   FcgidInitialEnv TEMP "C:/WINDOWS/TEMP"
   FcgidInitialEnv TMP "C:/WINDOWS/TEMP"
   FcgidInitialEnv windir "C:/WINDOWS"

   FcgidIOTimeout 40
   FcgidConnectTimeout 10
   FcgidMaxProcesses 1000
   FcgidOutputBufferSize 64
   FcgidProcessLifeTime 120
   FcgidMaxRequestsPerProcess 10000
   FcgidMinProcessesPerClass 0
   FcgidFixPathinfo 1

# Global Config Example
  <Files ~ "\.php$">

    Options Indexes FollowSymLinks ExecCGI
    AddHandler fcgid-script .php
    FcgidWrapper "c:/php/php-cgi.exe" .php
  </Files>
</IfModule>

现在官方都不推荐使用VC6版本了,也不会提供VC6的源码,所以大家都迁移到PHP VC9。这里推荐几个网站,分别提供了Apache VC9, Apache X64, PHP X64。

How to remove www from your URL with mod_rewrite

source link: http://yoast.com/how-to-remove-www-from-your-url-with-mod_rewrite/
I got a hit today for the following search query: how do you get rid of the www in url .

Here’s the code to 301 redirect the www version of your site to the non-www version using Apache’s mod_rewrite:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

Adding the www instead of removing it

And, as requested in the comments, the code to add www to your domain name:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) http://www.example.com$1 [R=301]

博客从域名godpress.cn转到roygu.com域名

博客转来好几天了,但是一直懒于做域名301重定向。为了保留以前的读者,一般情况下,网站换域名后要做相关的SEO处理,最通常的就是把原来网站相应的URL全部转到新网站相应的URL上。 示例:你可以访问http://godpress.cn/?p=328,它会自动重定向到http://roygu.com/?p=328。不多说了,下面直接贴代码:


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^godpress.cn$ [OR]
rewritecond %{http_host} ^www.godpress.cn [nc]
rewriterule ^(.*)$ http://roygu.com/$1 [L,R=301]