Web Site Services

Source: Internet
Author: User

I. Apache Website Service Basics 1.Apache Introduction 1) The origin of Apache

1. "Apache http Server" Open source software project distinguished representative, using standard HTTP network protocol to provide web browsing services, can run on a variety of operating system platform; Use standard C/s architecture

2.Apache is a number of previous Web server programs to consolidate, perfect after the formation of the software, which is called "A patchy server", meaning "based on the original Web Service Program code Modification (patch) formed after the server program"

3.1995 release of version 1.0, after the "Apache Group" responsible for the management and maintenance of the project; 1999 Apache Foundation (Apache Software foundation,asf)

4. "Apache HTTP Server" is one of ASF's famous software projects, officially named "HTTPd"

2) main features of Apache

1. Open Source: Anyone is free to use, fully embodies the spirit of open source software

2. Cross-platform applications: can be run on most hardware and software platforms, thanks to the Apache source code open

3. Support for various web programming languages: Perl, PHP, Python, Java, ASP, etc.

4. Modular design: The Apache function is divided into various modules, what functions need to directly load the corresponding modules, and support commercial self-development module

5. Stable operation: can be used to build a Web site with heavy load traffic

6. Good security: The maintenance team provides patches for discovered vulnerabilities in a timely manner

3) Major versions of Apache

1.X: Up to 1.3, this version inherits the excellent features and configuration management style since the Apache Server version 1.0, with good compatibility, stability; currently stopped maintenance

2.x:apache joins many new features, new configuration syntax and management style

4) httpd error code

100 (continuation)-The requestor shall continue to make the request. The server returns this code to indicate that the first part of the request was received and is waiting for the remainder

101 (Switching protocol)-the requestor has asked the server to switch protocols, the server has confirmed and is ready to switch

200 (Success)-The server has successfully processed the request. Typically, this indicates that the server provided the requested Web page. If this status code is displayed for your robots.txt file, it means that Googlebot has successfully retrieved the file

201 (created)-the request was successful and the server created a new resource

202 (accepted)-the server has accepted the request but has not yet processed

203 (non-authoritative information)-The server has successfully processed the request, but the information returned may be from another source

204 (no content)-The server successfully processed the request, but did not return any content

205 (reset content)-The server successfully processed the request, but did not return any content. Unlike the 204 response, this response requires the requestor to reset the document view (for example, to clear the form contents to enter new content)

206 (partial)-The server successfully processed a partial GET request

300 (multiple options)-the server can perform a variety of actions for the request. The server can select an action based on the requestor (user agent) or provide a list of actions for the requestor to select

301 (permanent move)-the requested page has been permanently moved to a new location. When the server returns this response (a response to a GET or HEAD request), the requestor is automatically forwarded to the new location. You should use this code to tell Googlebot that a webpage or website has been permanently moved to a new location

302 (temporary Move)-the server is currently responding to a request from a Web page in a different location, but the requestor should continue to use the original location to respond to subsequent requests. This code, similar to the 301 code that responds to the GET and HEAD requests, will automatically move the requestor to a different location, but you should not use this code to tell Googlebot that a Web page or site has moved because Googlebot will continue to crawl the original location and index it

303 (See other locations)-The server returns this code when the requestor should use a separate GET request for the different locations to retrieve the response. For all requests except HEAD, the server automatically goes to a different location

304 (unmodified)-The requested webpage has not been modified since the last request. When the server returns this response, the Web page content is not returned, and if the page has not changed since the requestor last requested it, you should configure the server to return this response (known as the If-modified-since HTTP header). The server can tell the search engine that the spider/bot has not changed since the last crawl, thus saving bandwidth and overhead


305 (use proxy)-the requestor can only use the proxy to access the requested Web page. If the server returns this response, it also indicates that the requestor should use the proxy

307 (Temporary redirect)-The server is currently responding to a request from a Web page in a different location, but the requestor should continue to use the original location to respond to subsequent requests. This code, similar to the 301 code that responds to the GET and HEAD requests, will automatically move the requestor to a different location, but you should not use this code to tell Googlebot that a page or site has moved because Googlebot will continue to crawl the original location and index it

400 (Bad Request)-the server does not understand the syntax of the request

401 (unauthorized)-Request authentication required. The server may return this response for the requested web page after login

403 (Forbidden)-The server rejects the request. If you see this status code when Googlebot tries to crawl a valid webpage on your site (you can see this information on the Web crawl page under Google Webmaster Tools Diagnostics), your server or host may have denied Googlebot access

