Apache服务器的配置(一)

个人web站点配置

一、 前期准备:

检测Apach是否安装

[root@localhost Desktop]# rpm -qa|grep httpd

httpd-2.2.15-29.el6_4.i686

httpd-tools-2.2.15-29.el6_4.i686

二、配置

1,若已经安装好则开启服务

[root@localhost Desktop]# service httpd start

Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName

                                                           [  OK  ]

2,测试网页

3,配置防火墙:setup

4,Apache服务停止

停止Apache服务的命令如下所示:

[root@localhost Desktop] #service  httpd  stop

5,自动加载Apache服务,有两种方法,这里用哪一种都行

(1)使用ntsysv命令,在文本图形界面对Apache自动加载(在httpd选项前按空格,加上“*”)。

(2)使用chkconfig命令自动加载。

[root@localhost Desktop] #chkconfig  --level  3  httpd  on     

#运行级别3自动加载

[root@localhost Desktop] #chkconfig  --level  3  httpd  off   

#运行级别3不自动加载

6,配置httpd文件

[root@localhost Desktop]# vi /etc/httpd/conf/httpd.conf

在UserDir disabled前面加上#注释

把UserDir public_html前的#去掉,表示用户个人目录可用

在用户家目录下面创建public_html目录,用来存放网页,linux中一般默认网页名称为index.html

[student@localhost ~]$ mkdir public_html

[student@localhost ~]$ vi public_html/index.html

之后编辑静态网页就行

7,配置权限,根据httpd.conf配置文件用户家目录的权限是711,public_html目录的权限是755

[student@localhost home]$ chmod 711 student

[student@localhost home]$ chmod 755 student/public_html

8,关闭SELIinux,两种方法都可以

查看SELinux状态:

/usr/sbin/sestatus -v      ##如果SELinux status参数为enabled即为开启状态

SELinux status:                 enabled

getenforce                 ##也可以用这个命令检查

关闭SELinux:

(1)临时关闭(不用重启机器):

setenforce 0          ##设置SELinux成为permissive模式

setenforce 1 设置SELinux成为enforcing模式

这里需要关闭,临时关闭也可以

9,其他配置

在root用户下输入

setsebool -P httpd_can_network_connect=1

配置完成之后一定要重启服务

service httpd restart

 

 

 

猜你喜欢

转载自blog.csdn.net/huiyudaoyi/article/details/26952913
今日推荐