Skip to content
Search

Apache httpd

lastmod 2020-11-29created 2014-03-2039 edits

The Apache Web Server is an http web server maintained by the Apache Software Foundation. It runs not only on Unix-like systems such as BSD and Linux, but also on platforms such as Microsoft Windows and Novell NetWare.

Categories

Service port

To change the service port, edit the Listen entry in the /conf/httpd.conf file under the httpd root directory.

Checking module availability

With <IfModule>, you can check whether a module is in use (available).

<IfModule [MODULE_NAME]>
...
</IfModule>

Command line options

httpd -M
Dump a list of loaded Static and Shared Modules.
httpd -t
Uses the directives in the file config on startup.
apache2ctl -S
Get a list of all virtual hosts which are defined in all apache configuration files.

With OpenSSL

To install Apache together with OpenSSL, add --with-openssl to the configure options.

MAC OSX Commandline option

If installation fails on MAC OSX and the log message shows an error related to the x86_64 architecture, add the following options.

./configure darwin64-x86_64-cc -fPIC

Enabling Apache HTTPS

On CentOS, mod_ssl is not included in the default packages. Install it as follows.

$ yum install mod_ssl

Ubuntu

sudo a2enmod ssl
sudo a2ensite default-ssl
sudo service apache2 reload
sudo service apache2 restart

Applying an SSL certificate for Apache HTTPS

Install OpenSSL, generate the certificate, then copy the files.

$ sudo apt-get install openssl
## ...
$ sudo cp server.crt /etc/ssl/certs
$ sudo cp server.key /etc/ssl/private

Apache HTTP 2.x configuration

$ sudo a2ensite ssl <- /etc/apache2/mods-available/ssl 파일을 /etc/apache2/mods-enabled/ssl 파일에 링크시킴

Httpd-ssl.conf configuration

$ vi /etc/apache2/conf.d/httpd-ssl.conf

Edit it as follows.

<ifmodule ssl_module>
<VirtualHost _default_:443>
#   General setup for the virtual host
...
#   SSL Engine Switch:
#   Enable/Disable SSL for this virtual host.
SSLEngine on
SSLCertificateFile /etc/ssl/certs/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key

Finally, restart Apache.

$ sudo service apache2 restart

Troubleshooting

A collection of problems that can occur while using Apache httpd.

(13) Permission denied

On Unix-like OSes, only root can access well-known ports of 1024 or below. So run it with the root account.

Apache 2.4: 403 Status code

If you get a 403 Forbidden status code after updating to Apache 2.4.x, add Require all granted as shown below.

<Directory "your directory here">
   Order allow,deny
   Allow from all
   # New directive needed in Apache 2.4.3: 
   Require all granted
</Directory>

404 Not found

When using scripts such as php, accessing a path that does not exist as an actual directory can cause a 404 error. In this case, remove the Indexes option.

<VirtualHost _default_:443>
    ...
    <Directory /var/www/html>
        Options -Indexes
        AllowOverride All
        <IfModule mod_authz_core.c>
            Require all granted
        </IfModule>
    </Directory>
    ...
</VirtualHost>

AH00548

Testing the configuration file prints the following warning.

AH00548: NameVirtualHost has no effect and will be removed in the next release

NameVirtualHost is going to be removed in the future. You can remove this directive.

Favorite site

Log file management

Guide & Tip

References


  1. Www.superuser.co.kr.7z ↩

author Zer0 sitemap