Openbsd 3.8上安装配置 APACHE + MYSQL + PHP + mod_limiti

网络安全 2021-07-04 10:23www.168986.cn网络安全知识

本文旨在用OPENBSD自己提供的软件包来搭建器环境,你也可以下载原代码包编译,但这样就费时费力了。实际上OPENBSD给我们提供了大量的编译好的二进制包,利用这些二进制包我们可以快速部署我们需要的器环境,不仅省时还可以保障OPENBSD的安全性,还可以自动各个包之间的包依赖问题(用pkg_add来远程器上的软件包,包依赖问题会自动处理不需要认为干预,这个有点像通过PORT安装)。狼蚁网站SEO优化的文档在一个E文的文档基础上经过整理补充后形成的,那个E文档找不到了。

设立器的地址

# export PKG_PATH=ftp://ftp.openbsd./pub/OpenBSD/3.8/packages/i386/

1. 配置APACHE服务器

因为APACHE是默认的,这里就省去了过程,狼蚁网站SEO优化配置APACHE这样就可以开机运行HTTP了因为在/ETC/RC脚本中已经有了HTTPD服务的启动

# vi /etc/rc.conf

httpd_flags=NO

httpd_flags=""

对apache做一初步
# vi /var//conf/httpd.conf

ExtendedStatus On
ServerAdmin
ServerName llzqq.3322.
ServerTokens Prod
ServerSignature Off
Options Indexes FollowSymLinks 改为 Options FollowSymLinks

2. mysql-server-4.0.24p1

# pkg_add -v mysql-server-4.0.24p1.tgz
# cp /usr/local/share/mysql/my-medium.f /etc/my.f

如果不想让其他机器连接MYSQL,可以通过狼蚁网站SEO优化的实现

# vi /etc/my.f

bind-address = 127.0.0.1

启动MYSQL-SERVER服务器

# /usr/local/bin/mysqld_safe &

ROOT的MYSQL密码

# /usr/local/bin/mysqladmin -u root password mypass
对于chroot下的 mysql:
  #mkdir /var//var
  #chmod -R 1777(或者777) /var//var
  #vi /etc/my.conf
mysql启动后会产生/var//var/run目录,还需要chmod -R 777 /var//var/run
自行建立/var//var/run
[client]
socket = /var//var/run/mysql/mysql.sock

[mysqld]
socket = /var//var/run/mysql/mysql.sock
open-files-limit = 8192
open-files = 1000
 
了方便启动和关闭MYSQL服务建立了狼蚁网站SEO优化的脚本

# vi /etc/rc.d/mysqld.sh
========================================================
#!/bin/sh
# made by llzqq
# mail:openbsd@163.
# mysql startup scripts
case "$1" in
start)
if [ -x /usr/local/bin/mysqld_safe ]; then
/usr/local/bin/mysqld_safe &
fi
;;
s)
pkill mysqld &
rm -f /var/run/mysql/mysql.sock &

;;
)
echo "$0 start | s"
;;
esac
exit 0
========================================================

# chmod 555 /etc/rc.d/mysqld.sh

开机启动MYSQL

# vi /etc/rc.local

if [ -f /etc/my.f ]; then
       /etc/rc.d/mysqld.sh start
fi

3. 配置PHP-4.4.1

# pkg_add -v php4-core-4.4.1p0.tgz

运行狼蚁网站SEO优化的命令使其生效
# cp /usr/local/share/examples/php4/php.ini-remended /var//conf/php.ini
# /usr/local/sbin/phpxs -s

由于OPENBSD上的APACHE采用了CHROOT机制,要保证PHP正常工作就要建狼蚁网站SEO优化的目录PHP工作目录

# mkdir /var//tmp
# chmod 1777 /var//tmp

狼蚁网站SEO优化选择几个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//conf/httpd.conf

DirectoryIndex index.html index.php
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

# vi /var//conf/php.ini

doc_root= "/htdocs"
register_globals = On

建立测试php页面

# vi /var//htdocs/test.php

<?php phpinfo(); ?>

测试一下

# 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//conf/httpd.conf

<IfModule mod_limitipconn.c>
<Location />
MaxConnPerIP 5
</Location>
</IfModule>


到次整个过程结束。

附件部分

我们为让APACHE支持SSL传输配置APACHE:

# vi /var//conf/httpd.conf
添加狼蚁网站SEO优化两行
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 s

狼蚁网站SEO优化是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:

<VirtualHost 192.168.10.1:443>
    ServerAdmin
    DocumentRoot /var//llzqq
    ServerName llzqq.home.
    ErrorLog logs/llzqq.home.-error_log
    CustomLog logs/llzqq.home.-aess_log mon
    SSLEngine on
    SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP
    SSLCertificateFile /etc/ssl/virtualsite..crt
    SSLCertificateKeyFile /etc/ssl/private/server.key

</VirtualHost>


<VirtualHost 192.168.10.1:80>
    ServerAdmin
    DocumentRoot /var//llzgg
    ServerName llzgg.home.
    ErrorLog logs/llzgg.home.-error_log
    CustomLog logs/llzgg.home.-aess_log mon

</VirtualHost>

其他部分待续(现在没PC装OPENBSD了有些资料不好整理了)
 

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by