分类: BSD
2006-06-23 10:38:20
OpenBSD全能服务器安装手册之基本服务器篇--Apache+php4
1. 配置APACHE服务器:
因为APACHE是系统默认安装的,这里就省去了安装过程,下面配置APACHE这样就可以开机运行HTTP了因为在/ETC/RC脚本中已经有了HTTPD服务的启动设置
# vi /etc/rc.conf
改:
httpd_flags=NO
为:
httpd_flags=""
对apache做一初步设置
# vi /var/www/conf/httpd.conf
ExtendedStatus On
ServerAdmin llzqq@126.com
ServerName llzqq.3322.org
ServerTokens Prod
ServerSignature Off
Options Indexes FollowSymLinks 改为 Options FollowSymLinks
3. 安装配置PHP-4.4.1
# pkg_add -v php4-core-4.4.1p0.tgz
运行下面的命令使其生效
# cp /usr/local/share/examples/php4/php.ini-recommended /var/www/conf/php.ini
# /usr/local/sbin/phpxs -s
由于OPENBSD上的APACHE采用了CHROOT机制,要保证PHP正常工作就要建下面的目录PHP工作目录:
# mkdir /var/www/tmp
# chmod 1777 /var/www/tmp
下面选择安装几个PHP组件:
pkg_add -v php4-extensions-4.4.1p0.tgz
# pkg_add -v php4-gd-4.4.1p0-no_x11.tgz
# /usr/local/sbin/phpxs -a gd
# pkg_add -v php4-mysql-4.4.1p0.tgz
# /usr/local/sbin/phpxs -a mysql
# pkg_add -v php4-ncurses-4.4.1p0.tgz
# /usr/local/sbin/phpxs -a ncurses
# pkg_add -v php4-imap-4.4.1p0.tgz
# /usr/local/sbin/phpxs -a imap
# pkg_add -v php4-curl-4.4.1p0.tgz
# /usr/local/sbin/phpxs -a curl
# pkg_add -v php4-dbx-4.4.1p0.tgz
# /usr/local/sbin/phpxs -a dbx
# pkg_add -v php4-ldap-4.4.1p0.tgz
# /usr/local/sbin/phpxs -a ldap
# pkg_add -v php4-pdf-4.4.1p0.tgz
# /usr/local/sbin/phpxs -a pdf
# pkg_add -v php4-snmp-4.4.1p0.tgz
# /usr/local/sbin/phpxs -a snmp
设置apache支持PHP:
# vi /var/www/conf/httpd.conf
DirectoryIndex index.html index.php
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
# vi /var/www/conf/php.ini
doc_root= "/htdocs"
register_globals = On
建立测试php页面
# vi /var/www/htdocs/test.php
测试一下:
# pkill httpd
# /usr/sbin/httpd
在浏览器中输入实验一下
4. 安装mod_limitipconn模块来限制单IP的并发连接数
# wget
# tar xzf mod_limitipconn-0.04.tar.gz
# cd mod_limitipconn-0.04
# vi Makefile
APXS = /usr/sbin/apxs
# make
# make install
让APACHE支持这个模块:
# vi /var/www/conf/httpd.conf
MaxConnPerIP 5
到次整个安装过程结束。
附件部分:
我们为让APACHE支持SSL传输配置APACHE:
# vi /var/www/conf/httpd.conf
添加下面两行:
SSLCertificateFile /etc/ssl/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key
为了使APACHE启动时启用SSL,设置一下APACHE启动选项:
# vi /etc/rc.conf.local
改:
httpd_flags="" # or it could have httpd_flags=NO
为:
httpd_flags="-DSSL # or it could have httpd_flags=NO
手动启动和关闭APACHE这样做就可以了:
# apachectl startssl
# apachectl stop
下面是设置APACHE+SSL的过程:
1. 创建服务器KEY文件 (1024 bit) :
# /usr/sbin/openssl genrsa -out /etc/ssl/private/server.key 1024
2. 创建服务器CSR文件(certificate signing request)
# /usr/sbin/openssl req -new -key /etc/ssl/private/server.key -out /etc/ssl/private/server.csr
这里自己填写一些注册信息
3. 生成签名证书(365天有效证书):
# /usr/sbin/openssl x509 -req -days 365 -in /etc/ssl/private/server.csr -signkey /etc/ssl/private/server.key -out /etc/ssl/server.crt
4. 虚拟主机部分:
NameVirtualHost 192.168.10.1:*
ServerAdmin llzqq@126.com
DocumentRoot /var/www/llzqq
ServerName llzqq.home.com
ErrorLog logs/llzqq.home.com-error_log
CustomLog logs/llzqq.home.com-access_log common
SSLEngine on
SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP
SSLCertificateFile /etc/ssl/virtualsite.com.crt
SSLCertificateKeyFile /etc/ssl/private/server.key
ServerAdmin llzgg@126.com
DocumentRoot /var/www/llzgg
ServerName llzgg.home.com
ErrorLog logs/llzgg.home.com-error_log
CustomLog logs/llzgg.home.com-access_log common