404 (Not found)-the server could not find the requested webpage. For example, this code is often returned for pages that do not exist on the server, and if you do not have a robots.txt file on your site and you see this status code on the robots.txt page of the Google Webmaster Tools Diagnostic tab, this is the correct status code. However, if you have a robots.txt file and you see this status code, your robots.txt file may be named incorrectly or in the wrong location (the file should be in the top-level domain named robots.txt), or if you see this status code for Googlebot crawled URLs ( On the HTTP error page of the Diagnostics tab, it means that Googlebot follows a potentially invalid link to another page (an old link or an incorrectly entered link)

405 (method Disabled)-disables the method specified in the request

406 (not accepted)-unable to respond to the requested Web page using the requested content attribute

407 (requires proxy authorization)-This status code is similar to 401 (unauthorized), but specifies that the requestor should authorize the use of the proxy. If the server returns this response, it also indicates that the requestor should use the proxy

408 (Request timed out)-timeout occurs when the server waits for a request

409 (conflict)-the server has a conflict when the request is completed. The server must include information about the conflict in the response. This code may be returned by the server in response to a PUT request that conflicts with the previous request, as well as a list of differences of two requests

410 (Deleted)-The server returns this response if the requested resource has been permanently deleted. This code is similar to the 404 (not Found) code, but is sometimes used to replace the 404 code in cases where the resource existed before and now does not exist. If the resource has been permanently moved, you should use 301 to specify a new location for the resource

411 (valid length required)-The server does not accept requests that do not contain a valid Content-Length header field

412 (precondition not met)-one of the prerequisites that the server did not satisfy the requestor to set in the request

413 (Request entity too Large)-the server cannot process the request because the request entity is too large to exceed the server's processing power

414 (The requested URI is too long)-The requested URI (usually the URL) is too long for the server to process

415 (Unsupported media type)-The requested format is not supported by the requested page

416 (Request scope does not meet requirements)-if the page cannot provide the requested range, the server returns this status code

417 (unmet expectations)-the server does not meet the requirements of the "expected" Request header field

500 (server internal error)-The server encountered an error and could not complete the request

501 (not implemented)-the server does not have the ability to complete the request. For example, this code may be returned when the server does not recognize the request method

502 (Bad Gateway)-the server received an invalid response from the upstream server as a gateway or proxy

503 (Service Unavailable)-the server is not currently available (due to overloading or downtime maintenance). Usually, it's just a temporary state.

504 (Gateway Timeout)-The server acts as a gateway or proxy, but does not receive requests from the upstream server in a timely manner

505 (HTTP version not supported)-the HTTP protocol version used in the request is not supported by the server

2. Install HTTPD server 1) prepare to work

RPM-E httpd--nodeps

/uninstall httpd installed using RPM mode

Vim/etc/sysconfig/network-scripts/ifcfg-eth0/Configure Network Address

Device=eth0

Type=ethernet

Onboot=yes

Nm_controlled=no

Bootproto=static

ipaddr=192.168.1.10

netmask=255.255.255.0

gateway=192.168.1.1

dns1=192.168.1.1

Vim/etc/sysconfig/network/Modify Host Name

Networking=yes

hostname=www.xueluo.org

2) source code compilation and installation

A. Unpacking

Tar-zxvf/root/httpd-2.2.17.tar.gz-c/usr/src/

cd/usr/src/httpd-2.2.17/

B. Configuration

./configure--prefix=/usr/local/httpd--enable-so--enable-rewrite--enable-charset-lite--enable-cgi

Solution:

--prefix: Specifying the program installation directory

--ENABLE-SO: Start dynamic load module support, make it extensible; is the core module to provide DSO support

--enable-rewrite: Start Page address rewriting function for website optimization and directory Migration maintenance

--enable-charset-lite: Enable character set support to support Web pages that use various character set encodings

--ENABLE-CGI: Enable CGI scripting support, extend the application access of the Web site, usually the execution of CGI involves security issues, any system can be called, so it is common to put CGI in a specific directory to execute

C. Compiling and installing make && make install

3) Confirm the installation results

Ls/usr/local/httpd

Solution:

Service Catalog:/usr/local/httpd/

Master configuration file:/usr/local/httpd/conf/httpd.conf

Web directory:/usr/local/httpd/htdocs/

Service script:/usr/local/httpd/bin/apachectl

Execution Program:/USR/LOCAL/HTTPD/BIN/HTTPD

Access log:/usr/local/httpd/logs/access_log

Error log:/usr/local/httpd/logs/error_log

4) Optimized execution path (added to the search path for user-friendly use)

