了方便启动和关闭MYSQL服务建立了下面的脚本:
# vi /etc/rc.d/mysqld.sh
========================================================
#!/bin/sh
# made by llzqq
# mail:openbsd@163.com
# mysql startup scripts
case "$1" in
start)
if [ -x /usr/local/bin/mysqld_safe ]; then
/usr/local/bin/mysqld_safe &
fi
;;
stop)
pkill mysqld &
rm -f /var/run/mysql/mysql.sock &
;;
*)
echo "$0 start | stop"
;;
esac
exit 0
========================================================
# chmod 555 /etc/rc.d/mysqld.sh
设置开机启动MYSQL
# vi /etc/rc.local
if [ -f /etc/my.cnf ]; then
/etc/rc.d/mysqld.sh start
fi
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-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
<?php phpinfo(); ?>
测试一下:
# pkill httpd
# /usr/sbin/httpd
在浏览器中输入https://IP/test.php实验一下
4. 安装mod_limitipconn模块来限制单IP的并发连接数
# wget https://dominia.org/djao/limit/mod_limitipconn-0.04.tar.gz
# 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
<IfModule mod_limitipconn.c>
<Location />
MaxConnPerIP 5
</Location>
</IfModule>
到次整个安装过程结束。
附件部分:
我们为让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