apache httpd.conf 配置


一 windows 环境下apche配置


1 Listen 开启监听端口。在开启虚拟端口的时候,端口要开启。一般端口8080以后可以使用

#Listen 12.34.56.78:80
Listen 80
Listen 8080
Listen 8081
Listen 8082
Listen 8083
Listen 8084
Listen 8085

#开启监听的端口

2 apache 位置

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "D:/xampps/apache"       

#apache 存放的位置

3 管理员邮箱

 #
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin postmaster@localhost

#改为自己的邮箱,实际开发中不用理会

4 服务器名

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost

#实际开发中不用修改

5 根目录权限

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>

7 文件目录权限


# 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 "D:/xampps/htdocs"   #文件路径
<Directory "D:/xampps/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.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks Includes ExecCGI


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


    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

 7 文件默认显示

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex Index.php index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
                   default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
                   home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>


8 htaccess权限

#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<Files ".ht*">
    Require all denied
</Files>


9开始虚拟模块

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

10 虚拟端口

<VirtualHost *:80>
     DocumentRoot d:/xampps/htdocs/Vcanbuy/
     #ServerName hyd.com
</VirtualHost>

11开启路由重写

LoadModule rewrite_module modules/mod_rewrite.so


二.在linux环境下配置apache  + mysql


1 监听端口在 prots.conf文件

2.虚拟主机配置在sites-avalible->000-default.conf

3 重启命令 sudo service apache2 restart;

4mysql -uroot -p

  mysql>show databases;

mysql>use dbnamel;

mysql>show tables;

mysql>exit;



apachectl(Apache control interface)

功能说明:可用来控制Apache HTTP服务器的程序。语  法:apachectl [configtest][fullstatus][graceful][help][restart][start][status][stop]补充说明:apachectl是slackware内附Apache HTTP服务器的script文件,可供管理员控制服务器,但在其他Linux的Apache HTTP服务器不一定有这个文件。参  数:  configtest   检查设置文件中的语法是否正确。  fullstatus   显示服务器完整的状态信息。  graceful   重新启动Apache服务器,但不会中断原有的连接。  help   显示帮助信息。  restart   重新启动Apache服务器。  start   启动Apache服务器。  status   显示服务器摘要的状态信息。  stop   停止Apache服务器。








评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值