apache  在linux下命令

2. 编译Apache 在src目录下 ./configure 可用 ./configure--help|less 得到帮助, make, make install, install

3. apache的启动和关闭 sbin/apachectl start sbin/apachectl stop sbin/apachectl restart (重起)

源文档 <http://codex.wordpress.org.cn/Apache_%BC%F2%BD%E9%BC%B0%BB%F9%B1%BE%C5%E4%D6%C3>

http://codex.wordpress.org.cn/Apache_%BC%F2%BD%E9%BC%B0%BB%F9%B1%BE%C5%E4%D6%C3

    1. 重启Apache(httpd)服务:   service httpd restart
    2. 重新启动apache服务器:   apachectl restart
    3. 启动Apache服务器:            apachectl start
    4. 停止Apache服务器:            apachectl  stop
    5. apachectl     [ configtest -> 检查设置文件中的语法是否正确]

[fullstatus  -> 显示服务器完整的状态信息 ]

[graceful  ->重启Apache服务器,但不会中断原有的连接]

start/stop              ::      /usr/local/apache2/bin/apachectl (start|restart|graceful|graceful-stop|stop|configtest)

最常用的Apache路径有:

/etc/httpd/conf/httpd.conf

/usr/local/apache/conf/httpd.conf

/usr/local/apache2/conf/httpd.conf

Apache 2.2 default layout (apache.org source package):

ServerRoot              ::      /usr/local/apache2

DocumentRoot            ::      /usr/local/apache2/htdocs

Apache Config File      ::      /usr/local/apache2/conf/httpd.conf

Other Config Files      ::      /usr/local/apache2/conf/extra/

SSL Config File         ::      /usr/local/apache2/conf/extra/httpd-ssl.conf

ErrorLog                ::      /usr/local/apache2/logs/error_log

AccessLog               ::      /usr/local/apache2/logs/access_log

cgi-bin                 ::      /usr/local/apache2/cgi-bin (enabled by default, but the bundled scripts are 644)

binaries (apachectl)    ::      /usr/local/apache2/bin

start/stop              ::      /usr/local/apache2/bin/apachectl (start|restart|graceful|graceful-stop|stop|configtest)

Apache 2.0 default layout (apache.org source package):

ServerRoot              ::      /usr/local/apache2

DocumentRoot            ::      /usr/local/apache2/htdocs

Apache Config File      ::      /usr/local/apache2/conf/httpd.conf

SSL Config              ::      /usr/local/apache2/conf/ssl.conf

ErrorLog                ::      /usr/local/apache2/logs/error_log

AccessLog               ::      /usr/local/apache2/logs/access_log

cgi-bin                 ::      /usr/local/apache2/cgi-bin (enabled by default, but the bundled scripts are 644)

binaries (apachectl)    ::      /usr/local/apache2/bin

start/stop              ::      /usr/local/apache2/bin/apachectl (start|stop|graceful|configtest)

Apache 1.3 default layout (apache.org source package):

ServerRoot              ::      /usr/local/apache

DocumentRoot            ::      /usr/local/apache/htdocs

Apache Config File      ::      /usr/local/apache/conf/httpd.conf

ErrorLog                ::      /usr/local/apache/logs/error_log

AccessLog               ::      /usr/local/apache/logs/access_log

cgi-bin                 ::      /usr/local/apache/cgi-bin (enabled by default, but the bundled scripts are 644)

binaries (apachectl)    ::      /usr/local/apache/bin

start/stop              ::      /usr/local/apache/bin/apachectl (start|stop|graceful|configtest)

Debian, Ubuntu (Apache 2):

ServerRoot              ::      /etc/apache2

DocumentRoot            ::      /var/www

Apache Config Files     ::      /etc/apache2/apache2.conf

::      /etc/apache2/ports.conf

Default VHost Config    ::      /etc/apache2/sites-available/default, /etc/apache2/sites-enabled/000-default

