apache
先安装openssl
然后升级一下 expat2
安装 apache2
安装 apache 的 mod
fastcgi:
OK,完成了。
下来是php:
安装后的设置:
看一下 /usr/etc/apache2 目录下面已经有几个 httpd 的设置文件了,拷一个当正式的配置文件
| Code: | [Copy to clipboard] |
| cp /usr/local/etc/apache2/httpd-dist.conf /usr/local/etc/apache2/httpd.conf |
|
然后编辑 httpd.conf
| Code: | [Copy to clipboard] |
#增加对php的支持,在AddType application/x-gzip .gz .tgz后面加: AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
#随后设置网站默认启动页允许为index.php,找到 DirectoryIndex这行,改为: DirectoryIndex index.html index.htm index.php index.html.var
#再设置apache默认字符集为简体中文。找到 AddDefaultCharset 改成: AddDefaultCharset GB2312
#另外,一个访问量较大的网站,apache默认的150连接肯定是不行的。以下各行改为: StartServers 10 MinSpareServers 10 MaxSpareServers 15 ServerLimit 2000 MaxClients 1500 MaxRequestsPerChild 10000 |
|
最后,要在服务器启动时自动启动 apache,需要编辑 /etc/rc.conf
加入以下两行:
这时候,你可以用以下命令来试着启动 apache
===============================================
如果提示说 ssl.conf 配置文件某行有错,server.crt 证书文件不存在的话,那么恭喜你,跟我一样中奖了,我不知道这是否是 apache2 port的一个bug,总之这样安装完的apache+mod_ssl 是没有服务器证书的,apache2启动失败了,我们需要手工来签属一个可用的证书
先下载一下证书生成程序:http://www.openssl.org/contrib/ssl.ca-0.1.tar.gz
然后:
| Code: | [Copy to clipboard] |
tar zxvf ssl.ca-0.1.tar.gz cd ssl.ca-0.1 ./new-root-ca.sh ./new-server-cert.sh server ./sign-server-cert.sh server |
|
我只写了相关的命令,后面三个命令执行时会有一系列的问题需要回答:密码、省份、城市、机构 。。。。有够烦的,自己看着办吧,赫赫
不过友情提示一下:./new-server-cert.sh server 的时候,commonName 最好设成跟你的 ServerName 一样,不然 apache 启动中会生成错误日志。
好了,然后到 /usr/local/etc/apache2 目录下面建两个目录来存放刚才生成的 crt 和 key 文件
然后将刚才生成的四个文件放到新目录下面,再修改属性,以策安全
| Code: | [Copy to clipboard] |
cp ca.crt /usr/local/etc/apache2/ssl_crt cp ca.key /usr/local/etc/apache2/ssl_key cp server.crt /usr/local/etc/apache2/ssl_crt cp server.key /usr/local/etc/apache2/ssl_key cd /usr/local/etc/apache2/ssl_key chmod 444 server.key chmod 444 server.key cd /usr/local/etc/apache2/ssl_crt chmod 444 server.crt chmod 444 server.crt |
|
OK,搞定,现在启动 apache2 应该没有问题了