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

Sample Analysis of Apache Service

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)05/31 Report--

This article shows you a sample analysis of Apache services, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Apache HTTP SERVER

An open source web server software of the Apache Software Foundation

Curl-I view the web server type of the website

Before the experimental test, add domain name resolution / etc/host to the host that initiated the access request.

First, install httpd

Yum install httpd

Systemctl start httpd

Systemctl enable httpd # Boot start

Firewall-cmd-- permanent-- add-service=http # add the http service to the firewall list

Firewall-cmd-reload

Firewall-cmd-- permanent-- add-service=https # add the https service to the firewall list

Firewall-cmd-reload

Modify the main configuration file of http to modify the default settings

/ etc/httpd/conf/httpd.conf

42 Listen 8 modify the default network port of the http service

119 DocumentRoot "/ www/html" # modify the default release directory for the http service

one hundred and twenty

121 Require all granted

one hundred and twenty two

one hundred and sixty seven

168 DirectoryIndex webtest index.html# default release file, read the former first, the former is not available and then read the latter #

one hundred and sixty nine

Firewall-cmd-add-port=8080/tcp

Systemctl restart httpd

Mkdir / www/html/webtest

The selinux tag is consistent with the default release directory

Ls-Z / var/www/

Semanage fcontext-a-t httpd_sys_content_t "/ www (/. *)?"

Restorecon-vvFR / www

2. Virtual host

One host provides services for multiple websites

Vim / etc/httpd/conf.d/default.conf

Documentroot / www/html

Customlog "logs/default.log" combined# specifies the log

Vim / etc/httpd/conf.d/news.conf

Servername news.laosiji.com

Serveralias news# setting alias

Documentroot / www/laosiji.com/news

Customlog "logs/news.log" combined

Require all granted

Vim / etc/httpd/conf.d/xxx.conf

Mkdir-p / www/laosiji.com/news

Vim / www/laosiji.com/news/webtest# is the same as the file name set earlier

Third, authorize designated users to access

First create a new release directory as the test directory

Mkdir-p / www/laosiji.com/admin/webtest

When htpasswd-cm / etc/httpd/htpasswd admin # adds a user again, note that the option is-m, otherwise the previous information will be overwritten

New password:

Re-type new password:

An encrypted password file / etc/httpd/htpasswd will be generated

Authuserfile "/ etc/httpd/htpasswd"

Authtype basic

Authname "Please input username and password"

Require user admin# or set to valid-user all authorized users can log in

Custom self-signed certificate

Yum install crypto-utils mod_ssl

Genkey laosiji.com # hostname, generating certificate

Select next

There are several key specifications to choose from

In the generation key # you can click the keyboard or move the mouse when the generation is slow

Select no not to send an authentication request to CA

Select next

Fill in some information (note that the host name is not misspelled)

Vim / etc/httpd/conf.d/login.conf# New login for testing

Mkdir / www/laosiji.com/login

Servername login.laosiji.com

Serveralias login

Documentroot / www/laosiji.com/login

Customlog "logs/login.log" combined

SSLEngine on

SSLCertificateFile / etc/pki/tls/certs/laosiji.com.crt

SSLCertificateKeyFile / etc/pki/tls/private/laosiji.com.key

Require all granted

# Web page redirection

Servername login.laosiji.com

Rewriteengine on

Rewriterule ^ (/. *) $https://%{HTTP_HOST}$1 [redirect=301]

Systemctl restart httpd

Vim / www/laosiji.com/login/webtest# write a test text

Welcome log in

Open a browser to write to login.laosiji.com

Select Add Excetion

Select Confirm Security Exception

When you get the certificate, the web page can be displayed normally.

The above is a sample analysis of Apache services. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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

Network Security

Wechat

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

12
Report