标签:share mtu 编译安装 register 技术分享 过程 地址 make service
1.编译安装httpd-2.4主机名 | 操作系统 | ip地址 |
---|---|---|
root@bogon ~ | rhel7 | 192.168.43.199 |
更改主机名,关掉防火墙和selinux。
[root@bogon ~]# systemctl stop firewalld.service
[root@bogon ~]# setenforce 0
[root@bogon ~]# getenforce
Permissive*
#安装开发环境
[root@bogon ~]# yum groupinstall "Development Tools" -y
过程略.......
[root@bogon ~]# yum -y install openssl-devel pcre-devel expat-devel lib tool
过程略......
#下载并安装apr-1.4+apr-util-1.4
[root@bogon src]# wget http://mirrors.shu.edu.cn/apache//apr/apr-1.6.3.tar.bz2
过程略
[root@bogon src]# wget http://mirrors.shu.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2
过程略
#下载完成后对其进行解压
[root@bogon src]# ls
apr-1.6.3.tar.bz2 apr-util-1.6.1.tar.bz2 debug httpd-2.4.34.tar.bz2 kernels
[root@bogon src]# tar xf apr-1.6.3.tar.bz2
[root@bogon src]# tar xf apr-util-1.6.1.tar.bz2
[root@bogon src]# ls
apr-1.6.3 apr-util-1.6.1 debug kernels
apr-1.6.3.tar.bz2 apr-util-1.6.1.tar.bz2 httpd-2.4.34.tar.bz2
#编辑configure文件
[root@bogon apr-1.6.3]# vim configure
cfgfile=${ofile}T
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
#$RM "$cfgfile" 加注释
#编译安装 apr-1.6.3和apr-util-1.6.1,编译安装过程省略。
[root@bogon apr-1.6.3]# ./configure --prefix=/usr/local/apr
[root@bogon apr-1.6.3]# make && make install
[root@bogon apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@bogon apr-util-1.6.1]# make && make install
#下载编译安装httpd:
[root@bogon ~]#wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.3
4.tar.bz2
[root@bogon ~]# ls
anaconda-ks.cfg httpd-2.4.34.tar.bz2
[root@bogon ~]# tar xf httpd-2.4.34.tar.bz2
[root@bogon ~]# cd httpd-2.4.34
[root@bogon httpd-2.4.34]# ./configure --prefix=/usr/local/apache > --sysconfdir=/etc/httpd24 > --enable-so > --enable-ssl > --enable-cgi > --enable-rewrite > --with-zlib > --with-pcre > --with-apr=/usr/local/apr > --with-apr-util=/usr/local/apr-util/ > --enable-modules=most > --enable-mpms-shared=all > --with-mpm=prefork
[root@bogon httpd-2.4.34]# make && make install
#开启服务
[root@bogon bin]# ./apachectl start
httpd (pid 62102) already running
#查看进程
[root@bogon bin]# ps -ef |grep httpd
root 62102 1 0 22:47 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 62103 62102 0 22:47 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 62104 62102 0 22:47 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 62105 62102 0 22:47 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 62106 62102 0 22:47 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 62107 62102 0 22:47 ? 00:00:00 /usr/local/apache/bin/httpd -k start
root 62114 2085 0 22:52 pts/1 00:00:00 grep --color=auto httpd
[root@bogon bin]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
#在客户机上验证
2.配置三种不同风格的虚拟主机
2.1相同ip不同端口.
[root@bogon htdocs]# mkdir yiyi
[root@bogon htdocs]# mkdir scsc
[root@bogon htdocs]# echo ‘hello‘ > /usr/local/apache/htdocs/yiyi/index.html
[root@bogon htdocs]#echo ‘world‘ > /usr/local/apache/htdocs/scsc/index.html
[root@bogon htdocs]# ls
index.html scsc yiyi
#更改配置文件内容。
[root@bogon ~]# vim /etc/httpd24/httpd.conf # If your host doesn‘t have a registered DNS name, enter its IP addres s here.
ServerName www.example.com:80 #取消前面的#号
#Deny access to the entirety of your server‘s filesystem. You must
[root@httpd ~]# vim /etc/httpd24/httpd.conf
#Listen 12.34.56.78:80
Listen 80
Listen 8080 #添加监听8080端口
编辑配置文件:
[root@httpd ~]# vim /etc/httpd24/httpd.conf
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
<VirtualHost 192.168.118.100:80>
ServerName www.ls.com
DocumentRoot "/usr/local/apache/htdocs/tom"
ErrorLog "/usr/local/apache/htdocs/haha.log"
CustomLog "/usr/local/apache/htdocs/haha.log" combined
<Directory /usr/local/apache/htdocs/tom>
Require all granted
</Directory>
</VirtualHost>
<VirtualHost 192.168.118.100:8080>
ServerName www.jerry.com
DocumentRoot "/usr/local/apache/htdocs/jerry"
ErrorLog "/usr/local/apache/htdocs/haha.log"
CustomLog "/usr/local/apache/htdocs/haha.log" combined
<Directory /usr/local/apache/htdocs/jerry>
Require all granted
</Directory>
</VirtualHost>
"/etc/httpd24/httpd.conf" 530L, 19464C
#重启httpd服务:
[root@httpd bin]# ./apachectl restart
Windows开机服务验证:
2.2相同端口不同的ip
#增加虚拟主机2的ip
[root@bogon ~]# ip addr add 192.168.43.111/24 dev ens33
[root@bogon ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:39:f7:f2 brd ff:ff:ff:ff:ff:ff
inet 192.168.43.199/24 brd 192.168.43.255 scope global dynamic ens33
valid_lft 3509sec preferred_lft 3509sec
inet 192.168.168.34/24 brd 192.168.168.255 scope global ens33
valid_lft forever preferred_lft forever
inet 192.168.43.111/24 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::9059:e88a:8b54:f6fa/64 scope link
valid_lft forever preferred_lft forever
#更改配置文件虚拟主机2的IP地址:
[root@bogon bin]# vim /etc/httpd24/httpd.conf
#virtual host 2
<VirtualHost 192.168.43.111:80>
ServerName www.scsc.com
DocumentRoot "/usr/local/apache/htdocs/scsc"
ErrorLog "logs/error_log"
CustomLog "logs/access_log" combined
<Directory /usr/local/apache/htdocs/scsc>
Require all granted
</Directory>
</VirtualHost>
#重启一下httpd服务:
[root@bogon ~]# cd /usr/local/apache/bin
[root@bogon bin]# ./apachectl restart
[root@bogon bin]# ss -ant
#在Windows浏览器上进行验证:
3.相同IP相同端口不同域名
#更改配置文件:
[root@bogon bin]# vim /etc/httpd24/httpd.conf
</IfModule>
#virtual host 1
<VirtualHost 192.168.43.199:80>
ServerName www.yiyi.com
DocumentRoot "/usr/local/apache/htdocs/yiyi"
ErrorLog "logs/error_log"
CustomLog "logs/access_log" combined
<Directory /usr/local/apache/htdocs/yiyi>
Require all granted
</Directory>
</VirtualHost>
#virtual host 2
<VirtualHost 192.168.43.199:80>
ServerName www.scsc.com
DocumentRoot "/usr/local/apache/htdocs/scsc"
ErrorLog "logs/error_log"
CustomLog "logs/access_log" combined
<Directory /usr/local/apache/htdocs/scsc>
Require all granted
</Directory>
</VirtualHost>
#在windows客户机上增加环境变量,让虚拟域名和虚拟主机ip对照:
#找到hosts文件增加如下内容:
127.0.0.1 wwis-dubc1-vip60.adobe.com
127.0.0.1 activate-sjc0.adobe.com
192.168.43.199 www.scsc.com
192.168.43.199 www.yiyi.com
#重启服务,在Windows上进行验证:
标签:share mtu 编译安装 register 技术分享 过程 地址 make service
原文地址:http://blog.51cto.com/13945839/2178021