**Title: Initial Server Setup and Installing Nginx on Ubuntu 18.04**
---
**Step 1: Initial Server Setup**
1. **Log in as Root User:**
```
ssh root@yourserverip
```
2. **Create a New User:**
```
adduser kanhu
```
3. **Grant Sudo Privileges:**
```
usermod -aG sudo kanhu
```
4. **Switch to the New User:**
```
su - kanhu
```
5. **Copy SSH Keys:**
```
rsync --archive --chown=kanhu:kanhu ~/.ssh /home/kanhu
```
6. **Access the Server with New User:**
```
ssh kanhu@yourserverip
```
---
**Step 2: Installing Nginx**
1. **Install Nginx:**
```
sudo apt install nginx
```
2. **Add New User to www-data Group (for Nginx access):**
```
sudo gpasswd -a www-data $USER
```
3. **Create a Test Directory:**
```
mkdir test
```
4. **Create an Index File:**
```
sudo nano test/index.html
```
5. **Edit Nginx Configuration:**
```
sudo nano /etc/nginx/sites-available/default
```
Change `root /var/www/html;` to `root /home/kanhu/test;`. Save and exit.
6. **Test Nginx Configuration:**
```
sudo nginx -t
```
7. **Restart Nginx:**
```
sudo systemctl restart nginx
```
---
**Summary:**
This guide outlines the initial setup of an Ubuntu 18.04 server, including creating a new user with sudo privileges, setting up SSH access, and installing Nginx. Additionally, it provides instructions on configuring Nginx to serve content from a custom directory and adds a new user to the `www-data` group for seamless integration with Nginx. This setup allows for easy management of web content and enhances server security.
0 Comments
Post a Comment