Module Locations        ::      /etc/apache2/mods-available, /etc/apache2/mods-enabled

ErrorLog                ::      /var/log/apache2/error.log

AccessLog               ::      /var/log/apache2/access.log

cgi-bin                 ::      /usr/lib/cgi-bin

binaries (apachectl)    ::      /usr/sbin

start/stop              ::      /etc/init.d/apache2 (start|stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean)

Notes:

The Debian/Ubuntu layout is fully documented in /usr/share/doc/apache2/README.Debian

Debian/Ubuntu use symlinks to enable vhosts and modules. Configuration files are created in their respective sites-available and mods-available directories. To activate vhosts and modules, symlinks are created in the respective sites-enabled and mods-enabled directories to the config files in either sites-available and mods-available. Debian provides scripts to handle this process called ‘a2ensite’ and ‘a2enmod’ which enables vhosts and modules.

The default DocumentRoot is specified in the default vhost config file, /etc/apache2/sites-available/default

Debian, Ubuntu (Apache 1.3):

ServerRoot              ::      /etc/apache

DocumentRoot            ::      /var/www

ErrorLog                ::      /var/log/apache/error.log

AccessLog               ::      /var/log/apache/access.log

cgi-bin                 ::      /usr/lib/cgi-bin

binaries (apachectl)    ::      /usr/sbin

start/stop              ::      /etc/init.d/apache (start|stop|graceful|configtest)

Fedora Core, CentOS, RHEL:

ServerR

配置入门一:虚拟目录

打开并创建虚拟目录的步骤如下:

# Virtual hosts

# Include conf/extra/httpd-vhosts.conf

去掉conf/http.conf文件中:

#Include conf/extra/httpd-vhosts.conf

前面的"#" (实际上是去掉注释) ,

然后若conf下面没有extra/http-vhosts.conf这个文件则创建,最后在里面添加如下代码:

<VirtualHost *:80>

DocumentRoot "E:\APMserv\APMServ5.2.6\www\htdocs\php\Weibopie\Sina_App"

ServerName wo.weibopai.com

# This should be omitted in the production environment

SetEnv APPLICATION_ENV development

<Directory "E:\APMserv\APMServ5.2.6\www\htdocs\php\Weibopie\Sina_App">

Options Indexes MultiViews FollowSymLinks

AllowOverride All

Order allow,deny

Allow from all

</Directory>

</VirtualHost>

其中:E:\APMserv\APMServ5.2.6\www\htdocs\php\Weibopie\Sina_App指向你要访问的项目的地址(注意Apache端口号是否是80,若不是则修改),重启Apache服务器。

ServerName 后面的参数要在hosts中映射,这样就可以通过访问域名来访问项目,

127.0.0.1 wo.weibopai.com

备注:一个Apache服务器可以配置多个虚拟目录

Apache禁止目录访问方法介绍

在PHP网站开发中,基于WEB服务器和PHP网站程序代码的安全考虑,我们需要对相关的目录或者文件访问权限进行控制,以防止意外情况的发生,那么我们如何来实现这种功能呢?我们可以通过Apache来实现禁止目录访问(禁止游览列出的目录或文件列表)、禁止或允许IP与域名访问目录的功能。

环境说明

我使用的是DedeCMS DedeAmpz的PHP运行环境,PHP版本5.2.4,Apache版本2.2.4

在Apache中配置禁止目录访问,即禁止游览列出的目录/文件列表的方法

访问网站目录时Apache默认配置为可列出目录/文件列表,即当你访问http://localhost时会列出相关的目录和文件列表,我们可以通过修改Apache配置文件httpd.conf来实现禁止列出目录/文件列表,方法如下:

1、打开apache配置文件httpd.conf

2、找到

1

2

3

4

5

6

<Directory />

Options Indexes

AllowOverride None

Order allow,deny

Allow from all

</Directory>

