Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Apache installation, configuration and optimization methods

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains the "Apache installation, configuration and optimization methods", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Apache installation, configuration and optimization methods"!

Install Apache 2.0.48 (see Install manual)

Taking into account the future to rewite_url to make it easier for google to include the site, specially added mod_rewrite.

At the same time, in order to limit traffic, a special mod_limitpcnn.c patch is added, so there is an additional option-- enable-forward.

It is recommended that you do not delete the installation directory after installation, so that you can use it in future upgrades.

Remember to turn off apache2.0 before upgrading

Compilation process:

Code:

#. / configure-enable-so-enable-speling-enable-rewrite

-with-ssl=/usr/local/ssl-enable-forward

# make

# make install

In this example, mod_so,mod_speling and openssl support are compiled.

There are also several other ways of writing.

Code:

#. / configure-enable-modules=so-enable-modules=speling-enable-modules=rewrite

Or

Code:

#. / configure-enable-modules= "so speling"

-- enable-MODULE [= shared] compiles and contains the module MODULE. MODULE is the name of the module that removes "_ module" from the document. To compile a module to DSO, add the-shared option, that is,-- enable-mods-shared. (see MODULE manual)

Note: "if you want the core to be able to load DSO without actually compiling any dynamic modules, specify-- enable-modules=so or-- enable-so" (see the DSO manual), so the previous order cannot be swapped. View configure parameters for all apache

After installation, you can use the following command to see which modules are started

Code:

# apachectl-l

Compiled in modules:

Core.c

Mod_access.c

Mod_auth.c

Mod_include.c

Mod_log_config.c

Mod_env.c

Mod_setenvif.c

Prefork.c

Http_core.c

Mod_mime.c

Mod_status.c

Mod_autoindex.c

Mod_asis.c

Mod_cgi.c

Mod_negotiation.c

Mod_dir.c mod_imap.c

Mod_actions.c

Mod_speling.c

Mod_userdir.c

Mod_alias.c

Mod_rewrite.c

Mod_so.c

Next, put the startup program into the boot program. If you want to start an ssl encrypted web page, you must start apache2.0 manually (see the ssl section)

Code:

# echo "/ usr/local/apache2/bin/apachectl start" > > / etc/rc.d/rc.local

Reference:

Code:

If you want your server to continue running after a system reboot

You should add a call to apachectl to your system startup files (typically rc.local

Or

A file in an rc.N directory). This will start Apache as root. Before doing this ensure

That your server is properly configured for

Security and access restrictions.

Add the above statement to profile to set the path, making it easier to control apachectl under bash, saving the trouble of entering the path.

Code:

# vi / etc/profile

PATH= "  $PATH:usr/local/apache2/bin:"

Configure apache2.0

Code:

# vi / usr/local/apache2/conf/httpd.conf

For the configuration file, please see the file httpd.conf (set the document directory to / home/dalouis/public_html)

Code:

# chmod 755-R / home/dalouis/

Set the readability of the directory to drwxr-xr-x (755), otherwise "Forbidden You don't have permission to access / on this server."

Some configurations about security:

Considering the security of cgi-bin, we remove cgi-bin for the time being. Add all the lines about cgi-bin in all httpd.conf to #.

Configuration of Xiyang

I use: mod_limitipconn, mod_expires, mod_gzip, mod_php4, mod_so, mod_access, mod_alias, mod_userdir, mod_dir, mod_autoindex, mod_status, mod_mime, mod_log_config, http_core

About the problem of timeout

When I write all the product view pages, there are often problems that apache stops working because of timeout or excessive traffic, for two reasons, one is the unscientific code, the other is the setting of apache.

Here are some changes to the settings:

Code:

# KeepAlive: Whether or not to allow persistent connections (more than

# one request per connection). Set to "Off" to deactivate.

# KeepAlive Off

# MaxKeepAliveRequests: The maximum number of requests to allow

# during a persistent connection. Set to 0 to allow an unlimited amount.

# We recommend you leave this number high, for maximum performance.

# MaxKeepAliveRequests 0

# KeepAliveTimeout: Number of seconds to wait for the next request

# from the same client on the same connection.

# KeepAliveTimeout 0

Recording the HTTP-REFERER and AGENT of visitors helps to count what search engine visitors use to find our site. Or in the original CustomLog line, change the parameter from common to combined

Code:

# If you would like to have agent and referer logfiles

# uncomment the following directives.

CustomLog logs/referer_log referer

CustomLog logs/agent_log agent

CustomLog logs/www.domain.com-access_log combined

Use mod_limitipconn.c to limit the number of concurrency of apache

Package: http://dominia.org/djao/limit/ the installation here recommends using dynamic DSO and patch apache2.0 so that apache2.0 can recognize the IP behind the agent. But to recompile apache2.0, here is the introduction.

Code:

# # Instructions for building DSO with proxy tracking:

# tar xzvf httpd-2.0.39.tar.gz

# tar xzvf mod_limitipconn-0.22.tar.gz

# cd httpd-2.0.39

# patch-p1 <.. / mod_limitipconn-0.22/apachesrc.diff

#. / buildconf

#. / configure-enable-so-enable-speling-enable-rewrite

-with-ssl=/usr/local/ssl-enable-forward

# make

# make install

# cd.. / mod_limitipconn-0.22

# PATH=/usr/local/apache2/bin:   $PATH

# make install

Installation process

# lynx http://dominia.org/djao/limit/mod_limitipconn-0.22.tar.gz

# tar-zxvf mod_limitipconn-0.22.tar.gz

# cd httpd-2.0.48

# patch-p1 <.. / mod_limitipconn-0.22/apachesrc.diff

Patching file configure.in

Hunk # 1 succeeded at 373 (offset 55 lines).

Patching file include/scoreboard.h

Patching file modules/generators/mod_status.c

Hunk # 1 succeeded at 746 (offset-1 lines).

Thank you for your reading, the above is the content of "Apache installation, configuration and optimization methods", after the study of this article, I believe you have a deeper understanding of Apache installation, configuration and optimization methods, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report