Install and configure Apache in Linux

Source: Internet
Author: User
  1. Download and install
    Download httpd-2.2.6.tar.gzfrom upload it to linuxlater.
    Decompress the tar-zxvf httpd-2.2.6.tar.gz, A httpd-2.2.6 directory appears in the current directory, and then run the following commands in sequence
    Music httpd-2.2.6 Apache
    CD Apache
    To set the installation parameters, run the following command:
    ./Configure -- prefix =/usr/local/apache2 -- enable-module = so
    The prefix parameter indicates that Apache is installed in the/usr/local/apache2 directory. If the login user is not root, the user may not have the permission to create a directory under/usr/local, in this case, an error is reported during make install. There are two solutions: 1) modify the prefix parameter to point to the path where a logon user has permission to create a directory; 2) use the root user to create the apache2 directory under the/usr/local directory, then, grant the WRX permission of apache2 to the login user.
    Finally, compile and install. Execute the following commands in sequence:
    Make install
    In short, the command sequence executed in the installation sequence is as follows. If no error occurs, the installation is successful.
    Tar-zxvf httpd-2.2.6.tar.gz
    Music httpd-2.2.6 Apache
    CD Apache
    ./Configure -- prefix =/usr/local/apache2 -- enable-module = so
    Make install
    Main Apache directories and files
    Location of the main configuration file:/etc/httpd/CONF/* Or/usr/local/apache2/CONF/httpd. conf
    Start script/etc/rc. d/init. d/httpd
    Help document/usr/local/apache2/manual/* html
    Icon files/usr/local/apache2/icons/* Used in HTML webpages /*
    Create and update Apache user programs/usr/local/apache2/htpasswd
    HTTP server program/usr/sbin/httpd
    Log File/usr/local/apache2/logs
  2. STARTUP configuration
    Modify the PATH environment variable, open. bash_profile in the home directory of the logged-on user, and add a line to the file.
    Path = $ path:/usr/local/apache2/bin
    Log out and log on again. Run apachectl-L. If any information is returned, the path is set successfully.
    The Apache configuration file is/usr/local/apache2/CONF/httpd. conf.
    The default listening port of Apache is 80. On Linux/Unix, only the root user has the permission to open a port smaller than or equal to 1024. Therefore, to enable Apache as a non-root user, you must modify the default port to enable httpd. conf. Modify the listen attribute (or port) to 8000.
    Run the command apachectl start. If no error message is displayed (if any, correct the error according to the error message), open IE and enter http: // ip in the address bar: 8000 (the IP address here is the IP address of the Apache installation host). If a page is displayed, it indicates that Apache is successfully started.
  3. Parameter description
    Servertype standlone/inetd server running mode
    Port 80 or the port number listened to by listen 80 in standlone Mode
    Owner of the user nobody process
    Group nobody
    Serveradmin admin @ localhost administrator mailbox
    Serverroot "/home/httpd/" Server File Location
    Servername httpserver server name
    Timeout 300 set the connection timeout between the server and the client
    Number of clients allowed to connect simultaneously in maxclient 300
    Proxyrequests on allows proxy
    DocumentRoot "/home/httpd/html" provides the root directory of the server documentation service
    Directory of the user's home page on the userdir public_html Server
    Directoryindex index.html Directory Index File
    Accessfilename. htaccess file name that contains access control information in each directory
    Alias/icons/"/home/user/icons/" creates an alias for a document not under DocumentRoot
    <Directory> </directory> directory settings. You can add some directory parameters in the middle, for example:
    <Directory "/">
    Options Indexes
    AllowOverride none
    Order allow, deny
    Allow from all
    In the preceding directory settings, the options Option configuration command is used to control the access characteristics of the directory.
    Execcgi: Execute the CGI script.
    Indexes: returns a list of objects when accessing a directory without an index.
    Which settings in the AllowOverride command ". htaccess" file allow overwrite previous settings?
    None: Do not read. htaccess
    Limit: overwrite commands (allow, deny) that control host access)
    Authconfig: allowed to overwrite Authentication-related commands (authtype, authname)
    Here is none
    Order command
    Control the order in which commands allow and deny are processed
    For example:
    Order allow, deny
    Deny from all
    Allow from host11
    Allow command
    For a directory, the allow command sets which hosts are allowed to access
    ALL: All Hosts
    Or Domain Name:
    Or a complete IP Address:
    Network number/subnet mask:
    Network number/NNN: indicates a range of IP addresses
    Deny command
    For a directory, the allow command sets which hosts are not allowed to access
    -All: All Hosts
    Or Domain Name:
    Or a complete IP Address:
    Network number/subnet mask:
    Network number/NNN: indicates a range of IP addresses
  4. End
    Different versions of Apache have minor differences in directory and parameter names, which can be guessed by name.
    Thank you for your attention.
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: 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.