文档章节

centos7安装apache

vshcxl
 vshcxl
发布于 2016/03/28 13:19
字数 664
阅读 66
收藏 1

1) 卸载系统自带的httpd:
rpm -qa|grep httpd
rpm -e httpd-2.2.15-15.el6.centos --nodeps 
rpm -e httpd-tools

2)找到最新版下载链接
从http://httpd.apache.org/download.cgi找到最新版下载链接,现在最版稳定版链接是:http://mirror.bjtu.edu.cn/apache//httpd/httpd-2.2.24.tar.gz

3)开始安装Apache
cd /usr/local/src
wget http://mirror.bjtu.edu.cn/apache//httpd/httpd-2.2.24.tar.gz
tar -zxvf httpd-2.2.19.tar.gz
cd httpd-2.2.19
./configure --prefix=/usr/local/apache --enable-vhost-alias --enable-rewrite --enable-info
make
make install

4)复制初始化文件和设置Apache开机启动
cp build/rpm/httpd.init /etc/init.d/httpd
chmod 755 /etc/init.d/httpd
chkconfig --add httpd
chkconfig --level 35 httpd on

5)创建符号链接
检查/etc/init.d/httpd看所需要的文件
CONFFILE=/etc/httpd/conf/httpd.conf
httpd=${HTTPD-/usr/sbin/httpd}
pidfile=${PIDFILE-/var/log/httpd/${prog}.pid}
lockfile=${LOCKFILE-/var/lock/subsys/${prog}}

符号链接如下:
ln -s /usr/local/apache/ /etc/httpd
ln -s /usr/local/apache/bin/httpd /usr/sbin/httpd
ln -s /usr/local/apache/bin/apachectl /usr/sbin/apachectl
ln -s /usr/local/apache/logs /var/log/httpd

6)启动/停止服务
service httpd restart
service httpd start
/usr/local/apache/bin/apachectl start
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl status
/etc/init.d/httpd start
/etc/init.d/httpd stop
/etc/init.d/httpd restart

使用pgrep查找启动的进程。
pgrep httpd

7)在浏览器中查看:
http://192.168.0.120:80
如果看到it works,说明apache已经启动了。

8)apache配置文件
vi /usr/local/apache/conf/httpd.conf
更多的configure选项可参考http://httpd.apache.org/docs/2.2/programs/configure.html

9) 默认地apache配置文件中如下:

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/usr/local/apache/htdocs"

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories). 
#
# First, we configure the "default" to be a very restrictive set of 
# features. 
#
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/usr/local/apache/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>

如果你需要你的home目录可以访问,需要在documentroot下创建symbollink指向你的home,且确保home目录对所有人都有可执行权限。例如:

[AAA@Centos_AAA cgi-bin]$ ll -d /usr/local/apache/htdocs/~AAA
lrwxrwxrwx. 1 root root 9 Apr 7 09:44 /usr/local/apache/htdocs/~AAA -> /home/AAA
[AAA@Centos_AAA cgi-bin]$ ll -d /home/AAA
drwxr-xr-x. 38 AAA AAA 4096 Apr 7 11:10 /home/AAA

可以访问:http://192.168.0.120/~AAA/

完!


© 著作权归作者所有

上一篇: maven内置属性
下一篇: Linux 下Jetty 部署
vshcxl
粉丝 27
博文 282
码字总数 34755
作品 0
浦东
高级程序员
私信 提问
搭建基于http的本地yum源服务器

概述 yum相较于rpm,能够更好地解决安装软件时的依赖包问题,使用yum安装更简单更方便。搭建本地YUM源服务器,可以避免升级安装软件时占用公网带宽;有了本地YUM源服务器,可以解决无法连接I...

Zero零_度
2016/09/29
103
0
yum更换国内源、yum下载rpm包 、源码包安装

yum更换国内源 yum源默认从国外网站下载,速度相对较慢。可以更换成内容源。 步骤:ls /etc/yum.repos.d ,将CentOS-Base.repo移走或改名。 下载CentOS7-Base-163.repo文件,命令:wget http...

linux运维影魔
2018/03/03
74
0
腾讯云主机Linux Centos7系统httpd Apache HTTP server服务安装记录

博主看的安装教程是centos6.3的,发现安装时与centos7.1有许多不同,于是边查边安装,记录了这篇Centos7的安装教程。 一、安装httpd服务 apache在centos7中是Apache HTTP server。如下对htt...

尘世如潮
2016/03/21
870
3
yum更换国内源、下载rpm包,源码包安装

yum更换国内源 yum本身自带的yum是国外的地址,国内下载会比较慢。 配置163yum源 rm -f dvd.repo 删除之前默认的yum源 使用wget或curl命令后,生产新的yum源文件CentOS7-Base-163.repo 查看C...

网虫变网工
2017/11/14
0
0
redhat centos apache 403 错误 Forbidden You don't have permission to access / on this server

redhat centos apache 403 错误 centos7 apache2.2.34源码包安装成功,确认进程已启动( ps -le | grep httpd) ,防火墙已关闭,但访问时报错: Forbidden You don't have permission to a...

2char
2017/11/22
0
0

没有更多内容

加载失败,请刷新页面

加载更多

【在 Nervos CKB 上做开发】Nervos CKB 脚本编程简介[3]:自定义代币

原文作者:Xuejie 原文链接:https://xuejie.space/2019_09_06_introduction_to_ckb_script_programming_udt/ Nervos CKB 脚本编程简介[3]:自定义代币 CKB 的 Cell 模型和 VM 支持许多新的用...

NervosCommunity
54分钟前
5
0
通过OAuth2.0 获取授权访问SF 用户数据

通过OAuth2.0 获取授权访问SF 用户数据 OAuth2.0 相关知识 深入了解 Salesforce 中的 OAuth 2.0(SF官方) OAuth 2.0 的一个简单解释(阮一峰大神) OAuth 2.0 的四种方式(阮一峰大神) GitHub OA...

在山的那边
今天
7
0
编写程序:从键盘上接受一个三位数(首先要确保是三位数),计算出各位之和输出。

#include<stdio.h> int main() { int a,sum=0; printf("请输入一个三位数:\n"); scanf("%d",&a); sum=a/100+a%100/10+a%10; printf("这三个数的和:%d",sum); return 0; }......

201905021729吴建森
今天
7
0
如何离开/退出/停用Python virtualenv

我正在使用virtualenv和virtualenvwrapper。 我可以使用workon命令在virtualenv之间切换。 me@mymachine:~$ workon env1(env1)me@mymachine:~$ workon env2(env2)me@mymachine:~$ workon e......

技术盛宴
今天
7
0
成长之路 万事坚持难

任何事情开了头,想要更好的发展下去,不忘初心,就一定要坚持下去。 以前自己坚持了一些事情,比如早睡不吃东西,由于中途断了,没有及时止损,导致又接着恶习断了几天。所以 及时的反省和调...

T型人才追梦者
今天
7
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部