CentOS(Linux)下Apache配置虚拟服务器

1.配置Linux+Apache+MySQL+PHP服务器;

参考了下面的链接的教程:http://www.ylmf.net/linux/tips/2011071626957.html

教程中提及的操作步骤大致上没有问题,但要注意Linux防火墙方面需要开放Http用到的80端口才能让局域网的客户机访问;

本机测试可以使用 curl命令;

curl "http://localhost:80/index.html"

2.配置虚拟服务器;

根据Apache的配置文件例子,基本上可以配置出虚拟服务器;

以下是我使用的配置信息:

#

# The following directive disables redirects on non-GET requests for

# a directory that does not include the trailing slash.  This fixes a 

# problem with Microsoft WebFolders which does not appropriately handle 

# redirects for folders with DAV methods.

# Same deal with Apple's DAV filesystem and Gnome 

#

# VirtualHost example:

# Almost any Apache directive may go into a VirtualHost container.

# The first VirtualHost section is used for requests without a known

# server name.

#

Listen 8081

NameVirtualHost *:8081

<VirtualHost *:8081>

ServerName localhost

    ServerAdmin *****@vip.qq.com

    DocumentRoot /var/www/jifun/www

    ErrorLog /var/www/jifun/ErrorLogs

    CustomLog /var/www/jifun/CustomLogs common

</VirtualHost>

<Directory "/var/www/jifun/www">

    Options FollowSymLinks

    AllowOverride None

DirectoryIndex index.html index.htm default.htm index.php default.php

Order Deny,Allow

Allow from all

</Directory>

需要注意配置正确的端口;

listen,NameVirtualHost 这些不能少;还有就是目录的权限;

配置过程需要手工建立网站的根目录, 日志文件apache启动时会自动建立;

重启apache命令

/etc/init.d/httpd restart

同样配置完成后,需要在防火墙开启相应端口;

防火墙配置文件:

vi /etc/sysconfig/iptables

如果apache启动失败

(13)Permission denied: make_sock: could not bind to address [::]:8011

(13)Permission denied: make_sock: could not bind to address 0.0.0.0:8011

no listening sockets available, shutting down

Unable to open logs

首先netsate查看网络端口是否被占用;

netstat -tnlup

其次是selinux服务引起的问题;可以关闭selinux; 

setenforce 0

关闭SELinux的方法:

修改/etc/selinux/config文件中的SELINUX="" 为 disabled ,然后重启。

如果不想重启系统,使用命令setenforce 0

注:

setenforce 1 设置SELinux 成为enforcing模式

setenforce 0 设置SELinux 成为permissive模式 

在lilo或者grub的启动参数中增加:selinux=0,也可以关闭selinux

 

 

你可能感兴趣的:(apache,centos,职场,休闲,虚拟服务器)