Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2471010
  • 博文数量: 867
  • 博客积分: 10010
  • 博客等级: 上将
  • 技术积分: 9800
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-27 14:44
文章分类

全部博文(867)

文章存档

2007年(6)

2006年(861)

我的朋友

分类:

2006-07-30 22:02:41

Apache+PHP+SSL 安装步骤

准备工作:

完成该种配置,需要如下软件包:

httpd-2.0.55.tar.bz2 php-5.0.4.tar.bz2

openssl-0.9.7g.tar.gz

第一步:安装Openssl

tar xvfz openssl-0.9.7g.tar.gz

cd openssl-0.9.7g

./config

make

make install

第二步:安装Apache

tar xvfz httpd-2.0.55.tar.gz

cd httpd-2.0.55

./configure --enable-ssl --with-ssl=/usr/local/ssl/

--enable-suexec --with-suexec-docroot=/usr/local

--enable-cgi --enable-rewrite --enable-so

--enable-logio --prefix=/usr/local/apache

--enable-module=most

--enable-shared=max --bindir=/usr/bin

--sbindir=/usr/sbin --sysconfdir=/etc/httpd

make

make install

生成加密证书:

mkdir /etc/httpd/ssl.crt

openssl genrsa -des3 -passout pass:asecretpassword

-out /etc/httpd/ssl.crt/server.key.org 1024

openssl req -new -passin pass:asecretpassword -passout

pass:asecretpassword -key

/etc/httpd/ssl.crt/server.key.org -out

/etc/httpd/ssl.crt/server.csr -days 3650

openssl req -x509 -passin pass:asecretpassword

-passout pass:asecretpassword -key

/etc/httpd/ssl.crt/server.key.org -in

/etc/httpd/ssl.crt/server.csr -out

/etc/httpd/ssl.crt/server.crt -days 3650

openssl rsa -passin pass:asecretpassword -in

/etc/httpd/ssl.crt/server.key.org -out

/etc/httpd/ssl.crt/server.key

mkdir /etc/httpd/ssl.key

mv /etc/httpd/ssl.crt/server.key

/etc/httpd/ssl.key/server.key

chmod 400 /etc/httpd/ssl.key/server.key

第三步:安装PHP

tar jxvf php-5.0.4.tar.bz2

./configure --with-apxs2=/usr/sbin/apxs

--with-mysql=/var/lib/mysql --enable-track-vars

--enable-sockets

--with-config-file-path=/etc --enable-ftp --with-zlib

--with-openssl=/usr/local/ssl

--enable-force-cgi-redirect

--enable-exif --with-gd --enable-memory-limit

--disable-debug --disable-rpath --disable-static

--with-pic

--with-layout=GNU --enable-calendar --enable-sysvsem

--enable-sysvshm --enable-s
ysvmsg --enable-trans-sid

--enable-bcmath --with-bz2 --enable-ctype --with-db4

--with-iconv --enable-filepro --with-gettext

--enable-mbstring --enable-shmop --enable-wddx

--disable-xml --with-xmlrpc --enable-yp --with-zlib

--without-pgsql --enable-dbx --enable-experimental-zts

--without-mm --enable-gd-native-ttf --with-imap-ssl

--enable-soap --enable-dbase

make

make install

cp /tmp/php-5.0.4/php.ini-dist /etc/php.ini

第四步:配置Apache

/etc/httpd/httpd.conf 中添加如下语句:

AddHandler cgi-script .cgi

AddHandler cgi-script .pl

AddType text/html .shtml

AddOutputFilter INCLUDES .shtml

AddType application/x-httpd-php .php .php5 .php4 .php3

建立/etc/init.d/httpd 文件:

#!/bin/sh

case "$1" in

start)

/usr/sbin/apachectl startssl

;;

stop)

/usr/sbin/apachectl stop

;;

restart)

$0 stop && sleep 3

$0 start

;;

reload)

$0 stop

$0 start

;;

*)

echo "Usage: $0 {start|stop|restart|reload}"

exit 1

esac

chmod 755 /etc/init.d/httpd

如果希望每次系统重新启动时都能自动运行,则:

ln -s /etc/init.d/httpd /etc/rc2.d/S20httpd

ln -s /etc/init.d/httpd /etc/rc3.d/S20httpd

ln -s /etc/init.d/httpd /etc/rc4.d/S20httpd

ln -s /etc/init.d/httpd /etc/rc5.d/S20httpd

ln -s /etc/init.d/httpd /etc/rc0.d/K20httpd

ln -s /etc/init.d/httpd /etc/rc1.d/K20httpd

ln -s /etc/init.d/httpd /etc/rc6.d/K20httpd

Apache:服务配制

1。首先服务的主配置文件在:

#vi /etc/httpd/httpd.conf

ServerRoot "/etc/httpd"

//这个文件定义了Apache的配置文件,日志文件,错误记录文件的记录.httpdApache启动的时候到httpd文件下寻找配置文件.

PidFile run/httpd.pid //Apache请求的数量记录文件也是它的pid

Timeout 300 //控制客户端连接超时。

MaxKeepAliveRequests 100

//单一客户反复连接服务的次数,可以小一点避免DDOS攻击。

KeepAliveTimeout 15

//一次连接中多次请求的间隔时间,如果客户端连接超过了这个时间,没有任何请求,
那么就自动断开。

StartServers

8//守护进程启动的时候,守护进程子进程的数量相关信息。

MinSpareServers 5//启动空闲的进程的最小值。

MaxSpareServers 20//启动空闲的进程的最大值。

MaxClinents 150//限制服务器允许并发的客户端连接数量。

MaxRequestPerChild 1000//一个子进程为多少次连接服务。

Listen 80//定义访问时的端口。

Include conf.d/*.conf //载入的配置文件。

User apache //apache用户

Group apache //apache用户组

ServerAdmin 服务器的管理员是本机的root用户

#ServerName_new.host.name:80//可以设置一个DNS服务器。

DocumentRoot "/var/www/html" //www服务所提供的路径。

DirectoryIndex index.html index.html.var

//这是提供www服务的访问次序。

#cd conf.d//配置文件,

#cd /var/www/html//下面有两个文件,mrtyusage.

#service httpd restart

------------------------------------------------------------------------------

第二个内容(口令访问)

------------------------------------------------------------------------------

#~~~~~~~~~~~~~~~~~~~~~~//最后一行

Authname "123abc"

AuthType Basic

AuthUserFile /etc/httpd/password //口令路径

Require user aiai dupeng //用户名 <注意单词不能写错>

#htpasswd -c /etc/httpd/passwd aiai

New password:7777777

Re-type new password: 7777777

#chmod 644 password

#ls -l

-rw-r--r-- root password

#htpasswd -c /etc/httpd/password dupeng

New password:7777777

Re-type new password: 7777777

#cd /etc/httpd/passwd start

-------------------------------------------------------

阅读(711) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~