> For the complete documentation index, see [llms.txt](https://mamawhocode.gitbook.io/devops/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mamawhocode.gitbook.io/devops/pre-requisite/server.md).

# Server

### What is a server?

A computer that provides services or resources. The programs on that computer makes them servers, jusk like your laptop could be a DB server if you install MySQL and let other computers access into.

<figure><img src="/files/qV65nly3y5lgMXnVPeXB" alt=""><figcaption></figcaption></figure>

### Apache Web Server

<details>

<summary>Install</summary>

```sh
# install apache
yum install httpd

# start apache web server service
service httpd start
service httpd status
```

</details>

<details>

<summary>Logs</summary>

```bash
# view access & error logs
cat /var/log/httpd/access_log
cat /var/log/httpd/error_log
```

</details>

<details>

<summary>Port</summary>

* the default port is 80

</details>

<details>

<summary>Config file: httpd.conf</summary>

`httpd.conf` is a config file used by Apache web server to control how the server responds to incomming requests. The file specifies things like which ports the server should listen on, where the web applications are located, which modules are loaded, and how security should be enforced.

After configuration, remmember restart httpd service to make it work.

#### Apache config file

```bash
# view configuration file
vim /etc/httpd/conf/httpd.conf
```

#### Document root

`DocumentRoot` in httpd.conf specify where to look at first.

```apacheconf
DocumentRoot "/var/www/html"
```

#### Host

{% code title="/etc/hosts" %}

```apacheconf
# multiple domains point to the same IP address
127.0.0.1 localhost
127.0.0.1 www.example.com
127.0.0.1 www.oranges.com
```

{% endcode %}

#### Virtual host

Multiple web site can be hosted in the same server if you configure `virutal hosts` in `httpd.conf`

```apacheconf
<VirutalHost *:80>
    ServerName www.organces.com
    DocumentRoot /var/www/oranges
</VirutalHost>
```

#### Include another conf file

```apacheconf
Include conf/houses.conf
```

</details>

### Nginx web server

```bash
# install Nginx
sudo apt-get install -y nginx

# confirm Nginx is running
ps auwx | grep nginx
```

### Commands

```sh
# check server timezone
# EST
date +%Z
timedatectl

# change timezone to America/New_York
sudo timedatectl set-timezone America/New_York

# update OS
sudo apt-get update
```
