在RHEL4下安装httpd2
- 格式:docx
- 大小:21.02 KB
- 文档页数:6
在Linux上搭建Web服务器的步骤在当今的数字化世界中,Web服务器作为承载和提供网页服务的重要组成部分,它的搭建对于Web应用程序的开发和部署具有至关重要的意义。
在本文中,我们将介绍在Linux操作系统上搭建Web服务器的步骤。
一、Linux环境准备1.选择合适的Linux发行版:目前常见的Linux发行版有Ubuntu、CentOS等,选择合适的发行版作为我们的Web服务器操作系统。
2.安装Linux操作系统:根据所选择的Linux发行版,进行系统的安装。
安装过程中需要设置用户名、密码等相关配置。
二、安装所需软件1.安装Apache服务器:Apache是目前最广泛使用的Web服务器软件之一。
在Linux上安装Apache可以通过包管理工具进行安装,以Ubuntu为例,命令如下:```sudo apt-get update //更新软件源sudo apt-get install apache2 //安装Apache```2.安装PHP解释器:PHP是一种广泛使用的服务器端脚本语言,用于动态生成Web页面。
同样使用包管理工具进行安装,以Ubuntu为例,命令如下:```sudo apt-get install php libapache2-mod-php //安装PHP和Apache模块```3.安装MySQL数据库:MySQL是一种开源的关系型数据库管理系统,用于存储和管理网站所需的数据。
以Ubuntu为例,命令如下:```sudo apt-get install mysql-server //安装MySQL服务器sudo mysql_secure_installation //进行安全设置```三、配置服务器1.配置Apache服务器:Apache的配置文件位于/etc/apache2目录下,通过编辑该文件可以对服务器进行相关配置。
```sudo nano /etc/apache2/apache2.conf //编辑配置文件```在配置文件中可以设置服务器的根目录、虚拟主机等信息。
每日一句:I am a slow walker, but I never walk backwards.(我走得很慢,但从来不后退。
)一、本次配置a)操作系统:Linuxb)服务器:httpd-2.4.3.tar.gzc)APR:apr-1.4.6.tar.gzd)APR-Util:apr-util-1.5.1.tar.gze)PCRE:pcre-8.31.tar.gz二、Linux安装程序的基本步骤1、./configure --prefix=安装目录2、make3、make install三、Linux安装apache服务器步骤:1、gzip -d httpd- NN.tar.gz (阿帕奇服务器安装包)2、tar xvf httpd- NN.tar(执行第一步后出现这个文件)3、cd httpd- NN(执行完第二步后会产生一个服务器的目录,使用cd命令进入)4、安装程序的基本步骤5、安装目录/bin/apachectl -k start (启动服务器)6、测试。
打开浏览器输入http://服务器IP,如果出现It Works,则服务器安装成功7、安装过程中遇到的问题a)安装服务器时提示缺少apr文件(到官网下载后进行安装(还是按照安装步骤))b)安装apr时提示确实apr-util(到官网下载后进行安装(还是按照安装步骤))c)安装服务器时提示确实pcre(到官网下载后进行安装(还是按照安装步骤))四、配置apache的虚拟主机a)将“安装目录\conf\httpd.conf ”中“#Include etc/extra/httpd-vhosts.conf ”的#去掉。
这样才能使httpd-vhosts.conf文件起作用,或者直接在httpd.conf中写配置也可以(不建议这么做)b)在httpd-vhosts.conf中配置VirtualHost(注:Apache在接受到请求时,首先会默认第一个VirtualHost,然后再找匹配的,如果没有匹配的,默认就是第一个VirtualHost起作用)<VirtualHost *:80> #主机名ServerAdmin admin@ #如果服务器有任何问题将发信到这个地址DocumentRoot /www/ #虚拟主机的指向目录ServerName #访问主机的域名[:端口号]ServerAlias * #- -这个不知道是啥。
Linux下Apache的安装与配置⼀、编译安装1、解决依赖关系⼆、后续操作1、启动httpd两种⽅法:第⼀种、/usr/local/apache/bin/apachectl start第⼆种⽅法:先修改http.pid⽂件位置打开配置⽂件增加⼀⾏vim /etc/httpd/httpd.conf 增加PidFile “/var/run/httpd.pid”为了启动httpd更加⽅便,#!/bin/bash## httpd Startup script for the Apache HTTP Server## chkconfig: - 85 15# description: Apache is a World Wide Web server. It is used to serve \# HTML files and CGI.# processname: httpd# config: /etc/httpd/conf/httpd.conf# config: /etc/sysconfig/httpd# pidfile: /var/run/httpd.pid# Source function library.. /etc/rc.d/init.d/functionsif [ -f /etc/sysconfig/httpd ]; then. /etc/sysconfig/httpdfi# Start httpd in the C locale by default.HTTPD_LANG=${HTTPD_LANG-"C"}# This will prevent initlog from swallowing up a pass-phrase prompt if# mod_ssl needs a pass-phrase from the user.INITLOG_ARGS=""# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server# with the thread-based "worker" MPM; BE WARNED that some modules may not# work correctly with a thread-based MPM; notably PHP will refuse to start.# Path to the apachectl script, server binary, and short-form for messages.apachectl=/usr/local/apache/bin/apachectlhttpd=${HTTPD-/usr/local/apache/bin/httpd}prog=httpdpidfile=${PIDFILE-/var/run/httpd.pid}lockfile=${LOCKFILE-/var/lock/subsys/httpd}RETVAL=0start() {echo -n $"Starting $prog: "LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONSRETVAL=$?echo[ $RETVAL = 0 ] && touch ${lockfile}return $RETVAL}stop() {echo -n $"Stopping $prog: "killproc -p ${pidfile} -d 10 $httpdRETVAL=$?echo[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}}reload() {echo -n $"Reloading $prog: "if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; thenRETVAL=$?echo $"not reloading due to configuration syntax error"failure $"not reloading $httpd due to configuration syntax error"elsekillproc -p ${pidfile} $httpd -HUPRETVAL=$?fiecho}# See how we were called.case "$1" instart)start;;stop)stop;;status)status -p ${pidfile} $httpdRETVAL=$?;;restart)stopstart;;condrestart)if [ -f ${pidfile} ] ; thenstopstartfi;;reload)reload;;graceful|help|configtest|fullstatus)$apachectl $@RETVAL=$?;;*)echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}" exit 1esacexit $RETVAL将以上代码加⼊到vim /etc/init.d/httpd中⽽后为此脚本赋予执⾏权限:chmod +x /etc/rc.d/init.d/httpd加⼊服务列表:chkconfig --add httpd给3,5启动chkconfig --level 3,5 httpd on最后加路径将 export PATH=$PATH:/usr/local/apache/binvim /etc/profile.d/httpd.sh完成后重新登录就可以了。
APACHE安装配置说明⼀、软件下载⼆、环境检查# rpm -qa|grep zlibzlib-devel-1.2.3-3zlib-1.2.3-3# rpm -qa|grep sslopenssl-devel-0.9.8b-10.el5openssl-0.9.8b-10.el5如果需要依赖包,安装其对应的devel包即可,此处仅⽤到zlib和ssl。
另,如果有httpd包,要先卸载掉或停⽌其服务。
三、编译安装1、针对安装⽬的的说明(来⾃INSTALL⽂件)如果是开发者则使⽤此选项,--with-included-apr利于连接apache的代码或者是调试apache,其消除了由于版本或者编译中跟APR或者APR-util代码产⽣的不匹配;如果从⼦版本编译apache,要先运⾏buildconf(需要Python,GNU autoconf和libtool),然后运⾏configure。
发⾏包不⽤。
如果要在FreeBSD5.4之前编译时包含apache的threaded MPM,需要使⽤--enable-threads和--with-mpm 参数在Mac上编译⼦版本,要使⽤GNU Libtool 1.4.2及以上版本2、关于SSL加密和正则表达式(来⾃⽂件README)Apache2.0及以上版本在⽬录modules/ssl/下包含了mod_ssl模块⽤于配置和监听ssl⽹络接⼝的连接。
(另外,⼀些apr-util版本在⽬录srclib/apr-util/ssl/下提供了ssl⽹络接⼝)带有单词crypto的包的名字,可能包含openssl加密库的⽬标代码。
如果apache的加密功能不理想或者要排除再重分配,则可以使⽤包的名字包含nossl的发布包。
Apache使⽤PCRE包包含的正则表达式。
3、对configure参数的说明配置帮助表:-h, --help显⽰帮助信息display this help and exit--help=short ⽤short参数将只显⽰正在运⾏的当前脚本的选项,⽽不能列出适⽤于Apache配置脚本所运⾏的外部配置脚本的选项display optionsspecific to thispackage--help=recursive 使⽤recursive参数将显⽰所有程序包的简短描述display the shorthelp of all theincluded packages-V, --version显⽰版本display version information and exit-q, --quiet, --silent不显⽰checking……信息do notprint`checking...' messages--cache-file=FILE在指定⽂件中存储测试结果cache test results in FILE [disabled]-C, --config-cache 在⽂件config.cache中存储测试结果alias for `--cachefile=config.cache'-n, --no-create configure脚本运⾏结束后不输出结果⽂件,常⽤于正式编译前的测试。
实训项目11 Apache服务器的架设一. 实训目的:1.掌握Apache的基本配置2.启动和停止Apache3.为系统用户配置自己的站点4.掌握架设Web服务器的方法二. 实训内容1.安装运行apache2.配置个人用户的Web站点三. 实训环境:1.1台具有Linux虚拟机的计算机,已经正确配置网络参数,能够和192.168.1网络中的其它主机相互通信。
四. 实训步骤1.安装apache服务器,启动默认www服务。
步骤1:安装Apache软件包。
(1)查看系统是否已经安装Apache软件包。
#rpm -qa | grep httpd(2)如果没有安装则执行下面的步骤进行安装(软件包文件在第一张Linux安装光盘中):#eject#mount /media/cdrom/#cd /media/cdrom/RedHat/RPMS/#rpm –ivh httpd-2.0.52-9.ent.i386.rpm#rpm –ivh httpd-manual-2.0.52-9.ent.i386.rpm#cd;eject步骤2:编辑Apache服务器的配置文件httpd.conf,启动默认的www服务。
(1)编辑配置文件httpd.conf,设置服务器名称#vi /etc/httpd/conf/httpd.conf修改如下内容:(注:设置服务器名称,此处xxx表示你的Apache服务器IP地址中的主机号。
(2)启动Apache服务。
#service httpd start步骤3:在默认Web站点的根目录/var/www/html中创建一个首页文件。
#cd /var/www/html#echo “Welcome to our Web Site” > /var/www/html/index.html 步骤4:在客户机的浏览器中访问该默认站点。
在Windows的浏览器地址栏中输入http://192.168.1.xxx,观察其结果是否正确。
apache2 实用安装与配置1.Apache 的安装Apache 的安装无外乎两种方式: 源代码安装和DEB包安装。
这两种安装类型各有特色,DEB包安装不需要编译,而源代码安装则需要先配置编译再安装,DEB包安装在一个固定的位置下,选择固定的模块,而源代码安装则可以让你选择安装路径,选择你想要的模块。
本文主要介绍DEB安装方式。
系统:GNU/Linux Debian/etchApache当前版本: 2.0.55-41.1 1. 安装:使用以下命令安装:tony@tonybox:~$sudo aptitude updatetony@tonybox:~$sudo aptitude install apache2 apache2-utils其中apache2-utils提供了我们在配置维护过程中非常有用的一些工具安装完成后,可以使用下面的命令启动Apache 服务:tony@tonybox:~$ sudo /etc/init.d/apache2 start停止Apache服务则是:tony@tonybox:~$ sudo /etc/init.d/apache2 stop也可以只接用kill 命令强制杀死apache2进程tony@tonybox:~$ sudo killall apache2如有需要, 可以通过rcconf来控制是否在系统启动是加载Apache 服务启动完成后打开浏览器, 使用URL http://localhost/ 来访问已经启动的Apache服务器, 服务器将会将会跳转到http://localhost/apache2-default/, 向浏览器返回一个Apache安装成功的页面.注: 这取决于/etc/apache2/sites-available/default 配置文件中, 是否取消了RedirectMatch ^/$ /apache2-default/行的注释1.22. 配置文件说明在Debian下, 安装完成后, 软件包为我们提供的配置文件位于/etc/apache2目录下:tony@tonybox:/etc/apache2$ ls -ltotal 72-rw-r--r-- 1 root root 12482 2006-01-16 18:15 apache2.confdrwxr-xr-x 2 root root 4096 2006-06-30 13:56 conf.d-rw-r--r-- 1 root root 748 2006-01-16 18:05 envvars-rw-r--r-- 1 root root 268 2006-06-30 13:56 httpd.conf-rw-r--r-- 1 root root 12441 2006-01-16 18:15 magicdrwxr-xr-x 2 root root 4096 2006-06-30 13:56 mods-availabledrwxr-xr-x 2 root root 4096 2006-06-30 13:56 mods-enabled-rw-r--r-- 1 root root 10 2006-06-30 13:56 ports.conf-rw-r--r-- 1 root root 2266 2006-01-16 18:15 READMEdrwxr-xr-x 2 root root 4096 2006-06-30 13:56 sites-availabledrwxr-xr-x 2 root root 4096 2006-06-30 13:56 sites-enableddrwxr-xr-x 2 root root 4096 2006-01-16 18:15 ssl其中apache2.conf为apache2服务器的主配置文件, 查看此配置文件, 你会发现以下内容# Include module configuration:Include /etc/apache2/mods-enabled/*.loadInclude /etc/apache2/mods-enabled/*.conf# Include all the user configurations:Include /etc/apache2/httpd.conf# Include ports listingInclude /etc/apache2/ports.conf# Include generic snippets of statementsInclude /etc/apache2/conf.d/[^.#]*有此可见, apache2 根据配置功能的不同, 对配置文件进行了分割, 这样更利于管理conf.d下为配置文件的附加片断,默认情况下, 仅提供了charset 片断,tony@tonybox:/etc/apache2/conf.d$ cat charsetAddDefaultCharset UTF-8如有需要我们可以将默认编码修改为GB2312, 即文件的内容为: AddDefaultCharset GB2312httpd.conf是个空文件magic文件中包含的是有关mod_mime_magic模块的数据, 一般不需要修改它.ports.conf则为服务器监听IP和端口设置的配置文件,tony@tonybox:/etc/apache2$ cat ports.confListen 80mods-available目录下是一些.conf和.load 文件, 为系统中可以使用的加载各种模块的配置文件, 而mods-enabled目录下则是指向这些配置文件的符号连接, 从配置文件apache2.conf 中可以看出, 系统通过mods-enabled目录来加载模块, 也就是说, 系统仅通过在此目录下创建了符号连接的mods-available 目录下的配置文件来加载模块。
在Linux下配置Apache服务器——江湖、孙中霞、李琴一、实验目的完成本次实训,将能够:●配置基本的Apache服务器●配置个人用户Web站点。
●配置虚拟目录别名功能。
●配置主机访问控制。
●配置用户身份验证功能.。
●配置基于IP地址的虚拟主机.二、实验环境1、RedHat Linux4AS.2、Apache 2.0三、实验内容1.配置基本的Apache服务器2.配置个人用户Web站点。
3.配置虚拟目录别名功能。
4.配置主机访问控制。
5.配置用户身份验证功能.。
6.配置基于IP地址的虚拟主机。
四、实验要求在Linux操作系统下配置Apache服务器。
五、注意事项1.在修配置文件下注意区分大小写、空格。
2.在每次重新开机后都必须启动Apachec服务器。
3.在每次修改完主配置文件后保存起来,必须重启Apachec服务器,如果不重启会导致配置无效,最终导致实验失败。
六、实验步骤1、检测是否安装了Apache软件包:A、首先为服务器网卡添加一个固定的IP地址。
B、在Web浏览器的地址栏中输入本机的IP地址,若出现Test Page测试页面(该网页文件的默认路径为var/www/html/index.html)如下图1所示就说明Apache已安装并已启动。
另一种方法是使用如下命令查看系统是否已经安装了Apache软件包:[root@rhe14~]# rpm –aq | grep httpdHttpd-suexec-2.0.52-9.entHttpd-manual-2.0.52-9.entSystem-config-httpd-1.3.1-1Httpd-devel-2.0.52-9.ent出现以上内容表明了系统已安装Apache软件包。
2、安装Apache软件包超级用户(root)在图形界面下选择“应用程序”|“系统设置”|“添加/删除应用程序”命令,选择“万维网服务器”软件包组,在单击“更新”按钮就可以安装与Apache相关的软件包。
httpd 的 3 种 MPM 工作模式MPM 是 Multi-Processing Modules,表示 Apache 中的多路处理模块,目前在 Linux 上的 Apache 2.2/2.4 中包括三种模式:prefork、worker 和 event 模式。
一 HTTPD 不同安装方式对比rpm 安装方式 httpd-2.2.15 默认运行 方式 影响运行 方式的因 素 安装了 3 种方式,以 prefork 默认 若编辑/etc/sysconfig/httpd 文 件 , 将 “ HTTPD=/usr/sbin/httpd.wor ker ” 注 释 取 消 , 则 再 重 启 将 以 worker 形式运行。
/usr/sbin/下有 3 个文件:httpd, httpd.event 和 httpd.worker. 以哪个文件运行就是那种模式。
因此可 以修改/etc/sysconfig/httpd 文 件或者修改 /usr/sbin/ 下的文件名 进行切换模式。
主 配 置 文 件 /etc/httpd/conf/httpd.conf 中 /etc/httpd/httpd.conf 文 件 里 LoadModule mpm_event_module modules/mod_mpm_event.so 源码编译安装 httpd-2.4.4 编译时可以选择编译哪种方式, 也可以 3 种全装。
默认是 event决定运行 方式的因 素mpm 参数/etc/httpd/extra/httpd-mpm. conf 文件中二 rpm 方式安装后的相关配置在一些发行版的 Apache 安装时, 可能不仅安装了 prefork 模式的 httpd, 也可能安装有 worker/event 模式的 httpd 供用户根据实际需要来选择。
比如 RHEL6.4 中的 httpd 安装包就是同时提供了 worker 和 event 模式的 httpd 程序,如下所示: # /usr/sbin/httpd.worker -l Compiled in modules: core.c worker.c http_core.c mod_so.c # /usr/sbin/httpd.event -l Compiled in modules: core.c event.c http_core.c mod_so.c 在 RHEL 系统中,可以很容易地配置 httpd 服务对 prefork、worker 和 event 等 3 种模式来进行选择。
Linux——搭建Apache(httpd)服务器⼀、基本概念Apache(或httpd)是Internet上使⽤最多的Web服务器技术之⼀,使⽤的传输协议是http超⽂本传输协议(⼀个基于超⽂本的协议),⽤于通过⽹络连接来发送和接受对象。
有两个版本:http:超⽂本传输协议,通过线路以明⽂形式发送,默认情况下使⽤80/TCP(也可以使⽤其他端⼝)https:经TLS/SSL安全加密的超⽂本传输协议,默认情况下使⽤端⼝443/TCP⼆、了解Apache的配置⽂件1、配置⽂件的分类在Linux系统中配置服务,其实就是修改服务的配置⽂件,httpd服务程序的主要配置⽂件及存放位置如下:配置⽂件的名称存放位置服务⽬录/etc/httpd主配置⽂件/etc/httpd/conf/httpd.conf虚拟主机配置⽂件/etc/httpd/conf.d⽇志⽂件/etc/httpd/logs⽹站数据⽬录/var/www/html2、主配置⽂件的重要参数主配置⽂件/etc/httpd/conf/httpd.conf参数⽤途ServerRoot服务⽬录ServerAdmin管理员邮箱User运⾏服务的⽤户Group运⾏服务的⽤户组ServerName⽹站服务器的域名DocumentRoot⽂档根⽬录(⽹站数据⽬录)Directory⽹站数据⽬录的权限Listen监听的IP地址与端⼝号DirectoryIndex默认的索引页页⾯ErrorLog错误⽇志⽂件CustomLog访问⽇志⽂件Timeout⽹页超时时间,默认为300秒3、Directory标签<Directory "/var/www/html">AllowOverride None #设置.htaccess⽂件中的指令类型,None表⽰禁⽌使⽤.htaccess,该参数⼀般不改Require all granted #设置权限,默认开启所有客户机访问权限</Directory>三、如何配置Apache服务器⾸先准备:主机名、⽹络、yum源1、更改主机名:[root@localhost ~]# hostnamectl set-hostname $主机名[root@localhost ~]# bash #环境变量重载2、配置⽹络(1)虚拟交换机、⽹络适配器选择仅主机模式,并且配置为192.168.100.0⽹段;(2)编辑⽹络配置⽂件:[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33修改: BOOTPROTO=static #改为静态IP地址ONBOOT=yes #改为开机⾃启IPADDR=192.168.100.10PREFIX=24 或者 NETMASK=255.255.255.0(3)重启⽹络服务:[root@localhost ~]# systemctl restart network3、配置yum源(1)先在VMware⾥⾯把系统镜像⽂件连接到虚拟机的光驱上;(2)挂载光驱⾥的镜像:[root@localhost ~]# mount /dev/cdrom /media(3)修改yum源配置⽂件:[root@localhost ~]# vim /etc/yum.repos.d/local.repo[rhel]name=rhelbaseurl=file:///mediaenabled=1gpgcheck=0(4)清空yum源缓存信息:[root@localhost ~]# yum clean all(5)检索当前yum源信息:[root@localhost ~]# yum repolist任务⼀:配置简单的httpd服务1、安装httpd服务[root@server ~]# yum -y install httpd2、启动httpd服务[root@server ~]# systemctl restart httpd[root@server ~]# systemctl enable httpd3、配置防⽕墙[root@server ~]# firewall-cmd --permanent --add-service=http[root@server ~]# firewall-cmd --reload4、关闭SELinux[root@server ~]# setenforce 05、客户端测试[root@client ~]# firefox http://IP地址或者 curl http://IP地址任务⼆:配置基于⽤户的个⼈⽹站注意:该⽤户必须在Linux系统中存在1、新建⼀个⽤户(⽹站基于该⽤户)[root@server ~]# useradd user0[root@server ~]# passwd user02、修改⽤户的家⽬录权限,使其他⽤户具有读取和执⾏的权限[root@server ~]# chmod -R 705 /home/user03、创建存放⽤户个⼈主页空间的⽬录,写user0的⽹页⽂件[root@server ~]# mkdir /home/user0/public_html[root@server ~]# cd /home/user0/public_html[root@server ~]# echo "this is user0's web">>index.html4、修改基于⽤户的httpd配置⽂件[root@server ~]# vim /etc/httpd/conf.d/userdir.conf修改: UserDir enabled #开启,表⽰让httpd服务程序开启个⼈⽤户主页功能UserDir public_html #去注释,UserDir参数表⽰⽹站数据在⽤户家⽬录中的保存⽬录名称5、配置防⽕墙(同上)[root@server ~]# firewall-cmd --permanent --add-service=http[root@server ~]# firewall-cmd --reload6、修改selinux权限[root@server ~]# getsebool -a|grep home[root@server ~]# setsebool httpd_enable_homedirs on7、重启服务[root@server ~]# systemctl restart httpd8、客户端测试[root@client ~]# firefox http://IP地址/~username 或者curl http://IP地址/~username任务三:配置基于域名访问的虚拟主机1、新建虚拟主机的⽹页⽂件[root@server ~]# mkdir /www/one /www/two[root@server ~]# cd /www/one[root@server ~]# echo "this is a web for virtual host one">>index.html[root@server ~]# cd /www/two[root@server ~]# echo "this is a web for virtual host two">>index.html[root@server ~]# chmod o+x /www2、配置虚拟主机的⽂件[root@server ~]# cd /etc/httpd/conf.d[root@server ~]# vim vhost.conf<Directory /www/one> #设置⽹站⽬录权限Require all granted #开启所有客户机访问权限</Directory><VirtualHost 192.168.100.10> #虚拟主机ServerName #定义服务器名称DocumentRoot /www/one/ #⽹站数据⽬录</VirtualHost><Directory /www/two>Require all granted</Directory><VirtualHost 192.168.100.11>ServerName DocumentRoot /www/two/</VirtualHost>3、做域名解析⽂件server/client[root@server ~]# vim /etc/hosts192.168.100.10 192.168.100.11 4、配置防⽕墙(同上)[root@server ~]# firewall-cmd --permanent --add-service=http[root@server ~]# firewall-cmd --reload5、修改虚拟主机⽹页⽂件的selinux上下⽂类型[root@server ~]# semanage fcontext -a -t httpd_sys_content_t '/www(/.*)?'[root@server ~]# restorecon -RFv /www6、重启服务[root@server ~]# systemctl restart httpd任务四:配置基于端⼝访问的虚拟主机1——新建虚拟主机的⽹页⽂件[root@server ~]# mkdir /www/8088[root@server ~]# echo "this is a web for port 8088 ">>index.html[root@server ~]# mkdir /www/8089[root@server ~]# echo "this is a web for port 8089 ">>index.html2——配置虚拟主机的⽂件[root@server ~]# cd /etc/httpd/conf.d[root@server ~]# vim vhost.conf<Directory /www/8088/>Require all granted</Directory><virtualHost 192.168.100.10:8088>DocumentRoot /www/8088/</virtualHost><Directory /www/8089/>Require all granted</Directory><virtualHost 192.168.100.10:8089>DocumentRoot /www/8089/</virtualHost>3、配置防⽕墙[root@server ~]# firewall-cmd --permanent --zone=public --add-port=8089/tcp[root@server ~]# firewall-cmd --permanent --zone=public --add-port=8088/tcp[root@server ~]# firewall-cmd --reload4、关闭SELinux[root@server ~]# setenforce 05、重启服务[root@server ~]# systemctl restart httpd6、使⽤浏览器访问任务五:配置基于TLS加密的虚拟主机注意:经TLS/SSL安全加密的超⽂本传输协议,默认情况下使⽤端⼝443/TCP 1、安装TLS加密软件,⽹站内容不⽤明⽂传输[root@server ~]# yum -y install mod_ssl2、⽣成密钥[root@server ~]# openssl genrsa >tlsweb.key3、⽣成证书请求⽂件[root@server ~]# openssl req -new -key tlsweb.key > tlsweb.csr4、⽣成证书⽂件[root@server ~]# openssl req -x509 -days 365 -key tlsweb.key -in tlsweb.csr >tlsweb.crt5、修改ssl.conf配置⽂件[root@server ~]# vim /etc/httpd/conf.d/ssl.confSSLCertificateFile /etc/pki/tls/certs/tlsweb.crtSSLCertificateKeyFile /etc/pki/tls/private/tlsweb.key6、把证书⽂件拷贝到ssl.conf配置⽂件⾥的对应路径下⾯[root@server ~]# cp tlsweb.crt /etc/pki/tls/certs/7、把秘钥⽂件拷贝到ssl.conf配置⽂件⾥的对应路径下⾯[root@server ~]# cp tlsweb.key /etc/pki/tls/private/。
在RHEL4下安装httpd2.2+mysql5+php5+svn1.5.4+svnmanager1.04全过程RHELRHEL本文档记载了在redhat enterprise linux as4(RHEL4)下安装httpd2.2+mysql5+php5+svn1.5.4+svnmanager1.04的全过程除了mysql是以rpm包安装的以外,其他都是编译安装,所以对其他linux及unix操作系统下安装svn和svnmanager也有一定参考作用,供新手参考,不当之处欢迎大家提出。
对于rhel5或者centos5,我推荐用rpm或者yum直接装,在rhel4上是没办法解决一些依赖关系以及php,svn等没有合适的版本所以编译安装-1.下载所有需要的安装文件httpd-2.2.11.tar.gzMySQL-test-community-5.1.30-0.rhel4.i386.rpmMySQL-client-community-5.1.30-0.rhel4.i386.rpmMySQL-community-debuginfo-5.1.30-0.rhel4.i386.rpmMySQL-devel-community-5.1.30-0.rhel4.i386.rpmMySQL-server-community-5.1.30-0.rhel4.i386.rpmMySQL-shared-community-5.1.30-0.rhel4.i386.rpmMySQL-shared-compat-5.1.30-0.rhel4.i386.rpmphp-5.2.8.tar.gzVersionControl_SVN-0.3.1.tgzXML_Parser-1.0.tgzXML_Parser-1.3.2.tgz/subversion-1.5.4.tar.gzsubversion-deps-1.5.4.tar.gz/svnmanager-1.04.tar.gz0.卸载原有httpd,mysql,php卸载顺序为php,mysql,httpd,首先使用rpm -qa | grep找到所有相关的包,然后用rpm -e 看依赖关系,最后用rpm -e 卸掉所有相关的包。
[root@localhost ~]# rpm -qa | grepphpphp-4.3.9-3.15php-ldap-4.3.9-3.15php-pear-4.3.9-3.15[root@localhost ~]# rpm -e phperror: Failed dependencies:php = 4.3.9-3.15 is needed by (installed) php-ldap-4.3.9-3.15.i386php = 4.3.9-3.15 is needed by (installed) php-pear-4.3.9-3.15.i386[root@localhost ~]# rpm -e phpphp-ldapphp-pear[root@localhost ~]# rpm -qa | grepmysqlmysql-4.1.20-1.RHEL4.1mysqlclient10-3.23.58-4.RHEL4.1[root@localhost ~]# rpm -e mysqlerror: Failed dependencies:libmysqlclient.so.14 is needed by (installed) cyrus-sasl-sql-2.1.19-5.EL4.i386[root@localhost ~]# rpm -e cyrus-sasl-sqlmysql mysqlclient10[root@localhost ~]# rpm -qa | grep httphttpd-manual-2.0.52-25.enthttpd-2.0.52-25.enthttpd-suexec-2.0.52-25.entsystem-config-httpd-1.3.1-1[root@localhost ~]# rpm -e httpderror: Failed dependencies:httpd-mmn = 20020903 is needed by (installed) mod_perl-1.99_16-4.i386httpd-mmn = 20020903 is needed by (installed) mod_python-3.1.3-5.1.i386httpd-mmn = 20020903 is needed by (installed) mod_ssl-2.0.52-25.ent.i386webserver is needed by (installed) webalizer-2.01_10-25.i386httpd = 2.0.52-25.ent is needed by (installed) httpd-manual-2.0.52-25.ent.i386httpd = 2.0.52-25.ent is needed by (installed) httpd-suexec-2.0.52-25.ent.i386httpd>= 2.0.40 is needed by (installed) mod_perl-1.99_16-4.i386httpd>= 2.0.40 is needed by (installed) mod_python-3.1.3-5.1.i386httpd = 2.0.52-25.ent is needed by (installed) mod_ssl-2.0.52-25.ent.i386httpd is needed by (installed) system-config-httpd-1.3.1-1.noarch[root@localhost ~]# rpm -e system-config-httpdmod_sslmod_pythonmod_perlhttpd-suexechttpd-manual webalizerhttpd1.rpm安装MySQLrpm -ivh MySQL-server-community-5.1.30-0.rhel4.i386.rpmrpm -ivh MySQL-client-community-5.1.30-0.rhel4.i386.rpmrpm -ivh MySQL-community-debuginfo-5.1.30-0.rhel4.i386.rpmrpm -ivh MySQL-devel-community-5.1.30-0.rhel4.i386.rpmrpm -ivh MySQL-shared-community-5.1.30-0.rhel4.i386.rpmrpm -ivh MySQL-test-community-5.1.30-0.rhel4.i386.rpm2.编译安装httpd(必须编译安装,rpm包会导致后面的svn无法编译成功)tar -xzvf httpd-2.2.11.tar.gzcd httpd-2.2.11./configure --enable-module=so --enable-dav --enable-dav-fs --enable-dav --enable-so --prefix=/usr/local/apache2makemake install将apache设为开机自动启动cp /usr/local/apache2/bin/apachectl /etc/init.d/httpdvi /etc/init.d/httpd在第一行#!/bin/sh下增加两行文字如下# chkconfig: 35 70 30# description: Apache接着注册该服务chkconfig --add httpdchkconfighttpd on3.编译安装php5,svnmanager需要php5,而php5在rhel4下无rpm包,只能编译安装tar -zxvf php-5.2.8.tar.gz./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-zlib --with-gd --with-pear --enable-force-cgi-redirect --with-config-file-path=/etc/(with-pear这个选项必须打开,后面装svnmanager有用)makemake installcp php.ini-dist /etc/php.inivi /etc/php.iniinclude_path = ".:/usr/local/php/lib/php"vi /etc/profilepathmunge /usr/local/apache2/bin afterpathmunge /usr/local/php/bin aftervi /usr/local/apache2/conf/httpd.conf可以看到LoadModule php5_module modules/libphp5.so说明php模块已经添加#AddType application/x-gzip .gz .tgz下加二行AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps解析php用DirectoryIndex index.html 改为DirectoryIndex index.html index.php自动打开目录下的index.php4.测试phpvi /usr/local/apache2/htdocs/test.phpphpinfo();?>/usr/local/apache2/bin/apachectl starthttp://168.68.8.184/http://168.68.8.184/test.php5.安装neon和serf模块,让svn能够访问http模式tar -zxvf subversion-deps-1.5.4.tar.gzcd subversion-1.5.4cd neon./configuremakemake installcd serf./configure --with-apr=/usr/local/apache2 --with-apr-util=/usr/local/apache2makemake install6.编译安装svn,svn1.5.4没有合适rhel4的rpm包,而比较低级的svn1.5.1又会有rpm依赖关系导致svnmanager安装不成功。