linux——编译安装httpd服务,同ip端口,不同域名
2018-08-13 15:42
736 查看
1.环境,先关防火墙
编译安装httpd-2.4
注:
./configure --prefix=/usr/local/apache \ //安装路径
”--sysconfdir=/etc/httpd24 \ 配置路径
--with-mpm=prefork 可改成worker
”
虚拟主机
虚拟主机有三类:
相同IP不同端口
不同IP相同端口
相同IP不同端口不同域名
vim /etc/httpd24/httpd.conf
创建网址文件
在logs下创建文件
赋予属主属组权限
启动方式
1.
2.
编辑etc/host文件地点,ip+网址
[root@localhost ~]# systemctl status firewalld [root@localhost ~]# systemctl disable firewalld [root@localhost ~]# systemctl stop firewalld [root@localhost ~]# setenforce 0
编译安装httpd-2.4
//安装开发环境 yum groupinstall "Development Tools" yum groups mark install "Development Tools" //安装检查 yum grouplist //创建系统用户,组但不创建新组文件 groupadd -r apache useradd -M -s /sbin/nologin -g apache apache (-M/不自动登陆,-s/这里指不登陆,-g/指定用户组) yum -y install openssl-devel pcre-devel expat-devel libtool
//下载并安装apr-1.4+和apr-util-1.4+ cd /usr/src/ wget http://mirrors.shu.edu.cn/apache//apr/apr-1.6.3.tar.bz2 wget http://mirrors.shu.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2 //解压成bz2 tar xf apr-1.6.3.tar.bz2 tar xf apr-util-1.6.1.tar.bz2 //编辑apr-1.6.3配置 cd apr-1.6.3 vim configure cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" //此行加上注释#或者删除 //配置过程 ./configure --prefix=/usr/local/apr //编译安装过程 make && make install //apr-util-1.6.1配置 cd /usr/src/apr-util-1.6.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr //编译安装 make && make install //编译安装httpd wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.34.tar.bz2 [root@localhost ~]# ls httpd-2.4.34.tar.bz2 [root@localhost ~]# tar xf httpd-2.4.34.tar.bz2 [root@localhost ~]# cd httpd-2.4.34 [root@localhost 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@localhost httpd-2.4.34]# make && make install
注:
./configure --prefix=/usr/local/apache \ //安装路径
”--sysconfdir=/etc/httpd24 \ 配置路径
--with-mpm=prefork 可改成worker
”
虚拟主机
虚拟主机有三类:
相同IP不同端口
不同IP相同端口
相同IP不同端口不同域名
vim /etc/httpd24/httpd.conf
ServerName www.example.com:80 //取消注释(删除#) [root@localhost httpd-2.4.34]# vim /etc/httpd24/httpd.conf //进入配置,同ip,不同域名 <VirtualHost 192.168.56.11:80> ServerName www.guohui.com DocumentRoot "/usr/local/apache/htdocs/guohui" ErrorLog "logs/guohui/error_log" CustomLog "logs/guohui/access_log" combined <Directory "/usr/local/apache/htdocs/guohui"> <RequireAll> Require all granted Require not ip 192.168.1 </RequireAll> </Directory> </VirtualHost> <VirtualHost 192.168.56.11:80> ServerName www.guohui1.com DocumentRoot "/usr/local/apache/htdocs/guohui" ErrorLog "logs/guohui/error_log" CustomLog "logs/guohui/access_log" combined <Directory "/usr/local/apache/htdocs/guohui"> <RequireAll> Require all granted Require not ip 192.168.1 </RequireAll> </Directory> </VirtualHost> set nu
创建网址文件
[root@localhost httpd-2.4.34]# cd /usr/local/apache/htdocs/ [root@localhost htdocs]# mkdir guohui guohui1 [root@localhost guohui]# echo 'guo' > guohui/index.html [root@localhost guohui]# echo 'hui' > guohui1/index.html
在logs下创建文件
root@localhost ~]# cd /usr/local/apache/logs [root@localhost logs]# mkdir guohui guohui1
赋予属主属组权限
chown -R apache.apache /usr/local/apache/htdocs chown -R apache.apache /usr/local/apache/logs [root@localhost htdocs]# cd /usr/local/apache/htdocs [root@localhost htdocs]# chown -R apache.apache guohui [root@localhost htdocs]# chown -R apache.apache guohui1
启动方式
1.
[root@localhost htdocs]# /usr/local/apache/bin/apachectl start 启动 /usr/local/apache/bin/apachectl gracefu 重启服务 apachectl -t 检查
2.
/usr/local/apache/bin/httpd 启动 /usr/local/apache/bin/httpd -t 检查语法 /usr/local/apache/bin/apachectl start restart stop restart
编辑etc/host文件地点,ip+网址
windows C:\Windows\System32\drivers\etc linux etc/host curl www.guohui.com 访问 要清空浏览器缓存 -j 4 //4核速度
相关文章推荐
- linux中手工编译安装httpd服务全操作过程
- 构建httpd网站服务器(二) -- httpd服务的访问控制和基于域名、IP、端口的虚拟主机
- linux安装apache并配置根据不同的域名转发到不同的端口
- Linux入门之web服务(二)---应用实例httpd编译安装
- 在linux平台上搭建目前企业公司中基于域名,ip以及端口的虚拟主机apache服务!还有
- linux——编译安装nginx出现报错,以及启动nginx服务时80端口被占用怎么解决?
- nginx代理同一ip,不同端口,域名服务
- 在Red Hat Linux5下构建LAMP网站服务平台之编译安装Apache与配置基于域名的虚拟Web主机
- linux配置DNS服务器并基于域名IP端口配置虚拟web服务器【实验】
- 使用源码编译安装httpd服务
- 初接触linux,源码编译安装httpd
- linux下将编译安装的服务设置为开机启动
- 初识linux之编译安装httpd2.4.9
- Web服务(三)httpd参数配置以及编译安装 推荐
- linux下编译安装httpd
- linux――源码编译安装httpd ERIKXUE薛忠权
- 编写安装配置httpd服务基于域名的虚拟主机脚本
- linux下利用yum、编译安装配置apache服务
- 享受Linux中编译安装httpd的快感 "就是你了,httpd"
- linux下yum、编译安装配置apache服务