Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CentOS 7.4 build Apache website service

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Blog catalogue

What is Apache?

1. The origin of Apache

2. The main features of Apache

II. Major versions of Apache

Third, install httpd server

1. Mount the CD

2. Source code compilation and installation

3. Apache global configuration items

4. Install DNS domain name resolution service

What is Apache?

Apache HTTP Server is one of the widely used Web application systems. In order to make good use of it, we must first understand its characteristics and its compilation and installation process.

Apache HTTP Server is an outstanding representative of the source software project, provides web browsing services based on the standard HTTP network protocol, and has maintained more than half of the Web server field for a long time. Apache server can run on Linux, UNIX, Windows and other operating system platforms.

1. The origin of Apache

Apache server is a software formed after integration and improvement of several Web server programs that appeared before. its name comes from "A Patchy Server", which means "server program formed after modification (patch) based on the code of the original Web service program."

Apache is managed and maintained by ASF. ASF is a non-profit organization, initially only responsible for the management of "Apache Web" server projects. With the continuous expansion of Web application demand, ASF has gradually increased many open source software projects related to Web technology. As a result, Apache now represents not only the Web server, but also, more broadly, many open source software projects managed by ASF. ASF's official website is ASF's official website.

"Apache HTTP Server" is one of the famous software projects under ASF, and its official name is "Httpd", which is the historical Apache website server.

2. The main features of Apache

The performance of Apache server in function, performance and security is outstanding, which can better meet the application needs of Web server users. Its main features include the following aspects:

Open source: this is one of the important features of the Apache server and the basis for other features.

Cross-platform applications: this feature benefits from the open source code of Apache. Apache servers can run on most hardware and software, so the UNIX operating system can run Apache servers, and it can also run on most Windows system platforms.

Support a variety of Web programming languages: Apache server can support web programming languages including Perl, PHP, Python, Java and so on. Even Microsoft ASP technology can be used in Apache server.

Modular design: Apache does not concentrate all the functions in a single service program, but achieves proprietary functions through standard modules as much as possible, which brings good scalability to the Apache server.

The operation is very stable: the Apache server can be used to build Web sites with heavy load visits, and many well-known enterprise websites use Apache as the Web service software.

Good security: Apache server has relatively good security, which is a common feature of open source software. In addition, the maintenance team of Apache will provide timely patches for the vulnerabilities that have been discovered to provide server programs as secure as possible for all users of Apache. II. Major versions of Apache

The Apache server currently includes versions 1.x and 2.x and is maintained separately. The two versions have some differences, but also have their own characteristics.

The highest version of 1.x series is 1.3. this version inherits the excellent features and configuration management style of Apache server since version 1.0, and has very good compatibility and stability.

Since version 2. 0, many new features have been added to the Apache server, and the configuration syntax and management style used have changed. Third, install httpd server

ISO extraction location: https://pan.baidu.com/s/1Cuy1NrdpQrnQkVZEmECS3g

Extraction code: b6qd

If you don't understand anything about this environment, you can refer to the blog post: making Centos 7.4 operating system template.

1. Mount the CD

Turn on the virtual machine

Configure IP addr

[root@centos01 ~] # vi / etc/sysconfig/network-scripts/ifcfg-ens32 TYPE=EthernetPROXY_METHOD=noneBROWSER_ONLY=noBOOTPROTO=static DEFROUTE=yes NAME=ens32DEVICE=ens32ONBOOT=yesIPADDR=192.168.100.10 NATEMASK=255.255.255.0 2, source code compilation and installation

The process of source code compilation and installation of httpd service mainly includes unpacking, configuration, editing and installation.

[root@centos01 mnt] # mount / dev/cdrom / mnt/ [root@centos01 mnt] # cd / mnt/ [root@centos01 mnt] # cp httpd-2.2.17.tar.gz / usr/src/ [root@centos01 mnt] # tar zxvf httpd-2.2.17.tar.gz-C / usr/src/ [root@centos01 httpd-2.2.17] #. / configure-prefix=/usr/local/httpd-enable-so-enable- Rewrite-enable-charset-lite-enable-cgi

In the above configuration command, the meaning of each option is as follows:

-- prefix: specify the directory in which the httpd service program is installed, such as / usr/local/httpd. -- enable-so: enable dynamic loading module support, and have the ability to further extend functions using httpd. -- enable-rewrite: enables web address rewriting for website optimization and directory migration maintenance. -- enable-charset-lite: starts character set support to support web pages encoded with various character sets. -- enable-cgi: enable CGI script program support to expand the application access ability of the website. [root@centos01 httpd-2.2.17] # make [root@centos01 httpd-2.2.17] # make install [root@centos01 ~] # ls / usr/local/httpd/ bin build cgi-bin conf error htdocs icons include lib logs man manual modules

Under the installed / usr/local/httpd directory, the main subdirectories are used for the following purposes:

