为了账号安全,请及时绑定邮箱和手机立即绑定

Apache+PHP+SSL 安装步骤

标签:
PHP

准备工作:
完成该种配置,需要如下软件包:
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 进行测试。


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消