Ln-s/usr/local/httpd/bin/*/usr/local/bin//Add to path search, user does not need full command path to use

5) Add httpd as System service (can control power-on self-boot via chkconfig tool)

CP/USR/LOCAL/HTTPD/BIN/APACHECTL/ETC/INIT.D/HTTPD/Copy the default script file to the System control directory

Vim/etc/init.d/httpd

#!/bin/bash

# CHKCONFIG:35 82 21/Service identification parameter, specify 3, 5 level sequential start identification number

# Description:startup script for the Apache HTTP Server

/file at the beginning of add chkconfig recognition configuration, do not add chkconfig add service times wrong

Chkconfig--add httpd/Add httpd as a system service

Chkconfig--list httpd/View the self-starting status of the HTTPD service

Second, the basic configuration of the HTTPD server 1. Deployment process for a Web site 1) determine the site name, IP address

Need to apply for a legitimate public IP address, and to the DNS provider to apply for a domain name, the corresponding host DNS resolution record

Internal use of the company can be configured independently, without public IP, but to use the internal domain name can be set up DNS and the corresponding resolution record added, modify the/etc/hosts file to improve the local resolution speed

2) Configure and start the HTTPD service

A. Configuring the HTTPD service

vim/usr/local/httpd/conf/httpd.conf/Edit httpd master configuration file

ServerName www.xueluo.com:80

/Find the row (97 rows), set the site name

APACHECTL-T/Detect httpd.conf file with syntax error; "Syntax OK" is correct

B. Start httpd service/etc/init.d/httpd start

NETSTAT-UTPLN | grep httpd

3) Deploy Web page documentation

Compile and install the HTTPD service, the Web site root directory is the/usr/local/httpd/htdocs directory, the Web page document is copied to this directory; Index.html test Web page is provided by default

4) Accessing the Web site in the client

5) View the Web site's access status

Access log:/usr/local/httpd/log/access_log

Error log:/usr/local/httpd/log/error_log

Tail-f/usr/local/httpd/logs/access_log

Tail-f/usr/local/httpd/logs/error_log

2.httpd.conf configuration file 1) global configuration Items

Key value "value" configuration format

ServerRoot: Service Catalog

ServerAdmin: Admin Mailbox

User: Identity of users running the service; default daemon

Group: The identity of the groups running the service; default daemon

ServerName: Domain name of the Web server

DocumentRoot: root directory of Web document

Listen: IP address, port number of the listener, default 80 port

Pidfile: Save the HTTPD process PID number file

DirectoryIndex: Default index page file; default Home file index.html

Errorlog: Location of error log files

Customlog: The location of the access log file; default type common

LogLevel: Logging level, default is warn (warning)

Timeout: Network connection timed out, default is 300 seconds

KeepAlive: Whether to remain connected, optional on or off

Maxkeepaliverequests: Maximum number of requested files per connection

KeepAliveTimeout: Time-out when maintaining connection status

Include: Additional configuration files that need to be included

2) zone Configuration Items

<directory/> Restricting access to the root directory

Options followsymlinks control option, allows symbolic links to be used, and whether to jump to the corresponding connection path when accessing a symbolic connection

AllowOverride None allows overlay configuration in the implicit control file; Do you want to find the. htaccess file as a profile

Order Deny,allow The application sequence of the access control policy; Check the Forbidden setting first, no forbidden all allowed

Deny from all prohibits anyone from accessing this zone

</Directory>

III. website Visits statistics 1. Deploy Awstats Analysis System 1) Install Awstats Package

TAR-ZXVF awstats-7.3.tar.gz/Decompression

MV Awstats-7.3/usr/local/awstats/Mobile Decompression directory, the software is directly available for the green version

2) Create a profile for the site to be counted

cd/usr/local/awstats/tools//Access Tool catalogue

chmod +x awstats_configure.pl/Give configuration script Execute permissions

./awstats_configure.pl/Execute configuration script

A. Specifying the HTTPD Master profile path

B. Set the log type to the HTTPD server's logging format as "combined" (default = Common)

C. Creating a configuration file for a specified Web site

D. Subsequent configuration work

Next, the HTTPD service will be restarted automatically (assuming/ETC/INIT.D/HTTPD script exists)

If you need to count other sites, run again./awstats_configure.pl

3) Modify the site statistics configuration file

Vim/etc/awstats/awstats.www.xueluo.org.conf

Logfile= "/usr/local/httpd/logs/access_log"

Dirdata= "/var/lib/awstats"

Mkdir/var/lib/awstats/Create Data storage directory

4) Perform log analysis and set cron scheduled tasks

chmod +x awstats_updateall.pl/give update script EXECUTE permission

./awstats_updateall.pl Now/update awstats information and statistics in the statistics database

Crontab-e

*/5 * * * */usr/local/awstats/tools/awstats_updateall.pl now

/etc/init.d/crond start && chkconfig--level Crond on

2. Access to the Awstats analysis system

http://192.168.1.10/awstats/awstats.pl?config=www.xueluo.org

Vim/usr/local/httpd/htdocs/awstats.html

<meta Http-equiv=refresh content= "0;url=http://192.168.1.10/awstats

/awstats.pl?config=www.xueluo.org ">

<body>

</body>

/implement auto-adjust Web page, simplify access operation

Http://192.168.1.10/awstats.html

Web Site Services

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.