Web Site Services

Source: Internet
Author: User

Web Site Services
First, Apache website Service Foundation
1.Apache Introduction
1) origin of Apache
"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 platforms; using the standard B/S architecture
Apache is the software that is formed after the integration and refinement of several Web server programs, which is named "A patchy server", which means "server program formed after modifying (patching) code based on the original Web service program"

1995发布1.0版本,后有"Apache Group"负责该项目的管理和维护;1999年在"Apache Group"基础成立Apache软件基金会(Apache Software Foundation,ASF)"Apache HTTP Server"为ASF旗下著名软件项目之一,正式名称为"httpd"

2) main features of Apache
Open Source: Anyone can freely use, fully embodies the spirit of open source software
Cross-platform applications: can be run on most hardware and software platforms, thanks to the open source code of Apache
Support for various web programming languages: Perl, PHP, Python, Java, ASP, etc.
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
Run stable: can be used to build Web sites with heavy load traffic
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. Installing the HTTPD server
1) Preparatory work
Chkconfig--level iptables off
Vim/etc/sysconfig/selinux
Selinux=disabled
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
Vim/etc/sysconfig/network//Modify host Name
Networking=yes
hostname=www.xueluo.org
Getenforce//view current SELinux status
Reboot
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
Options:
--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
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/
Added to path search paths, users do 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    # chkconfig:35 82 21        /服务识别参数,指定3、5级别顺序启动标识号    # description:Startup script for the Apache HTTP Server

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

chkconfig --add httpd           //将httpd添加为系统服务chkconfig --list httpd          //查看httpd服务的自启动状态

Second, the basic configuration of HTTPD server
Deployment process for 1.WEB sites
1) determine the website 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
...
Look for the row (97 rows), set the site name

apachectl -t

Detects httpd.conf file for syntax errors; "Syntax OK" is correct

B. Start the 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
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
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 options that allow symbolic links to be used, and whether to jump to the corresponding connection path when a symbolic connection is accessed
AllowOverride None
Override configuration in the implicit control file is not allowed; Do you want to find the. htaccess file as the configuration file
Order Deny,allow
The order in which the access control policies are applied; Check the Forbidden setting first, all allowed without forbidden
Deny from all
Prohibit anyone from accessing this area
</Directory>
Iii. Statistics of website visits
1. Deploying the Awstats Analysis System
1) Install the Awstats package

tar -zxvf awstats-7.3.tar.gz            //解压缩

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///Enter tool catalogue

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

./awstats_configure.pl              //执行配置脚本

A. Specifying the HTTPD Master profile path

B. Setting the log type
The logging format for the HTTPD server needs to be "combined" (default is 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"
...

mkdir /var/lib/awstats              //创建数据存放目录

4) Perform log analysis and set cron scheduled tasks
chmod +x awstats_updateall.pl//Give update script EXECUTE permission

./awstats_updateall.pl Now//update the Awstats information immediately and count it in the statistics database

crontab -e   */5 * * * *  /usr/local/awstats/tools/awstats_updateall.pl now/etc/init.d/crond start && chkconfig --level 35 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   

Enables automatic Web page adjustment and simplified access operations
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.