Installation and configuration of CentOS Apache server

Source: Internet
Author: User

CentOS Apache Server installation and configuration 1. Install the Apache program in three ways:
1. Direct Network installation;
2. Download the rpm package and upload it to the server for installation;
3. Compile and install using the original code; yum-y install httpdrpm-qa | grep httpd ---------------------------- start/stop/restart/status service httpd start
Service httpd stop
Service httpd restart
Service httpd status
Pstree | grep httpd // verify whether the service is started, which is rarely used. If the following information is prompted during startup:
Starting httpd: cocould not reliably determine the server's fully qualified domain name, using localhost. localdomain for ServerName edit/etc/httpd/conf/httpd. conf
Find the following content:
# ServerName www.example.com: 80
Change
ServerName localhost: 80 restart the Apache service. -------------------------------- Test whether the installation configuration is successful. http: // If the IP address is displayed: Apache 2 Test Page powered by CentOS, it's okay; if it cannot be opened, it should be an iptables problem;
Edit/etc/sysconfig/iptables
Add the following content:
-A input-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 443-j ACCEPT and restart the iptables service. ------------------------------ 2. Basic configuration: 1. edit/etc/httpd/conf/httpd for the setting project of the host environment. confKeepAlive off
Change
KeepAlive onMaxKeepAliveRequests 100
Change
MaxKeepAliveRequests 500 // you can increase the efficiency;
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
StartServers 4
MaxClients 300
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0: The prefork module is used by default. If you want to use the worker module to edit the following files:
/Etc/sysconfig/httpd
Find the following content:
# HTTPD =/usr/sbin/httpd. worker
Change
HTTPD =/usr/sbin/httpd. worker and restart the apache service. ------------------------------ 2. Edit the Chinese Big5 encoding language/etc/httpd/conf/httpd. conf and find the following content:
Adddefacharcharset UTF-8
Change
# Adddefacharset UTF-8
Or
Adddefacharcharset gb2313 // set according to the actual situation; find the following content:
LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nn no pl pt-BR ru sv zh-CN zh-TW
Change
LanguagePriority zh-CN en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt-BR ru sv zh-TW then restart the apache service; ------------------------------ 3. edit/etc/httpd/conf/httpd for homepage permission settings. conf finds the following content:
Options Indexes FollowSymLinks
Change
Options FollowSymLinks MultiViews and then restart the apache service. ------------------------------ Advanced Configuration:

Is the website IP address illegally directed to another domain name? How does Apache disable malicious domain names from directing to your server IP address:

Solution 1: Create a VM: <VirtualHost *: 80>
ServerName 171.111.158.91 // change to the IP address of your server;
<Location/>
Order Allow, Deny
Deny from all
</Location>
</VirtualHost> solution 2: create the first VM (no defined domain name is used by default to access the content of the first VM): <VirtualHost *: 80>
DirectoryIndex index.html index.htm index. php
DocumentRoot/var/www/html/test // define an empty directory, or place a website page to display the information you need to specify; <Directory/var/www/html/test>
ServerName 171.111.158.91 // change to the IP address of your server;
// The Directory is the same as above;
Order allow, deny
Allow from all
</Directory>
</VirtualHost> ......

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.