Tutorial on Linux Server 4-how to build Apache HTTP Server and proxy server in Linux

Source: Internet
Author: User
Tags debian server jboss server
Apache is the most popular open-source server. It has always held a large share of Web server and leads the development of open-source projects. Although there are no advantages in some large commercial e-commerce and enterprise applications (usually large enterprises use J2EE servers to their most commercial transaction platforms, such as BEA application server, IBM WebSphere, JBoss server, etc.), but as an explanation of the static Web page, proxy servers and other aspects still have a natural advantage, especially the most open-source projects, the price cost is more advantageous. At the same time, with the support for J2EE, you can achieve the purpose of clustering by cooperating with its sub-project Tomcat server (to a certain extent, J2EE specifications, usually the most servlet container, for more information, see the implementation of Tomcat clusters in Java and J2EE columns in my blog (http://blog.csdn.net/jwsh1984. Here I will take Debian server as an example to describe how to set up a Web server and a network proxy server. (The basic knowledge of the Debian server has been mentioned in the Unix/Linux column in my blog ).

(1) custom Server:
Note: You must be familiar with some basic LINUX operation commands or remote logon. In Windows, you can use Putty to remotely log on to the Debian server, as mentioned in the Windows column in my blog)
First download the relevant apache2.0 version on the official homepage. The source code is downloaded here. Apache2.0 is highly customizable. It can be transplanted to multiple platforms through MPMs at the same time, and has high scalability. Download the source code. We can customize the server as needed.
1. Copy the code package (xxx.gz) to/usr/src and decompress it to/usr/src. Generally, the command tar zxf *. GZ is used. (If this step is not done, refer to the article in the Unix/Linux column under my blog-how to decompress the Linux server ).
2. Compile and install (make and GCC compilers must be installed). Before compiling, you 'd better refer to the Apache official manual to customize your own requirements, the following is my own operation (go to the decompressed directory ):
1) platform configuration before Compilation :. /configure -- prefix =/usr/apache2 -- enable-mod-shared = all -- enable-Cache -- enable-disk-Cache -- enable-Mem-Cache -- enable-proxy -- enable- proxy-connect -- enable-proxy-HTTP -- enable-proxy-FTP
2) Compile: Make (this step will compile the relevant files generated according to your settings, which is also in this directory)
3) installation: make install (this step copies the compiled file to/usr/apache2)

3. Start and test:/usr/apache2/bin/apachectl start
Enter the relevant URL in the browser and test it. Remote Installation can also be performed on Windows: http: // (address of the Linux Server)/my example (http: // 192.168.199.138 ).
Note: apachectl is a sysv script (refer to the articles in the Unix/Linux column under my blog-Introduction to the startup script in Linux Server-related setup ), you can call apachectl stop to stop the server.

4. Set it to run automatically upon startup: Because apachectl is a sysv script, copy it to init. in the D folder, copy it to/etc/init. D folder (CP/usr/apache2/bin/apachectl/etc/init. d) and rename it to httpd (mV/etc/init. d/apachectl/etc/init. d/httpd), and create a connection (rcX. d), my sub-machine runs init 2 automatically at startup, so go to/etc/rc2.d and run the command ln-s .. /init. d/httpd s96httpd. (Please refer to the article in the Unix/Linux column under my blog-Introduction to the startup script for Linux Server-related setup)

(2) Configure the server:
Note: you must understand the basic operations of Vi before you start (refer to the articles in the Unix/Linux column under my blog-VI operations in Linux Server Construction)
1. Customize your home page and webpage root directory:
Go to the/usr/apache2/CONF/folder and open the editing file VI httpd. conf.
Search for the DocumentRoot string, use/DocumentRoot in VI command mode, and press enter (Continue search and press N ). Modify it to DocumentRoot "/var/www" (originally/usr/apache2/htdocs, it is recommended to change it to another folder, especially if it is not in a partition with the system) and search for directory, change <directory "/usr/apache2/htdocs"> to <directory "/var/www">, copy the content of your website to the/var/WWW folder.

2. Custom HTTP Proxy Server:
Confirm that mod_proxy.so and mod_proxy_http.so are loaded (search proxy for information ).
Go to the bottom of the file (g in command mode) and enter:
Proxyrequests on
<Proxy *>
Order deny, allow
Deny from all
Allow from 192.168.199
</Proxy>
Here 192.168.199 is the Web site that you allow to use the proxy, Which is configured in the LAN, save and exit,: WQ
Restart the server,/usr/apache2/bin/apachectl restart

Test proxy server: on the Windows client, open IE6, tools/Internet Options on the menu bar, enable connections, select LAN Settings, and check use a proxy ..., enter 192.168.199.138 in address (set by Linux Server), Port (80), and select OK. Enter the webpage address in the browser. The access connection is normal and successful. (I use Windows in English ).

Well, the proxy server is successful. We need to use the Linux server as the basic configuration for external connection.

Thank you for reading this article!
If you have any questions about this article, contact the author. Author address: Sidney.J.Yellow@gmail.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.