设为首页 收藏本站
查看: 1547|回复: 0

LAMP之三(编译安装httpd-fpm)

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-2-1 10:11:46 | 显示全部楼层 |阅读模式
linux+httpd+php-fpm+mysql
编译安装

环境:
iptables、selinux关闭状态

系统: CentOS release 6.7 (Final)
yum源:epel,cdrom

软件:
php-5.6.17
下载页面:http://php.net/downloads.php
httpd 2.4.18
下载页面:http://httpd.apache.org/download.cgi#apache24
mariadb 前面有专门编译的了,这里就直接yum安装了。

编译安装mariadb5.5http://www.iyunv.com/thread-172135-1-1.html

主机:
httpd
172.16.40.20
php-fpm
172.16.40.21
mysql
172.16.40.22
wKioL1apyq2TEv5iAABm9zVamY8626.jpg

一、http
二、php
三、Mysql(rpm安装的

四、安装phpMydmin和wordpress

五、为phpMyadmin添加https。



一、http:
httpd2.4依赖于apr1.4,而我们系统上面自带的apr是1.3.9的版本。所以我们要自己来编译新版本的apr工具。
apr是httpd程序代码跨平台的基础。不然还要为各个系统上运行的httpd来编写不同的库函数。
提供了一个对httpd统一的环境,而不用再操心为各个系统再编写适用的底层库。
网摘:

APR(Apache portable Run-time libraries,Apache可移植运行库)主要为上层的应用程序提供一个可以跨越多操作系统平台使用的底层支持接口库。在早期 的Apache版本中,应用程序本身必须能够处理各种具体操作系统平台的细节,并针对不同的平台调用不同的处理函数。


apr下载地址(apr、apr-utils):
http://apr.apache.org/download.cgi

http://mirrors.hust.edu.cn/apache//apr/apr-1.5.2.tar.gz

http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.4.tar.gz
wKioL1ap4nPwlVbNAAAWK-bNmoE602.jpg
这里是新装的系统,缺少开发工具和开发库。简单点可以直接安装开发包组。

1
2
yum groupinstall "Development tools"                              #开发工具
yum groupinstall "Server Platform Development"            #服务器开发库




apr:
1
2
3
[iyunv@localhost apr-1.5.2]# ./configure --prefix=/usr/local/apr
[iyunv@localhost apr-1.5.2]# make
[iyunv@localhost apr-1.5.2]# make install




apr-utils:
1
2
[iyunv@localhost apr-util-1.5.4]# ./configure --prefix=/usr/local/apr/ --with-apr=/usr/local/apr
[iyunv@localhost apr-util-1.5.4]# make && make install




httpd:
所依赖的包。
1
[iyunv@localhost httpd-2.4.18]# yum install pcre-devel openssl-devel -y



pcre 重写引擎要用到的,用来区配地址以重写为别的地址。
安装httpd:

1
2
[iyunv@localhost httpd-2.4.18]# ./configure --prefix=/usr/local/httpd24 --sysconfdir=/etc/httpd24 --enable-modules=most --enable-so --enable-ssl --enable-mpms-shared=all --enable-cgid --enable-rewrite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr --with-pcre --with-mpm=event
[iyunv@localhost httpd-2.4.18]# make && make install



1
2
3
4
5
6
7
8
9
10
11
12
--prefix=/usr/local/httpd24   #安装位置
--sysconfdir=/etc/httpd24      #配置文件位置。
--enable-modules=most        #要启用的模块,就是会编译成模块的, 而不是自动挂载的。对应的还有:
                                                   #--enable-mods-shared  要启用的共享模块。
                                                   #--enable-mods-static     要启用的静态模块。
--enable-so                               #启用动态装载(DSO)功能。也就是动态装载模块的功能。
--enable-ssl                              #启用ssl模块。不知道在上面的most里面有没有包括这个,没有尝试过。
--enable-mpms-shared=all    #各mpm功能以模块的形式存在。可以通过挂载不同的mpm模块来使用不同的功能模型。prefork,event,worker
--enable-cgid                            #cgi脚本功能,这里要用event模型,线程模型用这个来开启。非线程模型用--enabl-cgi来开启。
--enable-rewrite                      #URL重写的基本定义规则。
--with-pcre                                #使用外部的pcre库。
--with-mpm=event                  #默认event模型




服务脚本我们可以把系统自带的http脚本复制一份改一下就可以,也省得麻烦自己写了。

1
2
3
4
5
[iyunv@localhost httpd24]# cp /root/httpd /etc/init.d/httpd24       #我这里就是从别处复制来的。
[iyunv@localhost httpd24]# chkconfig --add httpd24                    #添加进chkconfig控制。
[iyunv@localhost httpd24]# chkconfig httpd24 on                         #设置开机启动
[iyunv@localhost httpd24]# chkconfig --list httpd24                      #查看状态。
httpd24         0:off   1:off   2:on    3:on    4:on    5:on    6:off



修改一下脚本,主要改的也就几个:
1
2
3
4
5
apachectl=/usr/local/httpd24/bin/apachectl
httpd=/usr/local/httpd24/bin/httpd
prog=httpd
pidfile=/var/run/httpd24/httpd.pid                #这个路径也可以直接指到默认的pid所在的位置,安装目录的logs/httpd.pid。不然就要在httpd的配置文件中修改pid文件所在位置,
lockfile=/var/lock/subsys/httpd24



我这里的设置,为了用系统上的httpd区分开(有时候可能一些软件依赖,httpd会自动安装上的),所以pidfile用了httpd24的目录。创建所必须的目录即可。
修改pid文件位置。添加一条PidFile指令即可。

wKiom1ap_Sbi6_OhAAAWdwWcPaQ393.jpg
启动:
1
2
3
[iyunv@localhost httpd24]# service httpd24 start
Starting httpd: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
                                                           [  OK  ]



这个错误是因为没有设置ServerName,然后反解IP地址失败,或者反解名称与主机名不一样导致的。设置上ServerName就可以了。如:
1
ServerName www.star.com





编译安装的2.4个人感觉与rpm安装还容易配置,配置文件非常的有条理。用什么功能,就配置对应的配置文件就行。

虚拟主机设置
因为在前二篇里已经反复写过两次配置过程了。这里就简略的写了。

加载模块,加载子配置文件。
wKioL1ap_9rzFUw8AAAdgx9rkZA720.jpg
wKiom1ap_5KBPqZ0AAAUnSK9mso498.jpg
1
2
3
[iyunv@localhost httpd24]# pwd
/etc/httpd24
[iyunv@localhost httpd24]# vim extra/httpd-vhosts.conf



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
41 <VirtualHost *:80>
42         ServerName www.star.com
43         DocumentRoot "/web/vhosts/www"
44         CustomLog "/var/log/httpd24/www/access_log" combined
45         ErrorLog "/var/log/httpd24/www/error_log"
46         <Directory "/web/vhosts/www">
47                 Options None
48                 Require all granted
49         </Directory>
50 </VirtualHost>
51
52
53
54 <VirtualHost *:80>
55         ServerName myadm.star.com
56         DocumentRoot "/web/vhosts/myadm"
57         CustomLog "/var/log/httpd24/myadm/access_log" combined
58         ErrorLog "/var/log/httpd24/myadm/error_log"
59         <Directory "/web/vhosts/myadm">
60                 Options None
61                 Require all granted
62         </Directory>
63 </VirtualHost>




关闭中心中机,注释DocumentRoot:
1
2
[iyunv@localhost star]# vim /etc/httpd24/httpd.conf
#DocumentRoot "/usr/local/httpd24/htdocs




创建所需目录
1
2
[iyunv@localhost httpd24]# mkdir /web/vhosts/{www,myadm} -pv
[iyunv@localhost httpd24]# mkdir /var/log/httpd24/{www,myadm} -pv



把httpd的执行文件添加进PATH变量,也可以用符号链接的方式:
1
2
3
4
5
[iyunv@localhost star]# vim /etc/profile.d/httpd24.sh
export PATH=/usr/local/httpd24/bin:$PATH
[iyunv@localhost star]# . /etc/profile.d/httpd24.sh
[iyunv@localhost star]# echo $PATH
/usr/local/httpd24/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin



测试并重启httpd(重载也可以):
1
2
3
4
5
6
[iyunv@localhost star]# httpd -t
Syntax OK
[iyunv@localhost star]# service httpd24 restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
[iyunv@localhost star]#



测试页面,内容就朋友们自定吧:
1
2
[iyunv@localhost star]# vim /web/vhosts/www/index.html
[iyunv@localhost star]# vim /web/vhosts/myadm/index.html



本地测试可以在hosts文件中添加主机名来完成域名解析:
windows主机在system32/driver/etc/hosts文件中修改

linux主机在/etc/hosts中。
如我这里的:
1
2
3
4
star@sst-pp:/mnt/g/soft$ sudo vim /etc/hosts
.....
172.16.40.20 www.star.com myadm.star.com
.....




测试没有问题,html服务工作正常 。
现在我们再添加反向代理的条目,php页面都代理至后端的php服务器。并且在DirectoryIndex后面加入默认文档index.php。我们测试这里主页面都是php的,所以要在index.html前面。

主配置文件启用代理模块,有两个, 一个是总代理模块,一个是fcgi功能模块。
1
2
3
[iyunv@localhost httpd24]# pwd
/etc/httpd24
[iyunv@localhost httpd24]# vim httpd.conf



wKioL1aqB7uzOwYWAAAt4Ygoj8A174.jpg
添加代理指令
现在的httpd-vhosts配置文件:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
AddType application/x-httpd-php .php        #添加或覆盖mime类型。
                                                                           #现在.php的mime就是application/x-httpd-php。 主类型/次类型
ProxyRequests Off                                           #关闭正向代理
<VirtualHost *:80>
        ServerName www.star.com
        DocumentRoot "/web/vhosts/www"
        CustomLog "/var/log/httpd24/www/access_log" combined
        ErrorLog "/var/log/httpd24/www/error_log"
        ProxyPassMatch ^/(.*\.php)$     fcgi://172.16.40.21:9000/web/php/www/$1        #代理至
        <Directory "/web/vhosts/www">
                Options None
                Require all granted
        </Directory>
</VirtualHost>

<VirtualHost *:80>
        ServerName myadm.star.com
        DocumentRoot "/web/vhosts/myadm"
        CustomLog "/var/log/httpd24/myadm/access_log" combined
        ErrorLog "/var/log/httpd24/myadm/error_log"
        ProxyPassMatch ^/(.*\.php)$     fcgi://172.16.40.21:9000/web/php/myadm/$1     #代理至
        <Directory "/web/vhosts/myadm">
                Options None
                Require all granted
        </Directory>
</VirtualHost>



上面的AddType定义mime,可以把反向代理关闭以后,在浏览器中打开一个.php页面试一下。
wKioL1aqDb-zP9tVAAALswH8ZwQ527.jpg
不过因为浏览器无法识别此mime,所以会下载此文件。
扩充一点:浏览器能做的就是只显示文本而已,而其它的数据都是通过mime类型来加载对应的插件或软件来处理的。



默认文档
wKioL1aqCALy2pUkAAAaT1qQEYA821.jpg
dir模块默认都是启用的,所以里面的指令是生效的。

1
2
3
[iyunv@localhost httpd24]# service httpd24 reload
Reloading httpd:
[iyunv@localhost httpd24]#



现在默认网页就已经不能打开了,php给转到了后端,而后端不会返回数据。
wKioL1aqLKCh3GiuAAAaTI0cpMo678.jpg


二、php:
1
2
[iyunv@localhost php-5.6.17]# ./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=php --with-fpm-group=php --with-config-file-path=/etc/ --with-config-file-scan-dir=/etc/php.d/ --with-openssl --with-zlib --with-bz2 --with-jpeg-dir --with-png-dir  --enable-mbstring --with-mcrypt --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd  --enable-sockets --with-freetype-dir
[iyunv@localhost php-5.6.17]# make install



make test 实在是太耗时间了,这里就不试了。生产环境最好还是跑一下。


报错信息:

1
2
configure: error: xml2-config not found. Please check your libxml2 installation.
[iyunv@localhost php-5.6.17]# yum install libxml2-devel -y



1
2
configure: error: Cannot find OpenSSL's <evp.h>
[iyunv@localhost php-5.6.17]# yum install openssl-devel -y



1
2
configure: error: Please reinstall the BZip2 distribution
[iyunv@localhost php-5.6.17]# yum install -y bzip2-devel



1
2
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
[iyunv@localhost php-5.6.17]# yum install libmcrypt-devel -y



参数介绍:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
--enable-fpm                                #启用fpm。  不能与做为httpd模块的方式并存。也就是--with-apxs2
--with-fpm-user=php                  #指定程序运行的用户
--with-fpm-group=php                #指定程序运行的用户组
--with-config-file-path=/etc/       #指定php编译器环境配置文件。与php-fpm不一样。php-fpm只是提供对外连接接口的。编译器才是真正来编译php程序的。
--with-config-file-scan-dir=/etc/php.d/      #php编译器的扩展配置文件所在目录。如把对于xcache的配置文件放在里面。
--with-openssl                               #openssl支持。
--with-zlib                                       #zlib是提供数据压缩用的函式库。它不能创建gzip压缩文件,但可以读取和在gzip压缩文件中写入数据。
--with-bz2                                       #bzip2库函式。可以透明地读写 bzip2(.bz2)压缩文件。
--with-jpeg-dir                                #输出图象到浏览器或文件,动态绘图功能。
--with-png-dir                                 #也一样。
--enable-mbstring                         # 多字节字符支持,如汉字。
--with-mcrypt                                 #提供多种加密算法支持的库
--with-mysql=mysqlnd                  #指定mysql连接器,mysqlnd是php内置的连接mysql系列数据库的连接器。
--with-mysqli=mysqlnd                 #指定mysqli连接器
-with-pdo-mysql=mysqlnd           #指定mysql-pdo连接器。
--enable-sockets                            #启用socket通迅,BSD-socket。  也就是远程网络通信了。本地文件通信是unix-socket.
--with-freetype-dir                         #字体引擎。




额外的参数:

1
2
3
4
--with-apxs2=FILE             #编译成httpd的模块,指定httpd的apxs工具所在位置。如果在PATH变量中可以找到apxs,后面的FILE可以省略。不过请注意此apxs是否是想要运行的httpd的apxs。
--sysconfdir=DIR                #这个是fpm的配置文件所在位置,一般不用配置,默认在安装目录下的etc下。
--with-mhas                        #基于离散数学原理的不可逆向的php加密方式扩展库
--enable-zip                        #透明地读写ZIP压缩文档以及它们里面的文件。现在好像不怎么用zip压缩了吧。







编译核心配置选项列表

http://cn2.php.net/manual/zh/configure.about.php



FPM配置选项
http://cn2.php.net/manual/zh/install.fpm.configuration.php


针对各数据库系统对应的扩展

http://php.net/manual/zh/refs.database.vendors.php


连接器mysql,mysqli,mysql-pdo介绍

http://php.net/manual/zh/mysqli.overview.php


其它信息可以查看php手册或google。
php手册,可以在右上角搜索信息。

http://php.net/manual/zh/index.php




接着来配置我们的php。
php编译器配置文件。
1
2
[iyunv@localhost php-5.6.17]# cp php.ini-production  /etc/php.ini
[iyunv@localhost php-5.6.17]# mkdir /etc/php.d



php-fpm服务脚本。注意这是在php代码的目录。
1
2
3
4
5
6
7
[iyunv@localhost php-5.6.17]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm     
[iyunv@localhost php-5.6.17]# chmod +x /etc/init.d/php-fpm
[iyunv@localhost php-5.6.17]# chkconfig --add php-fpm
[iyunv@localhost php-5.6.17]# chkconfig php-fpm on
[iyunv@localhost php-5.6.17]# chkconfig --list php-fpm
php-fpm         0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
[iyunv@localhost php-5.6.17]#



1
注意不要复制错了,不要复制成init.d.php-fpm.in了,这个文件是php安装之前的文件,而init.d.php-fpm是安装以后生成的。




fpm配置文件:
1
2
3
4
5
6
7
8
[iyunv@localhost php]# pwd
/usr/local/php
[iyunv@localhost php]# ls
bin  etc  include  lib  php  sbin  var
[iyunv@localhost php]# cd etc
[iyunv@localhost etc]# ls
pear.conf  php-fpm.conf.default
[iyunv@localhost etc]# cp php-fpm.conf.default php-fpm.conf



编辑配置文件:
1
2
3
[iyunv@localhost etc]# vim php-fpm.conf
listen = 172.16.40.21:9000
listen.allowed_clients = 172.16.40.20



注要就这两项,其它的暂时也不用修改。

启动php-fpm:

1
2
3
4
[iyunv@localhost local]# service php-fpm start
Starting php-fpm [28-Jan-2016 22:58:53] ERROR: [pool www] cannot get uid for user 'php'
[28-Jan-2016 22:58:53] ERROR: FPM initialization failed
failed



额,忘了创建php用户了。
1
2
3
4
5
6
[iyunv@localhost local]# useradd -r -s /sbin/nologin php
[iyunv@localhost local]# service php-fpm start
Starting php-fpm  done
[iyunv@localhost local]# ss -tnl
State      Recv-Q Send-Q                       Local Address:Port                         Peer Address:Port
LISTEN     0      128                           172.16.40.21:9000                                    *:*




安装xcache

1
2
3
4
5
6
7
8
9
10
11
[iyunv@localhost star]# tar -xf xcache-3.2.0.tar.gz
[iyunv@localhost star]# cd xcache-3.2.0
[iyunv@localhost xcache-3.2.0]# /usr/local/php/bin/p
pear        peardev     pecl        phar        phar.phar   php         php-cgi     php-config  phpize
[iyunv@localhost xcache-3.2.0]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.



phpize和php-config工具都是用来为php安装第三方扩展模块用的。

缺少autoconf.  用来生成config配置文件的。
1
2
3
4
5
6
7
8
9
10
11
12
13
[iyunv@localhost xcache-3.2.0]# yum install autoconf -y

[iyunv@localhost xcache-3.2.0]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
[iyunv@localhost xcache-3.2.0]#

[iyunv@localhost xcache-3.2.0]# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
[iyunv@localhost xcache-3.2.0]# make
[iyunv@localhost xcache-3.2.0]# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/



这个路径是xcache模块的存放路径,如果php识别不出来,就要自己手动指定extension了,而且要完整路径。不过现在一般都可以识别出来的。
复制xcache中的配置文件到/etc/php.d/。  用来让php识别此扩展模块。

1
[iyunv@localhost xcache-3.2.0]# cp xcache.ini  /etc/php.d/





测试:

创建php下网页文件存放目录。此目录就是前面httpd用fcgi协议发过来的目录。
1
2
3
4
5
[iyunv@localhost star]# mkdir /web/php/{www,myadm} -pv
mkdir: created directory `/web'
mkdir: created directory `/web/php'
mkdir: created directory `/web/php/www'
mkdir: created directory `/web/php/myadm'



创建网页测试:
1
2
3
4
5
6
7
8
9
10
11
12
13
[iyunv@localhost star]# vim /web/php/www/index.php

<h1>www.star.com</h1>
<?php
        phpinfo();
?>

[iyunv@localhost star]# vim /web/php/myadm/index.php

<h1>myadm.star.com</h1>
<?php
        phpinfo();
?>



重启php-fpm。打开网页完成测试。
1
[iyunv@localhost xcache-3.2.0]# service php-fpm restart



wKiom1aqMI6SLko8AADJT47t8Zg051.jpg

三、mysql:
安装,为wordpress创建数据库并授权用户。创建远程管理用户root。 这里就不做其它操作了。

1
2
3
4
5
6
7
8
9
10
11
12
[iyunv@localhost ~]# yum install mysql-server -y
[iyunv@localhost ~]# service mysqld start
[iyunv@localhost ~]# mysql

mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL ON wordpress.* TO wpuser@'172.16.40.21' IDENTIFIED BY 'abcdefg';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL ON *.* TO root@'172.16.40.21' IDENTIFIED BY 'abcdefg';
Query OK, 0 rows affected (0.00 sec)





四、安装phpMyAdmin,WordPress。

php主机:
phpMyAdmin:

1
2
3
[iyunv@localhost star]# unzip phpMyAdmin-4.5.3.1-all-languages.zip
[iyunv@localhost star]# mv phpMyAdmin-4.5.3.1-all-languages/* /web/php/myadm/
mv: overwrite `/web/php/myadm/index.php'? y




wordpress:
1
2
3
4
5
6
7
8
[iyunv@localhost star]# unzip wordpress-4.4.1-zh_CN.zip
[iyunv@localhost star]# mv wordpress/* /web/php/www/
mv: overwrite `/web/php/www/index.php'? y
[iyunv@localhost star]#

[iyunv@localhost star]# cd /web/php/www
[iyunv@localhost www]# cp wp-config-sample.php  wp-config.php
[iyunv@localhost www]# vim wp-config.php



wKioL1aqMh6S6SvMAACQrTIP8_k211.jpg
修改上述信息为所定义的数据库和所授权的数据库用户。

phpMyAdmin:
1
2
3
4
5
[iyunv@localhost www]# cd ../myadm/
[iyunv@localhost myadm]# cp config.sample.inc.php config.inc.php
[iyunv@localhost myadm]# openssl rand -base64 15
3Wvh8YWSRv0RxKYfvinv
[iyunv@localhost myadm]# vim config.inc.php



wKiom1aqMnHinLf3AABmCkUsqi4203.jpg
添加随机码和目标数据库。


httpd主机:
1
2
3
4
[iyunv@localhost star]# mv phpMyAdmin-4.5.3.1-all-languages/* /web/vhosts/myadm/
[iyunv@localhost star]# mv wordpress/* /web/vhosts/www/
mv: overwrite `/web/vhosts/www/index.php'? y
[iyunv@localhost star]#



那个php文件是刚才我这里测试的时候创建的。

现在我们来测试一下,这两个php应用能正常打开不。
注意防火墙。
wKiom1aqM9Wybi7QAABycDEjd7c376.jpg
wKioL1aqNB3R_4QiAACAa_OPubs293.jpg

都工作正常。
提示MySQL版本太低了。额。

wKiom1aqNBzRsMfFAAAth52UmXE789.jpg
我这里用centos7做数据库看一下。

修改一下phpMyAdmin配置文件对数据库的指向。  只要修改php主机上的就可以了。 我们知道 httpd是不会执行php文件的。
phpMyAdmin:
1
$cfg['Servers'][$i]['host'] = '172.16.40.12';




久违的页面终于出来了。
wKioL1aqNkvidOb8AAD7m-SqrMI751.jpg


五、为phpMyadmin添加https。

这里就不写怎么建立私有CA了,前面都写了两遍,看的也眼花不是。只来过一下怎么开启吧。
httpd主机, php主机休息了。
挂载模块,和开启ssl的配置文件:
1
2
3
4
LoadModule ssl_module modules/mod_ssl.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so

Include /etc/httpd24/extra/httpd-ssl.conf



证书和私钥放到了配置目录的ssl目录下了。

1
2
3
4
5
[iyunv@localhost httpd24]# ls
extra  httpd.conf  magic  mime.types  original  ssl
[iyunv@localhost httpd24]# ls ssl
myadm.crt  myadm.key
[iyunv@localhost httpd24]#



现在对于myadm.star.com虚拟主机的配置,www.star.com的虚拟主机没有修改,这里就不帖了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<VirtualHost *:443>
        ServerName myadm.star.com
        DocumentRoot "/web/vhosts/myadm"
        CustomLog "/var/log/httpd24/myadm/access_log" combined
        ErrorLog "/var/log/httpd24/myadm/error_log"
        ProxyPassMatch ^/(.*\.php)$     fcgi://172.16.40.21:9000/web/php/myadm/$1
        SSLEngine on
        SSLCertificateFile "/etc/httpd24/ssl/myadm.crt"
        SSLCertificateKeyFile "/etc/httpd24/ssl/myadm.key"
        <Directory "/web/vhosts/myadm">
                Options None
                Require all granted
        </Directory>
</VirtualHost>



要注意SSLEngine on在现在这种状态只能放在虚拟主机里面,只在这个虚拟主机中启用ssl。不然会因为另一个虚拟主机没有证书而报错的。
1
2
3
4
[Fri Jan 29 11:59:27.191067 2016] [ssl:emerg] [pid 1216:tid 140707884644096] AH02572: Failed to configure at least one certificate and key for www.star.com:443
[Fri Jan 29 11:59:27.191204 2016] [ssl:emerg] [pid 1216:tid 140707884644096] SSL Library Error: error:140A80B1:SSL routines:SSL_CTX_check_private_key:no certificate assigned
[Fri Jan 29 11:59:27.191212 2016] [ssl:emerg] [pid 1216:tid 140707884644096] AH02312: Fatal error initialising mod_ssl, exiting.
AH00016: Configuration Failed




因为是私有CA,所以要手动的把CA的根证书导入浏览器。 让浏览器信任由此CA所颁发的证书。
看一下现在的浏览器。
wKiom1arXZjByMxoAABgOu1OD4M646.jpg
wKioL1arXeHSfP2WAAAchjbx6z0930.jpg


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-172213-1-1.html 上篇帖子: LNMP安装与启动脚本编写 下篇帖子: 编译安装lamp
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表