Linux上甩开Apache安装SVN

最近捣腾了一个美国vps,把博客之类的都移民到国外去,由于平时常要在家里和公司来回切换,所以顺便用作平时同步的服务器。

虽然Google这个大好人提供了免费的SVN服务器,但是,他是全公开的,我个人除了代码外,可能还要同步些敏感信息。又想过付费买些SVN或GIT的服务,不靠谱的不敢买,靠谱的价格又贵,还不如自己买个VPS,放心多了,话不多说,开工。

这台VPS买了的时候是提供商给我装的干净的CentOS5.4,不过它太干净了,很多软件开发包都没有装上,杯具,但是本着“缺啥补啥”的原则,其实也不麻烦。

VPS上的WEB Server是nginx,简单,配置文件简洁,但功能很强大,所以我一直摒弃庞大笨重的Apache,既然不用Apache,自然也不想为了装SVN而去装个Apache,下面讲讲我装的过程,留个备份。

先下载最新的SVN源码包并解压:http://subversion.apache.org/

$bash# wget http://subversion.tigris.org/downloads/subversion-1.6.9.tar.gz
$bash# tar xzvf subversion-1.6.9.tar.gz
$bash# cd subversion-1.6.9

配置并检测编译环境:

$bash# ./configure --prefix=/usr/local/svn --with-ssl
configure: Configuring Subversion 1.6.9
configure: creating config.nice
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
...
checking for APR... no
configure: WARNING: APR not found
The Apache Portable Runtime (APR) library cannot be found.
Please install APR on this system and supply the appropriate
--with-apr option to 'configure'

or

get it with SVN and put it in a subdirectory of this source
...
Whichever of the above you do, you probably need to do
something similar for apr-util, either providing both
--with-apr and --with-apr-util to 'configure', or
getting both from SVN with:
...

一大堆checking之后,configure中断,提示无法找到APR和APR-util,原来SVN需要Apache的两个。其实我也不知道APR和APR-util是啥,于是网上Google之,翻来翻去找到了这个http://svn.haxx.se/dev/archive-2010-01/0545.shtml,一个名叫subversion-deps的东西,包含了离开apache安装SVN所依赖的东西,就在原来下载SVN源码的下方。这下好了,下到服务器,放在和svn源码同一级目录下,解压,然后再次执行configure,又报以下错误:

configure: checking sqlite library
amalgamation not found at /usr/local/src/subversion-1.6.9/sqlite-amalgamation/sqlite3.c
checking sqlite3.h usability... no
checking sqlite3.h presence... no
checking for sqlite3.h... no
checking sqlite library version (via pkg-config)... no

An appropriate version of sqlite could not be found.  We recommmend
3.6.13, but require at least 3.4.0.
Please either install a newer sqlite on this system

提示所需要的SQLite版本过低,前往它给出的URL下载并直接configure&&make&&make install,继续回到svn源码目录,configure之,期待着万事大吉。

configure: creating ./config.status
config.status: creating Makefile
config.status: creating sqlite3.pc
config.status: creating config.h
config.status: executing libtool commands

OK,检测完成,可以开始编译了,运行make命令;

tclsh ./tool/mksqlite3h.tcl . >sqlite3.h
/bin/sh: tclsh: command not found
make: *** [sqlite3.h] Error 127

编译终止,貌似缺少tcl,好嘛,继续本着“缺啥补啥”的原则,yum install tcl,再make,make install,一路下来终于没有报错了,这下可万事大吉了,首先得感谢国家让我接受长达9年得有偿义务教育,才能让我能看得到这么多单词。

还是记一下Nginx+MySQL+PHP搭建笔记

一、先装MySQL

$ tar xzvf mysql*.tar.gz
$ cd mysql*
$ ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile
$ make
$ make install
$ useradd mysql
$ chmod +w /usr/local/mysql
$ chown -R mysql:mysql /usr/local/mysql/
$ /usr/local/mysql/bin/mysql_install_db --user=mysql
$ cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
$ ln -s /etc/init.d/mysqld /etc/rc2.d/Kmysqld
$ ln -s /etc/init.d/mysqld /etc/rc2.d/Smysqld
$ /etc/init.d/mysqld start

