Issues to be aware of during Linux installation of Apache _linux

Source: Internet
Author: User
Tags documentation http request mkdir php development environment

As the most common Web server, Apache can be used in most computer operating systems, and as a free and open source Unix-like operating system Linux, it and Apache can be said to be the golden partner. This article introduces you to the installation and use of Apache under the Linux system.
First, to download the Apache software , you can download the website of Apache, I download here is the latest version of Apache-- httpd-2.4.18.tar.gz
two, download Apache, the next thing to do is not to start the installation immediately, I personally think should first Plan the installed directory structure . First clear what we do with Apache, I generally use apache+php+mysql as a PHP development environment. So for ease of management, I always install the three under the same directory. So under normal circumstances I create a new lamp folder under/(root) and then install all three under this directory. Of course, in the actual situation can be based on different and have their own habits to do different settings.
Three, after you plan your directory structure, the next step is to clear the conditions required to install apache2.4
1. The first and foremost is the C compiler, See if GCC is installed in our system, and no GCC is not able to compile the Apache source code. So we need to ensure that GCC is installed in the system before we install Apache. If you do not have GCC, you can use #yum install GCC to install this item.
2. Apr and Apr-util are required during installation of apache2.4, Apr (Apache portable Runtime)
3. PCRE (perl-compatible Regular Expressions Library) is required during installation, but there is no such library in httpd, so we need to install
four, After you plan your directory structure, you begin the installation process, and the installation process can be divided into the following four steps

1. # TAR–ZXVF httpd-2.4.18.tar.gz  Extract File
2. # CD httpd-2.4.18   into the unpacked folder
3./configure--prefix=/lamp/ apache/--enable-rewrite    uses configure configuration option
4. # make       compiles
5. # Make install     installation

In 1, 22 steps general situation no problem, the main problem is in the 3rd step./configure:
First of all, if you do not meet the condition 2 in three, the following error occurs during the./configure process

    • Checking for APR ... no
    • Configure:error:APR not found. Please read the documentation.
    • ......
    • Checking for Apr-util ... No
    • Configure:error:apr-util not found. Please read the documentation.

This is a missing APR and Apr-util class Library, the solution is to download the APR and apr-util two files, I download here is apr-1.5.2.tar.gz and apr-util-1.5.4.tar.gz. When the download is complete, start decompressing the two files to
Httpd-2.4.18/srclib below, each named Apr (HTTPD.2.4.18/SRCLIB/APR) and Apr-util (httpd.2.4.18/srclib/apr-util) Note that you cannot have a version number. This can be done by the time you compile it.
Second, the following error may also occur during the./configure process

    • Checking for pcre-config ... false
    • configure:error:pcre-config for Libpcre not found. PCRE is required and available from http://pcre.org/

This shows that we do not meet the three conditions of 3, the solution is to download the Pcre class library, installed in the system
First download the pcre-8.37.tar.gz, then unzip the installation

# TAR–ZXVF pcre-8.37.tar.gz
# cd pcre-8.37
#./configure–prefix=/usr/local/pcre (installation directory, can adapt this catalogue according to the actual situation)
# make
# make install 

After the installation is complete, add this item in the Apache./configure option –with-pcre=/usr/local/pcre/
Complete command for

 ./configure–prefix=/lamp/apache–enable-rewrite–enable-so–with-pcre=/usr/local/pcre

Step 3 can be passed successfully at this time.
Then execute make,make install in turn, and the following results appear

 

..... Installing configuration Files
mkdir/lamp/apache/conf
Mkdir/lamp/apache/conf/extra
Mkdir/lamp/apache /conf/original
Mkdir/lamp/apache/conf/original/extra
Installing HTML documents
mkdir/lamp/apache/ Htdocs
Installing error documents
mkdir/lamp/apache/error
installing icons
mkdir/lamp/apache/ Icons
mkdir/lamp/apache/logs
installing CGIs
mkdir/lamp/apache/cgi-bin
Header Files
Installing build system files
installing mans pages and online manual
Mkdir/lamp/apache/man
Mkdir/lamp/apache/man/man1
mkdir/lamp/apache/man/man8
mkdir/lamp/apache/manual
make[1]: Leaving Directory '/lnmp/httpd-2.4.18 '
 

The Apache installation was successful.
v. Test whether the Apache installation is successful

 #/lamp/apache/bin/apachectl–k start opens Apache service 

After the service is turned on we can use the following two commands to see if the Apache service is open

1. # wget localhost

The following results show the successful opening

    • --2015-12-28 13:11:14-- http://localhost/
    • Resolving host localhost ... 127.0.0.1
    • Connecting to localhost|127.0.0.1|:80 ... is connected.
    • HTTP request issued, waiting for response ... OK
    • Length: [text/html]
    • Saving to: ' index.html '
    • 100%[=====================================================================>]--.-K/s in 0s
    • 2015-12-28 13:11:14 (2.97 MB/s)-' index.html ' saved [45/45]
2. # curl localhost

The following results show the successful opening

#/lamp/apache/bin/apachectl–k stop off Apache service
#/lamp/apache/bin/apachectl–k restart restart Apache Service

Vi. adding Apache services to System services
1. Copy/lamp/apache/bin/apachectl to/etc/rc.d/init.d below, and rename to httpd

# CP/LAMP/APACHE/BIN/APACHECTL/ETC/RC.D/INIT.D/HTTPD

2. Edit/ETC/RC.D/INIT.D/HTTPD Add the following two lines to the file

# chkconfig:30
# Description:apache server.

3. Modify/ETC/RC.D/INIT.D/HTTPD Permissions

#chmod +x/etc/rc.d/init.d/httpd

4. Registration Service

#/sbin/chkconfig–add HTTPD

5. Then you can manage the Apache service via service command

# service httpd start Open Services
# service httpd stop shutdown Services

This article is just to provide a train of thought, after all, different systems may be different, we can install according to the actual situation, I hope this article is helpful to everyone.

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.