A well-known architecture in linux is lamp: linux + apache + mysql + php.
Apache has always been the most popular Web server on the Internet.
Background process: httpd
Script:/etc/rc. d/init. d/httpd
Port: 80 (http), 443 (https)
Required RPM package: httpd
Configuration path:/etc/httpd /*
Default website storage path:/var/www /*
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/
Advantages: free, stable, and fast
Install apache first
Rpm-ivh httpd-2.2.3-31.el5.centos.i386.rpm
Music httpd-2.0.54 apache
Cd apache
./Configure -- prefix =/usr/local/apache2 -- enable-module = so
Make
Make install
Install apache to/usr/local/apache and configure apache to support dso
Check Apache installation
[Root @ host CentOS] # rpm-qa | grep httpd
Httpd-2.2.3-31.el5.centos
Httpd-manual-2.2.3-31.el5.centos
System-config-httpd-1.3.3.3-1.el5
After installation, start Apache,
[Root @ host CentOS] # service httpd start
Now let's take a look at what this service has brought to us, because this experiment should be conducted together with the DNS Service experiment, but the time issue is not done together. when accessing the WEB service, we do not use a Domain Name Server, but only the IP address of the corresponding WEB Server
To configure Apache for the content you want to configure on the ferry port, we will configure Apache step by step !!!
This is the directory where all apache configuration files are stored.
[Root @ host ~] # Ll/etc/httpd/
Total 28
Drwxr-xr-x 2 root 4096 11-04 17:08 conf
Drwxr-xr-x 2 root 4096 11-04 :09 conf. d
Lrwxrwxrwx 1 root 19 11-04 logs->.../var/log/httpd
Lrwxrwxrwx 1 root 27 11-04 modu08 modules->.../usr/lib/httpd/modules
Lrwxrwxrwx 1 root 13 11-04 run->.../../var/run
This is the directory where webpage files are stored, generally in html
[Root @ host ~] # Ll/var/www/
Total 48
Drwxr-xr-x 2 root 4096 2009-09-04 cgi-bin
Drwxr-xr-x 3 root 4096 11-04 17:08 error
Drwxr-xr-x 2 root 4096 2009-09-04 html
Drwxr-xr-x 3 root 4096 11-04 17:08 icons
Drwxr-xr-x 14 root 4096 11-04 manu09 manual
Drwxr-xr-x 2 webalizer root 4096 11-04 usage
[Root @ host ~] # Ll/var/www/html/
Total 0
Apache main configuration file
[Root @ host ~] # Vim/etc/httpd/conf/httpd. conf
Each line in httpd. conf contains a statement. The Backslash "\" can be used at the end of the line to wrap the line. However, the backslash and the next line cannot contain any other characters (including blank spaces)
The configuration statements of httpd. conf are case-insensitive except for the parameter values of the options. You can use the "#" sign before each line to indicate comments.
Global configuration parameters.
ServerType
Select the method for activating the server. It can be inetd or standalone.
It should be an independent stationalone by default.
ServerRoot
Set the absolute path for Apache installation
#
ServerRoot "/etc/httpd"
TimeOut
Sets the maximum wait time for the server to receive the message.
#
Timeout 120
KeepAlive
Set whether the server enables the continuous request function. Generally, the real server must enable the function.
#
KeepAlive Off
MaxKeepAliveRequests
Sets the maximum number of consecutive requests that the server can accept.
#
MaxKeepAliveRequests 100
#
KeepAliveTimeout 15 \ maximum number of user waiting times for 'consecutive 'requests
##
# Server-Pool Size Regulation (MPM specific)
##
# Prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork. c>
StartServers 8 \ sets the number of sub-processes required for activation
MinSpareServers 5 \ sets the minimum number of idle sub-Processes
MaxSpareServers 20 \ sets the maximum number of idle sub-Processes
ServerLimit 256
MaxClients 256 \ sets the maximum number of service requests that can be provided to users at the same time
MaxRequestsPerChild 4000
</IfModule>
Port
Set the default port of the http service.
User/Group
Set the executor and Group of the server program
#
User apache
Group apache
As we said, webpage files are stored in/var/www/html by default. Now we can write a webpage by ourselves, which is simple to test.
[Root @ host ~] # Ll/var/www/html/
Total 0
[Root @ host ~] # Echo hello, this is my home, welcome! >/Var/www/html/index.html
[Root @ host ~] # Ll/var/www/html/
Total 8
-Rw-r -- 1 root 48 02-19 :50 index.html
[Root @ host ~] # Cat/var/www/html/index.html
Hello, this is my home, welcomell!
Then access your server again to see what changes have taken place.
In the main configuration file (/etc/httpd/conf/ default.html, etc.
#
DirectoryIndex index.html. var
We construct a php web website according to our own ideas... GO...
An index. php is added, so that we can test apache's support for php later. If you cannot find it, the redhat test page will appear.
#
DirectoryIndex index.html index. php
We tested to change the default website directory to the root directory.
Step 1: Modify the DocumentRoot location 1.
Step 2: modify directory permission settings 2
Restart the httpd service.
[Root @ host webphp] # service httpd restart
Client browsing
Now let's build a PHP page by ourselves...
[Root @ host webphp] # ll/root/webphp
Total 0
[Root @ host webphp] # echo hello. This is a php webservers! >/Root/webphp/index. php
[Root @ host webphp] # ll/root/webphp
Total 8
-Rw-r -- 1 root 32 02-19 13:58 index. php
Let's take a look at our own PHP page...
The basic service architecture in LINUX has been tested! However, for the normal maintenance after the architecture is completed, you still need to have a better environment to study hard...
-------------------