`
jgsj
  • 浏览: 965938 次
文章分类
社区版块
存档分类
最新评论

Ubuntu 安装配置apache web服务

 
阅读更多

1. 安装

sudo apt-get install apache2


2.启动/停止

启动:

sudo apache2ctl -k start

sudo service apache2 start

sudo /etc/init.d/apache2 start

停止:

sudo apache2ctl -k stop

sudo service apache2 stop

sudo /etc/init.d/apache2 stop

重新启动:

sudo apache2ctl -k restart

sudo service apache2 restart

sudo /etc/init.d/apache2 restart

3.配置

普通的apache发行版本配置文件是:

/etc/apache2/httpd.conf

Ubuntu发行版本的主配置文件是:

/etc/apache2/apache2.conf

#配置选项:

#你的apache软件安装的位置
#ServerRoot "/etc/apache2"
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
LockFile ${APACHE_LOCK_DIR}/accept.lock
# 第一个httpd进程(所有其他进程的父进程)的进程号文件位置。
PidFile ${APACHE_PID_FILE}
# 超时时间
Timeout 300
#是否允许持久连接
KeepAlive On
# 在持久连接过程中,允许的最大请求量
MaxKeepAliveRequests 100
#相同客户端相同连接的持久时间
KeepAliveTimeout 15
# StartServers: apache启动时候默认开始的进程数
# MinSpareServers:最小的闲置进程数
# MaxSpareServers: 最大的闲置进程数
# MaxClients: 设置同时连入的clients最大总数
# MaxRequestsPerChild:设置的是每个子进程可处理的请求数
# ServerLimit:最大的进程总数
# prefork工作模式(使用最多而且最稳定的工作模式)
<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>
# worker工作模式(与php配合不好,或者说暂时用不上)
<IfModule mpm_worker_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>
# event工作模式(不太稳定,或者说暂时用不上)
<IfModule mpm_event_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess
#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy all
</Files>
#文件类型:text/HTML使用:text/plain;二进制文件或图像文件使用:application/octet-stream
DefaultType text/plain
HostnameLookups Off
#错误日志文件存储路径
ErrorLog ${APACHE_LOG_DIR}/error.log
#日志级别:debug, info, notice, warn, error, crit,alert, emerg.
LogLevel warn
#包含模块的配置:
Include mods-enabled/*.load
Include mods-enabled/*.conf
# 包含所有用户的配置:
Include httpd.conf
# 包含端口配置
Include ports.conf
#日志文件格式
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# 包含一般性的配置语句片断:
Include conf.d/
# 包含虚拟主机的配置指令
Include sites-enabled/


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics