Linux under the Apache source code installation Experience

Source: Internet
Author: User

1 . Download the version you need from the Apache website. (Take the 2.4 version for example)Http://httpd.apache.org/download.cgi#apache24

( refer to URLs http://www.jb51.net/article/59474.htm and http://blog.csdn.net/yiluoak_47/article/details/22067185

)

2, copy the downloaded source package (using the WinSCP software copy file) to the Liunx server, go to this directory, and then unzip the tar –zxvf Httpd-2.4.12.tar.gz into the Unzip directory CD httpd-2.4.12.tar.gz

3. If Linux contains Apr apr-util need to first unload rpm –qa|grep Apr find rpm files are then forced to unload rpm –r–nodeps rpm file name

4. Go to http://apr.apache.org/download.cgi Download the Apr and apr-util files you need

5, the decompression of these two files, you need to install Apr ( recommended installation directory is the same directory) must be determined that Linux installed gcc

./configure--prefix=/usr/local/apr/

Make

Make install

(You must remember the installation directory, and so on when Apache installation requires these three directories )

6. Install the apr-util file again

./configure--prefix=/usr/local/apr/--with-apr=/usr/local/apr/

Make

Make install

7, and then download Pcre http://jaist.dl.sourceforge.net/project/pcre/pcre/to find a suitable version, is generally the latest version (if the hint is missing C + +, y um install-y gcc gcc-c++ command installs C + +)

./configure--prefix= Installation directory

Make

Make install

8. Start installing Apache ( This command does not copy, error.) Knock yourself)

./configure--prefix=/usr/local/apache24/--with-apr=/usr/local/apr/--with-apr-util=/usr/local/apr-util/-- with-pcre=/usr/local/pcre/--enable-rewrite--enable-so--enable-headers--enable-expires--with-mpm=worker-- Enable-modules=most--enable-deflate

Make

Make install

--prefix=/usr/local/apache2 indicates the installation path for the specified Apache, the default installation path is /usr/local/apache2

--enable-rewrite provides the rewrite of the URL rule to be more tender, that is, according to the known URL address, converted to the other desired URL Address

--enable-so activation of the Apache service DSO(Dynamic Shared Objects dynamically shared targets), which can be DSO To compile and install the shared module, the module itself cannot be DSO The method is compiled.

The--enable-headers provides control of the HTTP request header that is allowed.

--enable-expires activation Xunyu control HTTP "Expires: " and "Cache-control:" Through the configuration file header content, that is, the website image,js,css and other content, provide client browser cache settings. This is One of the important options for Apache tuning.

--with-mpm=worker select apache  MPM worker mode. For worker mode principle is that more threads are used to process requests, Therefore, more concurrent requests can be processed. While system   resource overhead little Jade is based on the process of the mpm prefork prefork process mode. This is the apache One of the important options for tuning.

--enable-deflate provides compression transmission encoding support for content, usually html,js,css and other content of the site. Using this parameter will increase the transfer speed and enhance the visitor's experience. In a production environment, this is One of the important options for Apache tuning.

9, 1) into the Apache installation directory:( Depending on the individual installation situation and different )

/usr/local/apache24/conf

2) Edit the httpd.conf file to search for "#ServerName"

#ServerName www.example.com:80 modified to the following
ServerName localhost:80
3) restart Apache again .
[Email protected] ~]#/usr/local/apache24/bin/apachectl restart

9. Copy the Apache startup script to the /etc/rc.d/init.d directory

Cp/usr/local/apache24/bin/apachectl/etc/init.d/httpd

Ln-s/etc/rc.d/init.d/httpd/etc/rc.d/rc5.d/s85httpd

In fact, Apache boot is called /usr/local/apache24/bin/httpd This command, view the contents of the script, as follows:

Cat/etc/init.d/httpd|grep-v ^#|grep-v ^$

Start Apacheas follows:

Service httpd Start

You can also use /usr/local/apache2/bin/httpd to start. as follows:

/usr/local/apache24/bin/httpd–k start

Bin Main Store program command directory,.

Conf primarily stores Apache configuration files.

Htdocs primarily stores the site directory.

The logs primarily stores the default log files.

Modules primarily stores Apache 's operating modules. For example , php,memcache compiled modules are stored here.

View the httpd.conf configuration content as follows:

Egrep-v ' ^[]*#|^$ '/usr/local/apache2/conf/httpd.conf | nl

10. Apache joins the system service

In order for Apache to boot , we can add the apachectl boot script to the rc.local file, as follows:

echo "/usr/local/apache24/bin/apachectl start" >>/etc/rc.local

Cat/etc/rc.local

We can also launch Apacheby adding Apache to the system service . There are two ways to add Apache as a system service, the first is to add it through chkconfig , and the second is to add the system's individual boot levels directly.

If you encounter a service httpd chkconfig (service httpd does not support Chkconfig) is not supported

Run Chkconfig--list, found that there is no Linux service in the list httpd, by Chkconfig--add httpd to add, but prompted: httpd service does not support Chkconfig. To edit/etc/rc.d/init.d/httpd, add the following comment information:
# chkconfig:2345 70 60
# Description:apache HTTPD

Description

the 2345 in chkconfig:2345 is the script's runlevel, which can be run in all 4 modes of 2345 . 234 are all text interfaces, and5 is the graphical interface X.

The script will be the future boot sequence number, if the start sequence number of other programs is smaller than (for example , The script needs to wait until these programs are started before starting. refers to the stop order number of the script when the system shuts down.

Use chkconfig to add the following:

Chkconfig--add httpd

the role of the chkconfig--add httpd command is to add /etc/init.d/httpd to the /etc/rc.d/rc0.d to /ETC/RC.D/RC6.D directory under

To turn on Apache boot, use the following command:

Chkconfig httpd on

Linux under the Apache source code installation Experience

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.