Linux下Apache服务器搭建

简介:    Apache服务架设心得(WEB服务管理器) 
环境:RHEL5.3,DNS已经配置好为:www.station53.com

一、Apache服务总览: 
1、所需要的软件包:httpd httpd-devel httpd-manual
2、端口:80(http) 443(https)
3、主配置文件:/etc/httpd/*
4、默认主页目录:/var/www/html
5、与Apache服务相关的Selinux环境:
1)system_u:object-r:httpd_config_t  /etc/httpd/conf和/etc/httpd/conf.d 下的文件
2)system_u:object_r:httpd_log_t /etc/httpd/logs中的日志文件。
3)system_u:object_r:httpd_modules_t httpd服务使用的相关模块
4)网页内容及网页目录的环境:  System_u:object_r:httpd_sys_content_t:如果不是这个页面将无法访问。
另:对于目录,Other组要有访问和可执行权限。
设置Selinux环境:  Chcon -R —reference=/var/www/html /var/www/html/data Restorecon -R /var/www/html 
建议网站目录都放到/var/www/html防止因为Selinux造成问题。

二、Apache配置文件的简单实现: 
1、 相关配置文件修改:/etc/httpd/conf/httpd.conf
1)、ServerRoot”/etc/httpd” 默认配置文件的存放目录;
2)、Timeout 120 客户端访问超时时间120秒;
3)、Listen 80 监听80端口; 
4)、ServerAdmin [email protected] 设置管理员邮箱; 
5)、ServerName www.station53.com服务器主机名,可以使DNS域名,也可以是IP地址; 6)、DocumentRoot /var/www/html 网页默认存放目录;
7)、DirectoryIndex index.html index.htm 设置主页文件的名字;
2、建立主页文件:  在/var/www/html目录建立主页文件index.html并写上写内容。
3、启动相关服务: chkconfig httpd on service httpd restart
4、测试自己的服务器:

三、用户个人主页的实现:

通过配置使我们每个用户都有一个主页可以通过http://www.station53.com/~Username访问的主页。   

1.运用命令: 
apahce启动命令:  推荐/usr/local/apache2/bin/apachectl start apaceh启动  
apache停止命令  /usr/local/apache2/bin/apachectl stop 停止  
apache重新启动命令:  /usr/local/apache2/bin/apachectl restart 重启  
要在重启 Apache 服务器时不中断当前的连接,则应运行:   /usr/local/sbin/apachectl graceful   

2.如果apache安装成为linux的服务的话,可以用以下命令操作:  
service httpd start 启动  
service httpd restart 重新启动  
service httpd stop 停止服务

猜你喜欢

转载自cdhychen.iteye.com/blog/2242066