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

How to install apache/HTTP service with CentOS source code

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

Share

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

This article mainly introduces how CentOS source code to install apache/HTTP services, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

CentOS source code installs apache/HTTP service

Httpd: a program that provides website services

Listening port: 80

Environmental preparation:

Linux CentOS7.3 system

Use one server and one client

First, install httpd

1: install

[root@localhost ~] # systemctl stop firewalld

[root@localhost ~] # setensorce 0

[root@localhost ~] # rpm-e httpd-nodeps # Uninstall the httpd that comes with the system

[root@localhost ~] # mkdir / media/cdrom # create a mount point folder

[root@localhost ~] # mount / dev/cdrom / media/cdrom # Mount CD

[root@localhost ~] # yum-y install gcc* apr-devel apr-util-devel pcre-devel # install the development kit

[root@localhost ~] # tar zxvf httpd-2.4.25.tar.gz # decompression package

[root@localhost ~] # cd httpd-2.4.25

[root@localhost httpd-2.4.25] # / configure-- prefix=/usr/local/httpd-- enable-so-- enable-rewrite-- enable-charset-lite-- enable-cgi

Note:

-- prefix: make the installation directory of the program

-- enable-so: enable the support of the dynamic loading module DSO, so that httpd has the ability to further expand its functions

-- enable-rewrite: enables web address rewriting for website optimization

-- 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@localhost httpd-2.4.25] # make & & make install

[root@localhost httpd-2.4.25] # ls / usr/local/httpd

[root@localhost httpd-2.4.25] # / usr/local/httpd/bin/apachectl start

[root@localhost httpd-2.4.25] # netstat-anpt | grep httpd

[root@localhost httpd-2.4.25] # / usr/local/httpd/bin/apachectl stop

[root@localhost httpd-2.4.25] # netstat-anpt | grep httpd

2: optimize the execution path

[root@localhost httpd-2.4.25] # ln-s / usr/local/httpd/bin/* / usr/local/bin/

[root@localhost httpd-2.4.25] # ls-1 / usr/local/bin/httpd / usr/local/bin/apachectl

# View soft connections

[root@localhost httpd-2.4.25] # httpd- v

[root@localhost httpd-2.4.25] # apachectl start

[root@localhost httpd-2.4.25] # netstat-anpt | grep httpd

[root@localhost httpd-2.4.25] # apachectl stop

[root@localhost httpd-2.4.25] # netstat-anpt | grep httpd

3: add httpd system service

Use chkconfig to add services to the system

[root@localhost httpd-2.4.25] # cp / usr/local/httpd/bin/apachectl / etc/init.d/httpd # copy configuration file

[root@localhost httpd-2.4.25] # vi / etc/init.d/httpd / / Edit configuration file

Add:

#! / bin/sh

# chkconfig:35 85 21

# description:httpd server

[root@localhost httpd-2.4.25] # chkconfig-- add httpd # join the system service and boot up

[root@localhost httpd-2.4.25] # chkconfig-- list httpd

[root@localhost httpd-2.4.25] # service httpd start # start httpd

2. Basic configuration of httpd server

1: determine the name, ip address and domain name of the website

2: configure and start httpd

[root@localhost ~] # vim / usr/local/httpd/conf/httpd.conf

Modify (the preceding number is the line number):

ServerName www.bdqn.com # # 200 lines

[root@localhost ~] # apachectl-t # detect configuration file syntax

2: start the httpd service

[root@localhost ~] # systemctl start httpd # start httpd

[root@localhost ~] # netstat-anpt | grep httpd

3: deploy the web page

[root@localhost ~] # vim / usr/local/httpd/htdocs/index.html # Edit Home Page

It works!

[root@localhost ~] # service httpd restart # restart the httpd service

4: test

Open the website

Http://192.168.10.101

5: check the site visit

[root@localhost ~] # tail / usr/local/httpd/logs/access_log

[root@localhost ~] # tail / usr/local/httpd/logs/error_log

III. Httpd.conf configuration file interpretation

1: global configuration item

[root@localhost ~] # vim / usr/local/httpd/conf/httpd.conf

ServerRoot "/ usr/local/httpd"

Listen 80 # listening port (default 80)

User daemon # user (default daemon)

Group daemon # user Group (default daemon)

ServerAdmin you@example.com # email address

ServerName www.bdqn.com # website domain name

DocumentRoot "/ usr/local/httpd/htdocs" # Web page storage location

DirectoryIndex index.html # default home page

ErrorLog "logs/error_log" # error log file storage location

LogLevel warn # Log level

CustomLog "logs/access_log" common # normal access log

Include conf/extra/proxy-html.conf # Virtual Host path

2: area configuration item

[root@localhost ~] # vim / usr/local/httpd/conf/httpd.conf

# Root directory

AllowOverride none

Require all denied

# restrict the path

Options Indexes FollowSymLinks

AllowOverride None

Require all granted # allows access to all hosts and denies access to everyone

Thank you for reading this article carefully. I hope the article "how to install CentOS source code to install apache/HTTP service" shared by the editor will be helpful to everyone. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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

Development

Wechat

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

12
Report