How to install Apache on Fedora

If you are a webdeveloper or if you just need to start local (or remote) web server (e.g. Apache, NGINX, lighttpd, Jigsaw, ehmm IIS) it is very easy process on GNU/Linux. Except MS IIS of course. My favourite is Apache and in this post I'll show you how to easy install and run it on Fedora 23 and Fedora 24.
Apache in RPM is called httpd. So just install it.
$ sudo dnf install httpd
Done. That's it.

Run, Apache, run!

How to start Apache web server?
$ systemctl start httpd

How to stop Apache web server?
$ systemctl stop httpd

How to restart Apache web server? For example if you are doing some configuration changes.
$ systemctl restart httpd

How to start it automatically at boot time?
$ systemctl enable httpd.service

You also need to allow the Apache service on Firewall:
$ firewall-cmd --permanent --zone=public --add-service=http
$ firewall-cmd --permanent --zone=public --add-service=https
$ firewall-cmd --reload

Now direct your browser to http://localhost, and you should see the Apache2 start page:

Apache2.4 start page on Fedora

Useful information

Apache's default document root is /var/www/html on Fedora, and the configuration file is /etc/httpd/conf/httpd.conf. Additional configurations are stored in the /etc/httpd/conf.d/ directory. And default log files (access_log and error_log) are in the /var/log/httpd/ directory. Note: you need root rights to access this directory.

And how to run PHP? We will see in the next post about installing PHP. ;)

Comments