php apache ssl,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-sysvmsg --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

第五步:测试

在/usr/local/apache/htdocs中编写一个info.php文件:

启动Apache:

/etc/init.d/httpd start

在浏览器中输入:

http://127.0.0.1/info.php

和https://127.0.0.1/info.php 进行测试。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值