需求背景:
在一个系统中直接查看任务运行的日志,所以想让放日志的目录能够直接以URL的方式访问.就用了apache
版本:
2.4.18
准备:
http://apr.apache.org/download.cgi 下载apr-1.5.2.tar.gz、apr-util-1.5.4.tar.gz
http://sourceforge.net/projects/pcre/files/pcre/ 下载 pcre
安装
1.安装apr
1 [root@localhost]# tar -zxf apr-1.5.2.tar.gz 2 [root@localhost apr-1.5.2]# ./configure --prefix=/opt/apr 3 [root@localhost apr-1.5.2]# make 4 [root@localhost apr-1.5.2]# make install
2.安装apr-util
1 [root@localhost]# tar -zxf apr-util-1.5.4.tar.gz 2 [root@localhost apr-util-1.5.4]# ./configure --prefix=/opt/apr-util -with-apr=/opt/apr/bin/apr-1-config 3 [root@localhost apr-util-1.5.4]# make 4 [root@localhost apr-util-1.5.4]# make install
3. 安装 pcre
1 [root@localhost ~]# tar xvf pcre-8.38.tar.bz2 2 [root@localhost ~]# cd pcre-8.38 3 [root@localhost pcre-8.38]# ./configure --prefix=/opt/pcre 4 [root@localhost pcre-8.38]# make 5 [root@localhost pcre-8.38]# make install
4. 安装 httpd
#tar xvf httpd-2.4.18.tar.gz #cd httpd-2.4.18 #./configure --prefix=/opt/apache2 --with-apr=/opt/apr --with-apr-util=/opt/apr-util/ --with-pcre=/opt/pcre #make #make install
配置
需要把日志文件夹发布,修改httpd.conf 文件,找到 <IfModule alias_module> 标签,添加红色的部分.
$ vim apache2/conf/httpd.conf <IfModule alias_module> # # Redirect: Allows you to tell clients about documents that used to # exist in your server's namespace, but do not anymore. The client # will make a new request for the document at its new location. # Example: # Redirect permanent /foo http://www.example.com/bar # # Alias: Maps web paths into filesystem paths and is used to # access content that does not live under the DocumentRoot. # Example: # Alias /webpath /full/filesystem/path # # If you include a trailing / on /webpath then the server will # require it to be present in the URL. You will also likely # need to provide a <Directory> section to allow access to # the filesystem path. # # ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that # documents in the target directory are treated as applications and # run by the server when requested rather than as documents sent to the # client. The same rules about trailing "/" apply to ScriptAlias # directives as to Alias. # ScriptAlias /cgi-bin/ "/opt/apache2/cgi-bin/" Alias /jobServer "/work/ad/addata/job-executor/log" <Directory "/work/ad/addata/job-executor/log"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> </IfModule>
启动Apache服务: /opt/apache2/bin/apachectl start
在浏览器 ip:5444/jobServer 即可访问该目录下内容.
关闭服务: /opt/apache2/bin/apachectl stop
重启服务: /opt/apache2/bin/apachectl restart
参考:
http://www.cnblogs.com/lzrabbit/archive/2013/03/05/2944804.html