Apache Web Server

Haz click aquí para leer en Español

Disclaimer: This is not a “best Minecraft servers”

Let’s do Linux! One of the most amazing things you can do in Linux is Apache webserver. Do you know what Apache server is? Let’s find out!

Apache webserver is a server responsible for accepting HTTP requests. Static (text, images) and dynamic (scripts). It is a cross platform server hosting that can be used as a dedicated server and provides great security (apache https). It will give you great modularity. One of the most popular bundles is the LAMP (Linux, Apache, Mysql and Python).

The group of developers of this new software started to call themselves the “Apache Group“.

It is very easy to install the server:

  • yum install httpd –> Installation, easy peasy
  • rpm -q httpd –> Check current installed Apache server version
    • /etc/httpd/conf/httpd.conf –> main conf file. Please backup the httpd.conf file before editing

Most important variables from the configuration file:

  1. ServerRoot: Path to the Apache server configuration, error_log and access_log files. The default location is: /etc/httpd
  2. PidFile: Process identification number for httpd. Apache spawns numerous child processes when running to accommodate the web traffic. Allows you to monitor and manipulate your server process. The more requests the more processes
  3. ServerName: This variable is where you declare your web site name. Ex: http://www.test-apache.com
  4. DocumentRoot: Where your web documents(html files, images, etc) should be located. It is possible to reference files in other directories using aliases and symlinks. The default location is: /var/www/html
  5. ErrorLog: It is a relative path to the ServerRoot default location logs/error_log. However, don’t forget that /etc/httpd/logs is a symbolic link to /var/log/httpd (so error log is here)
  6. Alias: To use a pseudonym for your site
  7. Listen: Tells the Web server what port to use for incoming connections. By default, port 80 is used (not secure) and we can modify it to point to HTTPS, port 443 (secure), this is the jewel in the crown!
Has the Apache server hosting been installed?

rpm -q httpd –> Check apache package

Are Linux permissions a nightmare?

Not really, if you understand the basics of permissions, the most critical ones are when it comes to SELinux (Security Enhanced Linux). In this example, I have two websites where I can access one of them and not the other. Why? WHYYYYY!?!

Yep, the permissions, you are right!

In this case I copied the folder where I am hosting my website /webdata to /mysite

As you see from the above image, the context type is different and httpd_sys_content (httpd user) is not allowed to access the directory 😦

You can see above that one of the sites is not accessible, nothing to worry about. We need to change the security context:

  • chcon -R -t httpd_sys_content_t /mysite –> To change file SELinux security context. -R recursevely and -t type
  • semanage fcontext -a -t httpd_sys_content_t  /mysite –> Make permanent changes to Linux context. -a Add policy -t context type
SElinx policy in place

In case you want to verify if the policy has been added to SELinux:

  • cat /etc/selinux/targeted/contexts/files/file_contexts.local –> to check if the policy has been added to SELinux

For my following entries, I will write about ftp server, nginx, SELinux. Stay tuned and follow the blog!

If you have time, check my other posts and let me know if you have done something similar.


Para saber mas de finanzas e inversión parteI y parteII

Para saber más de Apache aqui

Para saber mas de Ansible aqui

11 thoughts on “Apache Web Server

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

<span>%d</span> bloggers like this: