Install Apache on centos

Source: Internet
Author: User

Reprinted and modified from:
Http://www.centos.bz/2011/07/centos-compile-install-apache-from-source/
For more information, see:
Http://289972458.iteye.com/blog/1323258
Http://www.centos.bz/2011/07/centos-compile-install-apache-from-source/

1) uninstall the built-in httpd:
Rpm-Qa | grep httpd
Rpm-e httpd-2.2.15-15.el6.centos -- nodeps
Rpm-e httpd-Tools

2) Find the latest download link.
Slave

3) start to install Apache
CD/usr/local/src
Wget http://mirror.bjtu.edu.cn/apache//httpd/httpd-2.2.24.tar.gz
Tar-zxvf httpd-2.2.19.tar.gz
CD httpd-2.2.19
./Configure -- prefix =/usr/local/Apache -- enable-vhost-alias -- enable-Rewrite -- enable-Info
Make
Make install

4) copy the initialization file and set Apache startup
CP build/RPM/httpd. init/etc/init. d/httpd
Chmod 755/etc/init. d/httpd
Chkconfig -- add httpd
Chkconfig -- level 35 httpd on

5) create a symbolic link
Check/etc/init. d/httpd to view the required files.
Conffile =/etc/httpd/CONF/httpd. conf
Httpd =$ {httpd-/usr/sbin/httpd}
Pidfile =$ {pidfile-/var/log/httpd/$ {prog}. PID}
Lockfile =$ {lockfile-/var/lock/subsys/$ {prog }}

The symbolic link is as follows:
Ln-S/usr/local/Apache // etc/httpd
Ln-S/usr/local/Apache/bin/httpd/usr/sbin/httpd
Ln-S/usr/local/Apache/bin/apachectl/usr/sbin/apachectl
Ln-S/usr/local/Apache/logs/var/log/httpd

6) start/stop the service
Service httpd restart
Service httpd start
/Usr/local/Apache/bin/apachectl start
/Usr/local/Apache/bin/apachectl stop
/Usr/local/Apache/bin/apachectl status
/Etc/init. d/httpd start
/Etc/init. d/httpd stop
/Etc/init. d/httpd restart

Use pgrep to find the started process.
Pgrep httpd

7) Check in the browser:
Http: // 192.168.0.120: 80
If you see it works, Apache is started.

8) Apache configuration file
VI/usr/local/Apache/CONF/httpd. conf
For more configure options, refer to the http://httpd.apache.org/docs/2.2/programs/configure.html

9) The default Apache configuration file is as follows:

#
# DocumentRoot: the directory out of which you will serve your
# Events. By default, all requests are taken from this directory,
# Symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/usr/local/Apache/htdocs"

#
# Each directory to which Apache has access can be configured with respect
# To which services and features are allowed and/or disabled in that
# Directory (and its subdirectories ).
#
# First, we configure the "default" to be a very restrictive set
# Features.
#
<Directory/>
Options followsymlinks
AllowOverride none
Order deny, allow
Deny from all
</Directory>

#
# This shoshould be changed to whatever you set DocumentRoot.
#
<Directory "/usr/local/Apache/htdocs">
#
# Possible values for the options directive are "NONE", "all ",
# Or any combination:
# Indexes includes followsymlinks symlinksifownermatch execcgi Multiviews
#
# Note that "Multiviews" must be named * explicitly * --- "options all"
# Doesn' t give it to you.
#
# The options directive is both complicated and important. Please see
# Http://httpd.apache.org/docs/2.2/mod/core.html#options
# For more information.
#
Options indexes followsymlinks

#
# AllowOverride controls what directives may be placed in. htaccess files.
# It Can Be "all", "NONE", or any combination of the keywords:
# Options fileinfo authconfig limit
#
AllowOverride none

#
# Controls who can get stuff from this server.
#
Order allow, deny
Allow from all

</Directory>

#
# Directoryindex: sets the file that Apache will serve if a directory
# Is requested.
#
<Ifmodule dir_module>
Directoryindex index.html
</Ifmodule>

If you want to access your home directory, you need to create a symbollink under DocumentRoot to point to your home, and ensure that the home directory has executable permissions for everyone. For example:

[AAA @ centos_aaa cgi-bin] $ ll-D/usr/local/Apache/htdocs /~ Aaa
Lrwxrwxrwx. 1 Root 9 Apr 7 09:44/usr/local/Apache/htdocs /~ Aaa->/home/AAA
[AAA @ centos_aaa cgi-bin] $ ll-D/home/AAA
Drwxr-XR-X. 38 AAA 4096 APR 7 11: 10/home/AAA

Accessible: http: // 192.168.0.120 /~ AAA/

Complete!

Related Article

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.