只需要修改Options Indexes为Options None即可,注:根据PHP运行环境安装包的不同,Options Indexes也有可能是Options Indexes FollowSymLinks,一并改为Options None即可。

3、保存httpd.conf,并重启Apache即可,此时再访问http://localhost时, 报apache http 403 禁止访问错误信息

Forbidden

You don’t have permission to access / on this server.

Apache单个或多个目录禁止访问方法

这种方法通常用来禁止访问者访问后台管理目录或者程序目录,方法如下

1、打开apache配置文件httpd.conf

2、创建Directory块,比如禁止访问某个类库目录,可以这样实现

1

2

3

4

<Directory /var/www/www.leapsoul.cn/inc>

Order Deny,Allow

Deny from all

</Directory>

上述代码实现了禁止所有用户访问www.leapsoul.cn下inc目录的功能。如要实现禁止访问所有目录中inc目录的功能,只要将

1

<Directory /var/www/www.leapsoul.cn/inc>

更改为

1

<Directory /var/www/www.leapsoul.cn/*/inc>

即可。

3、重启Apache服务器。

其他说明

1、只允许或禁止某个域名进行目录访问

1

2

3

4

5

<Directory /var/www/www.leapsoul.cn/inc>

Order Deny,Allow

Deny from abc.com

Allow from apache.org

</Directory>

上述代码实现禁止abc.com域中主机访问inc目录,允许apache.org域中主机访问inc目录的功能。

2、只允许或禁止某个IP进行目录访问

1

2

3

4

5

<Directory /var/www/www.leapsoul.cn/inc>

Order Deny,Allow

Deny from 10.1.1.2

Allow from 192.168.1.0/255.255.255.0

</Directory>

上述代码实现禁止IP10.1.1.2访问www.leapsoul.cn/inc目录,允许IP192.168.1子网中的主机访问www.leapsoul.cn/inc目录的功能

注意:Allow from 192.168.1.0/255.255.255.0等同于Allow from 192.168.1或Allow from 192.168.1.0/24

至此,通过配置Apache服务器我们可以实现禁止目录访问(列出目录或文件列表),也可以实现禁止访问单个或者多个目录,更可以对访问者进行控制,比如允许或禁止某个IP或者域名对目录进行访问,这些功能对提高和优化WEB服务器的安全性能是必不可少的方法。

源文档 <http://www.leapsoul.cn/?p=453>

linux之Apache的更多相关文章

  1. linux 下 apache相关;启动、停止、重启命令;配置文件位置等等

    linux 下 apache启动.停止.重启命 基本的操作方法: 本文假设你的apahce安装目录为/usr/local/apache2,这些方法适合任何情况 apahce启动命令: 推荐/usr/l ...

  2. Linux下apache+phppgadmin+postgresql安装配置

    Linux下apache+phppgadmin+postgresql安装配置 操作系统:CentOS 安装包:httpd(首选yum), php(包括php以及php-pgsql,php-mbstri ...

  3. linux+php+apache web调用python脚本权限问题解决方案

    lamp : linux + apache + mysql + php 在上篇随笔中linux+php+apache调用python脚本时出现的问题的根本原因是:apache运行时使用的apache用 ...

  4. Apache性能优化、超时设置,linux 重启apache

    在httpd.conf中去掉Include conf/extra/httpd-default.conf前的#以使httpd-default.php生效.其中调节以下参数Timeout 15 (连接超时 ...

  5. 分享:linux下apache服务器的配置和管理

    linux下apache服务器的配置和管理. 一.两个重要目录: Apache有两个重要的目录:1.配置目录/etc/httpd/conf:2.文档目录/var/www: 二.两种配置模式: Apac ...

  6. linux 下apache安装、启动和配置

    linux 下 apache安装 1:系统安装,这里就不说了,网上有很多,也很简单.顺便说下,我用的是redhat 9: 2:在图形界面下下载apache 安装包,我下的是 httpd-2.2.9.t ...

  7. linux 下 apache启动、停止、重启命令

    原文:linux 下 apache启动.停止.重启命令 基本的操作方法: 本文假设你的apahce安装目录为/usr/local/apache2,这些方法适合任何情况 apahce启动命令: 推荐/u ...

  8. [Linux]Linux下Apache服务器配置

    Linux下Apache服务器配置 相关包: httpd-2.2.3-29.e15.i386.rpm                 //主程序包 httpd-devel-2.2.3-29.e15.i ...

  9. ZH奶酪:Ubuntu 14.04配置LAMP(Linux、Apache、MySQL、PHP)

    ZH奶酪:Ubuntu 14.04安装LAMP(Linux,Apache,MySQL,PHP) 之前已经介绍过LAMP的安装,这边文章主要讲解一下LAMP的配置. 1.配置Apache (1)调整Ke ...

  10. Linux系统Apache服务 - 配置 HTTP 的虚拟机主机

    接Linux系统Apache服务 - 配置HTTP的默认主页 1.创建/srv目录,作为httpd的文件目录,并创建/srv/default/www和/srv/www1.example.com/www ...

随机推荐

  1. Serv-U软件在64位操作系统下使用不了odbc解决方法

    这是因为64位Windows上有两个ODBC连接,你需要创建一个32位的ODBC连接.打开32位ODBC管理器的位置 X:\Windows\syswow64\odbcad32.exe. 利用这个管理器 ...

  2. jquery通过ajax获取数据,控制显示的数据条数

    效果图: 现在我们可以先看它的json数据,如图所示:                然后可以对应我们的代码进行理解. jquery通过ajax获取数据,并通过窗口大小控制显示的数据条数,以及可以根据 ...

  3. Rails常用命令

    rails new Project rails g scaffold location uuid:string deviceid:string latitude:float longitude:flo ...

  4. C#多线程下载一个文件

    这里只是说明多线程下载的理论基础,嘿嘿,并没有写多线程下载的代码,标题党了,但是我相信,看完这个代码就应该能够多线程的方式去下载一个文件了. 多线程下载是需要服务器支持的,这里并没有判断服务器不支持的 ...

  5. codeforces 629D 树状数组+LIS

    题意:n个圆柱形蛋糕,给你半径 r 和高度 h,一个蛋糕只能放在一个体积比它小而且序号小于它的蛋糕上面,问你这样形成的上升序列中,体积和最大是多少 分析:根据他们的体积进行离散化,然后建树状数组,按照 ...

  6. qtp不识别树结构中的点击事件

    qtp不识别树结构中的点击事件,未生成该点击事件的脚本,解决办法: 1.未生成点击"auto分类c1"的脚本 2.点击1.对象库-2.添加对象库-3.选中对象-点击OK,即将该对象 ...

  7. vi中如何去除高亮显示的单词

    在vi命令行模式下输入:set nohlsearch 单词不高亮显示:set hlsearch 单词高亮显示: 如果再次打开仍然显示,则可以随便搜索一个不存在的单词,然后保存,重新打开高亮不在显示:

  8. OpenGL和pcDuino搭建数字示波器

    看到大神们用Arduino.AVR做示波器,感觉很好玩,手头的pcDuino能不能做呢?一不做二不休,现在我们就自己用pcDuino做一个. 硬件清单: pcDuino一块 杜邦线若干 软件环境: 1 ...

  9. .net之单元测试

    一.单元测试的目的是为了提高项目的质量 二..net单元测试的实施步骤是:在已经创建的类文件的某个方法上右键-->选择创建单元测试-->系统会创建单元测试解决方案--->单元测试解决 ...

  10. 设计原则 Design Principle

    Design Principle设计原则 最近由于碰到要参与设计一个音频处理系统,有人提议用一个大的全局变量结构体来做状态信息交流的地方,引起了我对设计一个系统的思考,于是找到了如下资料,当然,关于这 ...