Linux advanced application - web website service

  • About the author: A cloud computing network operation and maintenance personnel, sharing network and operation and maintenance technology and useful information every day. 

  • Public account: Netdou Cloud Computing School

  •  Motto: Keep your head down and be respectful

  • Personal homepage:  Internet Bean’s homepage

Table of contents

 Preface

1.Apache

1.Apache introduction

 2. Characteristics of Apache

3.Apache version

 2. Install httpd server

1. Advantages of compiling and installing httpd server

2. Obtain the source code package of the Apache server

3. Compile and install steps

4. Steps to compile and install httpd service on CentOS 7:

3. Directory structure of httpd service

1. Main directories and files:

2.Web site deployment process

4.httpd.conf configuration file

1. Global configuration items

2. Commonly used global configuration parameters

Chapter summary


 Preface

I believe everyone has some understanding and practice of deploying web services on Windows. So do you know how to deploy a web website on Linux?


1.Apache

1.Apache introduction

Apache HTTP Server (Apache for short) is an open source web server of the Apache Software Foundation. It can run on most computer operating systems. Due to its cross-platform and security, it is widely used and is one of the most popular web server-side software. one.

Official website: http://httpd.apache.org


 2. Characteristics of Apache

①Open source code, cross-platform application

( Apache server can run on most software and hardware platforms, all UNIX operating systems can run, and it can even run well on Windows system platforms )

②Support multiple web programming languages

(Web programming languages ​​supported by the Apache server include Perl, PHP, Python, java, etc.)

③Modular design, stable operation and good safety


3.Apache version

1.X
  • The highest version currently is 1.3 , which runs stably.
  • Good backward compatibility, but lacks some newer features
2.X
  • The highest version currently is 2.4
  • Has more features
  • Compared with 1.X , the configuration management style is quite different

 2. Install httpd server

1. Advantages of compiling and installing httpd server

  • Has a greater degree of freedom and the functions can be customized
  • Get the latest software version in a timely manner
  • Universally applicable to most Linux versions, easy to transplant and use

2. Obtain the source code package of the Apache server

Address: http://httpd.apache.org/download.cgi


3. Compile and install steps

4. Steps to compile and install httpd service on CentOS 7:

1. Install dependent libraries

sudo yum install gcc make zlib-devel pcre-devel openssl-devel

2. Download the httpd source code package

wget http://httpd.apache.org/download.cgi -O httpd-2.4.51.tar.gz

3. Unzip the source code package

tar -zxvf httpd-2.4.51.tar.gz
cd httpd-2.4.51

4. Configure compilation options

./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --with-mpm=prefork --with-included-apr --with-apxs=/usr/sbin/apxs --with-ssl=/usr/local/httpd/conf/extra --with-pcre=/usr/local/httpd/lib --with-z=/usr/local/httpd --with-curl=/usr/local/curl --enable-deflate --enable-userdir --with-included-apr-util=/usr/local/httpd/include --with-included-apr=$(which apr-1-config) --with-included-apr-util=$(which apr-1-installed) --with-ssl=/usr/local/httpd/conf/extra --with-ssl=$(which openssl)

5. Compile and install

make && sudo make install

6. Start httpd server

sudo /usr/local/httpd/bin/apachectl start

7. Set up auto-start at boot

sudo /usr/local/httpd/bin/a2enmod rewrite
sudo /usr/local/httpd/bin/update-rc.d httpd defaults

3. Directory structure of httpd service

1. Main directories and files:

/usr/local/httpd:Apache安装目录,包含所有的配置文件、模块和其他相关文件。

/usr/local/httpd/conf:Apache的配置文件目录,包含主配置文件httpd.conf和其他一些配置文件,如ssl.conf、vhost.conf等。

/usr/local/httpd/include:Apache的头文件目录,包含所有使用的库和函数的头文件。

/usr/local/httpd/lib:Apache的库文件目录,包含所有编译好的动态链接库文件。

/usr/local/httpd/logs:Apache的日志文件目录,包含访问日志、错误日志和其他一些日志文件。

/usr/local/httpd/modules:Apache的模块目录,包含所有已编译好的模块文件。

/usr/sbin/apxs:Apache的扩展模块编译器。

/usr/sbin/httpd:Apache的主程序,用于启动、停止和管理服务器进程。

/usr/sbin/setenvif:Apache的环境变量设置工具,用于根据请求的User-Agent等信息设置环境变量。


2.Web site deployment process

  1. Determine the name and IP address of the website.
  2. Configure and start the httpd service.
  3. Deploy web documents.
  4. Access the web site on the client.
  5. Check the access status of the web site.


4.httpd.conf configuration file

1. Global configuration items

Determine the global operating parameters of the httpd server

ServerRoot "/usr/local/httpd"
Listen 80
User daemon
Group daemon
ServerAdmin [email protected]
ServerName www.benet.com
DocumentRoot "/usr/local/httpd/htdocs"
DirectoryIndex index.html index.php
ErrorLog logs/error_log
LogLevel warn
CustomLog logs/access_log common
PidFile logs/httpd.pid
CharsetDefault UTF-8
Include conf/extra/httpd-default.conf
……

2. Commonly used global configuration parameters

ServerRoot:服务目录
Listen:监听的IP地址、端口号
User:运行服务的用户身份
Group:运行服务的组身份
ServerAdmin:管理员邮箱
ServerName:网站服务器的域名
DocumentRoot:网页文档的根目录
DirectoryIndex:默认的索引页文件
ErrorLog:设置错误日志文件的路径
LogLevel:记录日志的级别,默认为warn

CustomLog:访问日志文件的位置
PidFile:保存httpd进程PID号的文件
AddDefaultCharset:设置站点中的网页默认使用的字符集编码
Timeout:网络连接超时,默认为300秒
KeepAlive:是否保持连接,可选On或Off
MaxKeepAliveRequests:每次连接最多请求文件数
KeepAliveTimeout:保持连接状态时的超时时间
Include:需要包含进来的其他配置文件

Chapter summary

  • Basic process of Apache compilation and installation
  • How to add system services under Linux system
  • Web site deployment process
  • Commonly used global configuration items in the httpd.conf configuration file
  • Commonly used regional configuration items in the httpd.conf configuration file

Guess you like

Origin blog.csdn.net/yj11290301/article/details/133269373