Installing the Apache server in a Linux environment

Source: Internet
Author: User

First note that the following actions are performed under root or with the sudo command.

1) go to http://httpd.apache.org/download download Apache source code

2) Extract to/usr/src, execute tar-zxvf httpd-x.x.x.tar.gz-c/usr/src in download directory (I use httpd-2.4.3.tar.gz)

3) Enter directory/usr/src/httpd-2.4.3, execute:./configure--prefix=/usr/local/apache2--with-mpm=worker--enable-cache-- Enable-disk-cache--enable-mem-cache--enable-file-cache--enable-nonportable-atomics--enable-mods-shared=most-- Enable-so--enable-rewrite--enable-ssl

4) Configure:error:APR not found appears. Workaround:

4.1) go to Apr http://apr.apache.org/ Download source code

4.2) Extract to/usr/src, execute tar-zxvf apr-x.x.x.tar.gz-c/usr/src/in download directory (I use apr-1.4.6.tar.gz)

4.3) Enter directory/usr/src/apr-1.4.6, execute./configure--prefix=/usr/local/apr;make;make Install

5) Enter directory/usr/src/httpd-2.4.3 again, add parameter--with-apr=/usr/local/apr/, re-execute:./configure--prefix=/usr/local/apache2-- With-mpm=worker--enable-cache--enable-disk-cache--enable-mem-cache--enable-file-cache-- Enable-nonportable-atomics--enable-mods-shared=most--enable-so--enable-rewrite--enable-ssl--with-apr=/usr/ local/apr/

6) Configure:error:apr-util not found appears. Workaround

6.1) go to apr-util http://apr.apache.org/ Download source code

6.2) Extract to/usr/src, execute tar-zxvf apr-util-x.x.x.tar.gz-c/usr/src/in download directory (I use apr-util-1.5.1.tar.gz)

6.3) Enter directory/usr/src/apr-util-1.5.1, execute./configure--prefix=/usr/local/apr-util;make;make Install

7) Enter directory/usr/src/httpd-2.4.3 again, add parameter--with-apr-util=/usr/local/apr-util/, re-execute:./configure--prefix=/usr/local/ Apache2--with-mpm=worker--enable-cache--enable-disk-cache--enable-mem-cache--enable-file-cache-- Enable-nonportable-atomics--enable-mods-shared=most--enable-so--enable-rewrite--enable-ssl--with-apr=/usr/ local/apr/--with-apr-util=/usr/local/apr-util/

8) appears configure:error:pcre-config for Libpcre not found. Workaround:

8.1) go to pcre http://pcre.org/ Download source code

8.2) Extract to/usr/src, execute tar-zxvf pcre-x.x.tar.gz-c/usr/src/in download directory (I use pcre-8.31.tar.gz)

8.3) Enter directory/usr/src/pcre-8.31, execute./configure--prefix=/usr/local/pcre;make;make Install

9) Enter directory/usr/src/httpd-2.4.3 again, add parameter--with-pcre=/usr/local/pcre, re-execute:./configure--prefix=/usr/local/apache2-- With-mpm=worker--enable-cache--enable-disk-cache--enable-mem-cache--enable-file-cache-- Enable-nonportable-atomics--enable-mods-shared=most--enable-so--enable-rewrite--enable-ssl--with-apr=/usr/ local/apr/--with-apr-util=/usr/local/apr-util/--with-pcre=/usr/local/pcre

10) appears Configure:WARNING:OpenSSL version is too old;checking whether to enable Mod_ssl ... configure:error:mod_ssl have be En requested but can is built due to prerequisite failures; Solution:

10.1) OpenSSL source code http://www.openssl.org/source/ Download source code

10.2) Extract to/usr/src, execute tar-zxvf openssl-x.x.x.tar.gz-c/usr/src/in download directory (I use openssl-1.0.1c.tar.gz)

10.3) Enter directory/usr/src/openssl-1.0.1c, execute./config--prefix=/usr/local/openssl;make;make Install

11) Enter directory/usr/src/httpd-2.4.3 again, add parameter--with-ssl=/usr/local/openssl, re-execute:./configure--prefix=/usr/local/apache2-- With-mpm=worker--enable-cache--enable-disk-cache--enable-mem-cache--enable-file-cache-- Enable-nonportable-atomics--enable-mods-shared=most--enable-so--enable-rewrite--enable-ssl--with-apr=/usr/ local/apr/--with-apr-util=/usr/local/apr-util/--with-pcre=/usr/local/pcre--with-ssl=/usr/local/openssl; make; make install;

Executed successfully.

12) Start Apache, enter the/usr/local/apache2/bin directory, execute the command sudo./httpd-k stop/start/restart or sudo apachectl start/stop/ Restart (Apachectl is execute script)

13) Set httpd can be run in any directory, open vim/etc/environment, add configuration/usr/local/apache2/bin

14) Set Apache to boot automatically, first copy Apachectl to directory/etc/init.d/, execute command sudo cp apachectl/etc/init.d/; then execute sudo update-rc.d apachectl Defaults

15) Failed to execute Apachectl start/stop under root, Error: Httpd:could not reliably determine the server ' s fully qualified domain name.

Workaround: (1) Enter the Apache installation directory: (depending on the individual installation situation) [[email protected] ~]# cd/usr/local/apache/conf

(2) Edit the httpd.conf file, search for "#ServerName", add ServerName localhost:80

(3) Restart Apache. Execute apachectl Restart

16) Error encountered: Permission Denied:make_sock:could not bind to address 0.0.0.0:80

Online search solutions are as follows:

The permissions for the httpd file must be 4755 and belong to the root user ... Simply put, S allows the normal user to run as a file owner/group, because some programs only have a master/group to run, as the/usr/bin/ping,ping command can only be run by root, In order for ordinary users to run, you have to add s-bit, you can experiment:

Remove S:chmod 755 Ping First
Run ping with a normal user and you will find that the permissions are insufficient.
Plus s:chmod 4755 Ping
It's normal to run again.

PS: Invalid for shell script settings! Valid only for Applications!

17) Go to browser input 127.0.0.1, you can display the Apache home page it works. The default directory for this page is in/usr/local/apache2/htdocs/. Apache is here to install OK.

Installing the Apache server in a Linux environment

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.