Module Apache instructions

About Apache

Apache Is the world's number one Web server software. It can run on almost all widely used computer platforms. Because of its cross platform and security, it is one of the most popular Web server-side software. It is fast, reliable and can be expanded through a simple API to compile Perl/Python and other interpreters into the server. At the same time, Apache is transliterated as Apache, a tribe of North American Indians, called Apache, in the southwest of the United States. It is also the name of a foundation, an armed helicopter and so on Baidu Encyclopedia Apache

Apache Web server software has the following features:

  • 1. Support the latest HTTP/1.1 communication protocol
  • 2. Have a simple and powerful file based configuration process
  • 3. Support common gateway interface
  • 4. Support IP based and domain name based virtual hosts
  • 5. Support multiple ways of HTTP authentication
  • 6. Integrated Perl processing module
  • 7. Integrated proxy server module
  • 8. Support real-time monitoring of server status and customization of server logs
  • 9. Support server side include instruction (SSI)
  • 10. Support secure Socket layer (SSL)
  • 11. Provide tracking of user session process
  • 12. Support FastCGI
  • 13. Java servlets can be supported through third-party modules

Apache features

TODO Apache function postposition, no need for now

Apache parameter details

Reference link: centos7 deploy Apache server

Enclosure

Centos7 Apache configuration example

Step 1 configure the scfan.conf configuration file:

# /etc/httpd/conf.d/scfan.conf
User scfan
Group scfan

<VirtualHost *:80>
    DocumentRoot "/home/scfan/project/FISAMS/branches/branch_scfan/src/web/fdm"
    <Directory "/home/scfan/project/FISAMS/branches/branch_scfan/src/web/fdm">
        options Indexes MultiViews
        AllowOverride all
        Allow from all
    </Directory>
</VirtualHost>

Step 2 rename welcome.conf:

# After renaming, testing 123 will no longer be displayed, but a detailed error will be displayed
mv  /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.bak

Step 3 restart the service:

/bin/systemctl restart httpd.service

Report errors: StackOverFlow - You don't have permission to access / on this server. , the following steps have solved this problem, which can be used for reference here

Step 4 directory authorization:

# Single level authorization is adopted to avoid the permission change of the whole directory file
[root@fdm conf]# chmod +x  /home/scfan/project/FISAMS/branches/branch_scfan/src/web/fdm
[root@fdm conf]# chmod +x  /home/scfan/project/FISAMS/branches/branch_scfan/src/web/
[root@fdm conf]# chmod +x  /home/scfan/project/FISAMS/branches/branch_scfan/src/
[root@fdm conf]# chmod +x  /home/scfan/project/FISAMS/branches/branch_scfan/
[root@fdm conf]# chmod +x  /home/scfan/project/FISAMS/branches/
[root@fdm conf]# chmod +x  /home/scfan/project/FISAMS/
[root@fdm conf]# chmod +x  /home/scfan/project
[root@fdm conf]# chmod +x  /home/scfan
[root@fdm conf]# chmod +x  /home

Step 5 modify the configuration file / etc/httpd/conf/httpd.conf:

# Configure the scfan.conf configuration file corresponding to the listening port
41 #Listen 12.34.56.78:80
42 Listen 80
43 Listen 8888
44 LimitRequestLine 40940  # Limit the Apache request length and increase it according to actual needs

# Note the following code
105 # <Directory />
106 #     AllowOverride none
107 #     Require all denied
108 # </Directory>

Step 6 restart the service:

/bin/systemctl restart httpd.service

Apache test page

The Apache test page means:

The Apache test page means that your server is properly configured and ready to use. Technically, this page is the default index page when you first install the Apache Web server.

How to make the Apache test page disappear

Just open the / var/www/index.html file and modify or delete it (although it may trigger new errors). Under Red Hat Enterprise Linux/CentOS/Fedora Core, rename or delete the file / etc/httpd/conf.d/welcome.conf to make sure you don't see the Apache test page.

You can now add content to the directory / var/www/html /. Note that before you do so, users who visit your site will see the default page, not your content. To prevent the use of this page, follow the instructions in the file / etc/httpd/conf.d/welcome.conf.

Apache problem log

Apache has not been designed to serve pages while running as root

Problem Description:

Unable to start httpd service under root

Log information:

[root@cf8d90d17e9a ~]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2019-12-16 02:06:58 UTC; 25s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 9553 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 9552 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 9552 (code=exited, status=1/FAILURE)

Dec 16 02:06:58 cf8d90d17e9a systemd[1]: Starting The Apache HTTP Server...
Dec 16 02:06:58 cf8d90d17e9a httpd[9552]: AH00526: Syntax error on line 1 of /etc/httpd/conf.d/fdm.conf:
Dec 16 02:06:58 cf8d90d17e9a httpd[9552]: Error:\tApache has not been designed to serve pages while\n\trunning as root.  There are known ...
Dec 16 02:06:58 cf8d90d17e9a systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Dec 16 02:06:58 cf8d90d17e9a kill[9553]: kill: cannot find process ""
Dec 16 02:06:58 cf8d90d17e9a systemd[1]: httpd.service: control process exited, code=exited status=1
Dec 16 02:06:58 cf8d90d17e9a systemd[1]: Failed to start The Apache HTTP Server.
Dec 16 02:06:58 cf8d90d17e9a systemd[1]: Unit httpd.service entered failed state.
Dec 16 02:06:58 cf8d90d17e9a systemd[1]: httpd.service failed.

resolvent:

For configuration of / etc/httpd/conf.d/fdm.conf, User and Group cannot be root, just modify to other users

User fdm
Group fdm
<VirtualHost *:80>
    DocumentRoot /home/fdm/web/fdm
    <Directory /home/fdm/web/fdm>
        options Indexes MultiViews
        AllowOverride all
        Allow from all
    </Directory>
</VirtualHost>

Forbidden You don't have permission to access xxx.html

Problem Description:

Insufficient file permissions

Solution 1:

# Tier one authorization
chmod +x /dira
chmod +x /dira/dirb/
chmod +x /dira/dirb/index.html
# Or directly chmod 777 -R /dira/dirb/index.html

Solution 2:

Modify the configuration file / etc/httpd/conf/httpd.conf

DocumentRoot "/home/fdm/web/fdm"

Solution 3:
Modify the configuration file / etc/httpd/conf/httpd.conf

# Note the following code
105 # <Directory />
106 #     AllowOverride none
107 #     Require all denied
108 # </Directory>

In the above cases, different solutions to different problems can be used in superposition.

Apache considerations

Reference resources

Use & simple configuration & complex configuration & parameter details & related instructions

SuperScfan Published 41 original articles, won praise 10, visited 40000+ Private letter follow

Topics: Apache Web Server CentOS Python