Centos7.4 server installation of apache and solutions to problems encountered during the installation process

Centos7.4 server installation of apache and solutions to problems encountered during the installation process

This article describes how to install Apache on a CentOS 7.4 server and how to solve problems that arise during the installation process. Share with you for your reference, the details are as follows:

1. Install httpd

1. Before installation, check whether there is an installed httpd.rpm package in the system. If not, it is not installed. If yes, delete it with rpm -e corresponding rpm package name.

#rpm -qa | grep httpd

2. Use yum to install (automatically install dependent packages), simple and convenient

#yum -y install httpd

3. After successful installation, use httpd-v to check the installed Apache version and find the location of the Apache configuration file

#find / -name "httpd.conf"

4. Back up the source configuration file to prevent failure in recovery

#cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak

5. Start Apache service

#systemctl start httpd.service

6. Automatically start the Apache service at boot

#systemctl enable httpd.service Start httpd automatically at boot
#systemctl disable httpd.service Do not start httpd at boot

7. Check the status of httpd

#systemctl status httpd.service

2. Problems during installation

1. Apache failed to start. Job for httpd.service failed because the control process exited with error code. See “systemctl status httpd.service” and “journalctl -xe” for details

Execute the command and check the error message

#systemctl status httpd.service

[root@cloud1 bin]# systemctl status httpd.service
  httpd.service - The Apache HTTP Server
  Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
  Active: failed (Result: exit-code) since 2018-11-26 11:13:09 CST; 6min ago
   Docs: man:httpd(8)
      man:apachectl(8)
 Process: 9915 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
 Process: 9913 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 9913 (code=exited, status=1/FAILURE)
Nov 26 11:13:09 cloud1.localdomain httpd[9913]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
Nov 26 11:13:09 cloud1.localdomain httpd[9913]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
November 26 11:13:09 cloud1.localdomain httpd[9913]: no listening sockets available, shutting down
November 26 11:13:09 cloud1.localdomain httpd[9913]: AH00015: Unable to open logs
Nov 26 11:13:09 cloud1.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
November 26 11:13:09 cloud1.localdomain kill[9915]: kill: cannot find process ""
Nov 26 11:13:09 cloud1.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
Nov 26 11:13:09 cloud1.localdomain systemd[1]: Failed to start The Apache HTTP Server.
Nov 26 11:13:09 cloud1.localdomain systemd[1]: Unit httpd.service entered failed state.
Nov 26 11:13:09 cloud1.localdomain systemd[1]: httpd.service failed.

The problem is that port 80 is occupied

Solution:

Check the usage of port 80

① . netstat -lnp|grep 80

tcp 0 0 192.168.180.68:61027 0.0.0.0:* LISTEN 6289/oproxyd
tcp 0 0 :::80 :::* LISTEN 846/httpd
tcp 0 0 ::ffff:192.168.180.68:7001 :::* LISTEN 32015/java

Kill the process occupying port 80

② . kill -9 846

③. If the first two methods do not work, restart and then start the httpd service

2. Apache failed to start, httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName

①. Enter the Apache configuration file

vi /etc/httpd/conf/httpd.conf

② ./ServerName Find ServerName

#ServerName www.example.com:80

Remove the # in front of it

:wq wqSave and exit

③. Restart the service

systemctl restart httpd.service

I hope this article will help you configure your CentOS server.

You may also be interested in:
  • Installation and configuration of mysql 8.0.15 under Centos7
  • Tutorial on installing lamp-php7.0 in Centos7.4 environment
  • Centos7.5 configuration java environment installation tomcat explanation
  • The best way to start a jar package project under Centos7 server
  • Alibaba Cloud Centos7 installation and configuration of SVN
  • How to add custom system services to CentOS7 systemd
  • How to add Nginx to system services in CentOS7
  • Detailed explanation of the basic use of centos7 firewall in linux
  • Detailed explanation of Nginx installation, SSL configuration and common commands under Centos7.x
  • CentOS 7 switching boot kernel and switching boot mode explanation

<<:  JS implements the sample code of decimal conversion to hexadecimal

>>:  MYSQL updatexml() function error injection analysis

Recommend

How to solve the problem of ERROR 2003 (HY000) when starting mysql

1. Problem Description When starting MYSQL, a pro...

After reading the introduction of CSS box model, you will not be confused

The property names often heard in web design: con...

Vue.js implements the nine-grid image display module

I used Vue.js to make a nine-grid image display m...

Detailed explanation of Vue data proxy

Table of contents 1. What I am going to talk abou...

Zabbix's psk encryption combined with zabbix_get value

Since Zabbix version 3.0, it has supported encryp...

A brief discussion on ifnull() function similar to nvl() function in MySQL

IFNULL(expr1,expr2) If expr1 is not NULL, IFNULL(...

Detailed explanation of the mysql database LIKE operator in python

The LIKE operator is used in the WHERE clause to ...

MySQL master-slave replication configuration process

Main library configuration 1. Configure mysql vim...

Solution to mysql failure to start due to insufficient disk space in ubuntu

Preface Recently, I added two fields to a table i...

How to solve the problem of forgetting the root password of Mysql on Mac

I haven't used mysql on my computer for a lon...

Sample code for implementing markdown automatic numbering with pure CSS

The origin of the problem The first time I paid a...

Summary of Vue3 combined with TypeScript project development practice

Table of contents Overview 1. Compositon API 1. W...

Detailed Introduction to Nginx Installation and Configuration Rules

Table of contents 1. Installation and operation o...