/ usr/local/httpd/bin: store all kinds of execution program files of httpd service, including main program httpd, service control tool apachectl, etc. / usr/local/httpd/cgi-bin: store various CGI program files. / usr/local/httpd/logs: stores the log files of the httpd service. / usr/local/httpd/conf: stores various configuration files of httpd service, including main configuration file httpd.conf, enhanced configuration subdirectory extra, etc. / usr/local/httpd/htdocs: stores web documents, including the default home page file index.html, etc. / usr/local/httpd/modules: stores various module files of the httpd service. [root@centos01] # ln-s / usr/local/httpd/bin/* / usr/local/bin/ [root@centos01 ~] # cp / usr/local/httpd/bin/apachectl / etc/init.d/httpd [root@centos01 ~] # chmod + x / etc/init.d/httpd [root@centos01 ~] # vim / etc/init.d/httpd #! / bin/sh # chkconfig: 3585 21 # description:apache server. [root@centos01] # chkconfig-- add httpd [root@centos01] # systemctl start httpd [root@centos01] # systemctl enable httpd httpd.service is not a native service, redirecting to / sbin/chkconfig. Executing / sbin/chkconfig httpd on [root@centos01 ~] # systemctl is-enabled httpd.service [root@centos01 ~] # apachectl-t [root@centos01 ~] # netstat-anptu | grep 80 tcp 0 0 127.0.0.1 tcp 25 0.0.0.0 LISTEN 980/master tcp6 0 0: 80 : * LISTEN 54014/httpd tcp6 0:: 1:25:: * LISTEN 980/master

The Apache service has been built. Now open a client and set up the same network card and the same network segment to access with the browser.

Open the client (the network card setting is the same as Centos)

Client sets IP address

Open a browser to access http://192.168.100.10

Modify the content of the home page of the website

[root@centos01 ~] # vim / usr/local/httpd/htdocs/index.html

Www.bdqn.com

Client revisit

3. Apache global configuration items

In the above settings line, the meaning of each global configuration item is as follows:

ServerRoot: sets the root directory of the httpd server, which contains the subdirectories and files necessary to allow Web sites. By default, the root directory of the httpd server is the installation directory of httpd. The default root directory is / usr/local/httpd, which is the same as the httpd installation directory specified when compiling the installation. In the httpd.conf configuration file, if you specify a directory or file location without using an absolute path, the directory or file location is considered to be under the root of the server. Listen: sets the network port number that the httpd server listens to. The default is 80. User: sets the user identity when running the httpd process. The default is daemon. Group: sets the group identity when running the httpd process. The default is daemon. ServerAdmin: sets the administrator E-mail address of the httpd server, through which you can contact the administrator of the Web site in a timely manner. ServerName: sets the full hostname (hostname + domain name) of the Web site. DocumentRoot: set the root directory of the website, that is, the actual storage path of the web document in the system. Directoryindex: set the site's default index page (home page). You can set multiple home page files, separated by spaces, and the default home page file is index.html. ErrorLog: sets the path to the error log file. The default path is logs/error_log. LogLevel: sets the level of logging. The default level is warn (warning). GustomLog: sets the path and log type to access the log file. The default path is logs/access_log, and the type used is common (common format). PidFile: sets the file used to save the httpd process number (PID). By default, the logs/httpd.pid,logs directory is located in the server root directory of Apache. AddDefaultCharset: sets the character set encoding used by default for pages in the site, such as utf-8,gb2312, etc. Include: contains the contents of another configuration file, you can put the configuration of some special functions into a separate file, and then use the Include configuration item to include it in the httpd.conf file, so that it is easy to maintain the configuration function independently without affecting the main configuration file.

The above configuration items are the main global configuration items in the httpd.conf file.

4. Install DNS domain name resolution service [root@centos01 ~] # umount / mnt/

Switch CD

[root@centos01 ~] # mount / dev/cdrom / mnt/ [root@centos01 ~] # mkdir / etc/yum.repos.d/bak/ [root@centos01] # mv / etc/yum.repos.d/CentOS-* / etc/yum.repos.d/bak/ [root@centos01 ~] # rm-rf / etc/yum.repos.d/Centos-* [root@centos01 ~] # yum-y install bind Bind-chroot [root@centos01 ~] # cp / etc/named.conf / etc/named.conf.bak [root@centos01 ~] # vim / etc/named.conf options {listen-on port 53 {192.168.100.10 }; directory "/ var/named"; allow-query {192.168.100.0; 24;}; zone "bdqn.com" IN {type master; file "bdqn.com.zone";} [root@centos01 ~] # named-checkconf-z / etc/named.conf [root@centos01 ~] # vim / var/named/bdqn.com.zone $TTL 86400 @ SOA bdqn.com. Root.bdqn.com (2019081610 1H 15m 1W 1D) @ NS centos01.bdqn.com. Centos01 A 192.168.100.10 www A 192.168.100.10 [root@centos01 ~] # named-checkzone bdqn.com / var/named/bdqn.com Zone [root@centos01 ~] # chown named:named / var/named/bdqn.com.zone [root@centos01 ~] # chmod + x / var/named/bdqn.com.zone [root@centos01] # systemctl start named [root@centos01] # systemctl enable named.service [root@centos01] # vim / usr/local/httpd/conf/httpd.conf # ServerName www.bdqn.com:80 [root@centos01 ~] # systemctl restart httpd

Client add DNS

Run cmd and enter whether nslookup bdqn.com is parsed properly.

Open a browser to access through the domain name

At this point, the client can be accessed through the IP address or through the domain name.

-this is the end of this article. Thank you for reading-

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report