CentOS安装Apache 整ssl
1. 安装Openssl
要使Apache支持SSL,需要首先安装Openssl支持。推荐下载安装openssl-0.9.8k.tar.gz下载Openssl:http://www.openssl.org/source/tar -zxf openssl-0.9.8k.tar.gz //解压安装包cd openssl-0.9.8k //进入已经解压的安装包./config //配置安装。推荐使用默认配置make && make install //编译及安装openssl默认将被安装到/usr/local/ssl
2.安装Apache
1)去官网下载:下载httpd-2.2.6.tar 包
./configure --prefix=/usr/local/apache --enable-so --enable-ssl --with-ssl=/usr/local/ssl --
enable-mods-shared=all
//配置安装。推荐动态编译模块
make && make install
动态编译Apache模块,便于模块的加载管理。Apache 将被安装到/usr/local/apache
3. Apache 2.2.* 的配置
打开apache安装目录下conf目录中的httpd.conf文件,找到
#LoadModule ssl_module modules/mod_ssl.so
#Include conf/extra/httpd_ssl.conf
删除行首的配置语句注释符号“#”
保存退出。
打开apache安装目录下conf/extra目录中的httpd-ssl.conf文件
在配置文件中查找以下配置语句
SSLCertificateFile conf/ssl.crt/server.crt 将服务器证书配置到该路径下
SSLCertificateKeyFile conf/ssl.key/server.key 将服务器证书私钥配置到该路径下
#SSLCertificateChainFile conf/ssl.crt/ca.crt 删除行首的“#”号注释符,并将中级CA证书配置到该路径下
保存退出,并重启Apache。重启方式:
进入Apache安装目录下的bin目录,运行如下命令
./apachectl -k stop
./apachectl -k start
打开apache安装目录下conf目录中的httpd.conf文件,找到
#LoadModule ssl_module modules/mod_ssl.so
#Include conf/extra/httpd_ssl.conf
删除行首的配置语句注释符号“#”
保存退出。
打开apache安装目录下conf/extra目录中的httpd-ssl.conf文件
在配置文件中查找以下配置语句
SSLCertificateFile conf/ssl.crt/server.crt 将服务器证书配置到该路径下
SSLCertificateKeyFile conf/ssl.key/server.key 将服务器证书私钥配置到该路径下
#SSLCertificateChainFile conf/ssl.crt/ca.crt 删除行首的“#”号注释符,并将中级CA证书配置到该路径下
保存退出,并重启Apache。重启方式:
进入Apache安装目录下的bin目录,运行如下命令
./apachectl -k stop
./apachectl -k start
编译安装时存在问题:
编译的时候出现问题:
1.mod_deflate has been requested but can not be built due to prerequisite failures(ubuntu centent)
2.(出现AH00557: httpd: apr_sockaddr_info_get() failed for Chunk3这个问题,解决办法, vi /usr/local/apache/conf/httpd.conf 找到#ServerName www.example.com:80 这行,把注释拿掉,然后改成ServerName localhost:80)
启动apache
service httpd start
(出现httpd: unrecognized service这个问题,解决办法
#cd /usr/local/apache/bin/
#cp apachectl /etc/rc.d/init.d/httpd
#vi /etc/rc.d/init.d/httpd
在#!/bin/sh这行下增加
# chkconfig: 2345 50 90
# description:Activates/Deactivates Apache Web Server)
在linux上安装有些东西时会出现 Permission denied 的情况:以下就是解决它的办法之一
编辑/etc/selinux/config,找到这段:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
把 SELINUX=enforcing 注释掉:#SELINUX=enforcing ,然后新加一行为:
SELINUX=disabled
保存,关闭。
......
编辑/etc/sysconfig/selinux,找到:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
如果SELINUX已经是 SELINUX=disabled,那么就不用改了,否则就把SELINUX=enforcing 注释掉,新加一行:
SELINUX=disabled
保存,退出。
如果你碰到其他类似提示:
cannot restore segment prot after reloc: Permission denied
哪应该是SELinux的问题,可以考虑把它关闭。
-------------------------------------------------------------------------------------
郁闷的是.我把SELinux关闭后还是不行.于是到google上search.发现这个很有用.
在你保证SElinux 被disable后.还执行下
chcon -t texrel_shlib_t
如: chcon -t texrel_shlib_t /路径/路径/名字.so (这个文件视具体执行文件.)
编辑/etc/selinux/config,找到这段:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
把 SELINUX=enforcing 注释掉:#SELINUX=enforcing ,然后新加一行为:
SELINUX=disabled
保存,关闭。
......
编辑/etc/sysconfig/selinux,找到:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
如果SELINUX已经是 SELINUX=disabled,那么就不用改了,否则就把SELINUX=enforcing 注释掉,新加一行:
SELINUX=disabled
保存,退出。
如果你碰到其他类似提示:
cannot restore segment prot after reloc: Permission denied
哪应该是SELinux的问题,可以考虑把它关闭。
-------------------------------------------------------------------------------------
郁闷的是.我把SELinux关闭后还是不行.于是到google上search.发现这个很有用.
在你保证SElinux 被disable后.还执行下
chcon -t texrel_shlib_t
如: chcon -t texrel_shlib_t /路径/路径/名字.so (这个文件视具体执行文件.)
4.yum被锁定无法使用:
rm -rf /var/run/yum.pid
然后再执行:
CentOS的软件安装工具不是apt-get 是yum
# yum -y install gcc
===============
# yum -y install gcc gcc-c++ libstdc++-devel