MySQL安装结束…

二、安装PHP5.28+PHP-FPM+eAccelebrater

安装依赖
1:安装zlib2

./configure --prefix=/usr/local/zlib

2:安装PNG

cp scripts/makefile.linux ./makefile
./configure --prefix=/usr/local/libpng

3:安装ttf

./configure --prefix=/usr/local/freetype

4:安装JPEG6

mkdir -pv /usr/local/libjpeg/{,bin,lib,include,man/man1,man1}
./configure --prefix=/usr/local/libjpeg --enable-shared --enable-static

5:安装 libxml2

./configure --prefix=/usr/local/libxml2
make;make install
cp xml2-config /usr/bin

6:安装 libmcrypt-2.5.7.tar.gz

./configure;make;make install

7:安装Fontconfig

export PKG_CONFIG_PATH=/usr/local/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH
./configure --prefix=/usr/local/fontconfig --with-freetype-config=/usr/local/freetype/bin/freetype-config

8:安装GD库

./configure --prefix=/usr/local/libgd --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype  --with-jpeg=/usr/local/libjpeg --with-fontconfig=/usr/local/fontconfig

为PHP打上fpm补丁并编译安装:

$ bzip2 -cd php-5.2.8.tar.bz2 | tar xf -
$ gzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1
$ cd php-5.2.8 && ./configure --prefix=/usr/local/php5 --enable-force-cgi-redirect --enable-fastcgi --with-gd --enable-trace-vars --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-gd-native-ttf --with-ttf --enable-gd-jis-conv --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/libjpeg --with-png-dir=/usr/local/libpng --with-libxml-dir=/usr/local/libxml2 --with-zlib-dir=/usr/local/zlib --enable-xml --enable-mbstring --enable-sockets --enable-fpm
$ make all install
$ cp php.ini-dist /usr/local/php5

php-fpm 启动
/usr/local/php5/sbin/php-fpm start
php-fpm 重启
/usr/local/php5/sbin/php-fpm restart

安装eAccelebrater:

$ tar xzvf eAccelebrater*.tar.gz
$ /usr/local/php5/bin/phpize
$ ./configure --with-php-config=/usr/local/php5/bin/php-config
$ make
$ make install

修改php.ini,修改extension_dir = extension_dir = “/usr/local/php5/lib/php5/extensions/no-debug-non-zts-20060613/”

添加:

extension=eaccelerator.so
extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.log_file = "/var/log/httpd/eaccelerator_log"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

保存退出,重启PHP。

mkdir /var/log/httpd/;mkdir /tmp/eaccelerator

三、安装Nginx

先安装pcre
然后

./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_perl_module

nginx重启脚本

chown -R nobody:nobody /var/www
kill -HUP `cat /usr/local/nginx/logs/nginx.pid`

—-本人懒性大发 以下跳跃着说—

nginx配置

user  nobody;
worker_processes  10;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;
events {
worker_connections  1024;
}
http {
include       mime.types;
default_type  application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  15;

tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;

gzip  on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;

server {
listen       80;
server_name  www.yuing.cn;

#charset koi8-r;

access_log  logs/access.www.yuing.cn.log  main;
error_log  logs/error.www.yuing.cn.log error;

location / {
root   /var/www/www.yuing.cn;

index  index.php index.html index.htm;
include php_fcgi.conf;
}

#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   html;
}

error_page   404  /404.html;
location = /404.html {
root   html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
#    root           html;
#    fastcgi_pass   127.0.0.1:9000;
#    fastcgi_index  index.php;
#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
#    include        fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#    deny  all;
#}

location ~ /stats{
stub_status             on;
access_log              on;
auth_basic              "NginxStatus";
#auth_basic_user_file  conf/htpasswd;
}
}

#main

server {
listen       80;
server_name  imethan.com;

access_log  logs/access.imethan.com.log  main;
error_log  logs/error.imethan.com.log error;

location / {
root   /var/www/imethan.com;
index  index.php index.html index.htm;
include php_fcgi.conf;
}

error_page   404  /404.html;
location = /404.html {
root   html;
}
}

error_page   404  /404.html;
location = /404.html {
root   html;
}
}

}