The Complete Guide to Install Nginx on CentOS 7 with phpMyAdmin

Securing the Server

User configuration:
  1. Add your username.
    adduser yourusername
  2. Set your password.
    passwd yourusername
  3. Set credentials.
    visudo
    ## Allow root to run any commands anywhere
    root    ALL=(ALL)       ALL
    yourusername        ALL=(ALL)       ALL
    

    To save your configuration, press escape key then input the following command, then hit enter.

    :wq
SSH security (login access security):
  1. Login with your username, input your password if asked.
    ssh yourusername@your_ipv4
  2. Generate your SSH key. You can do it on a Linux bash command line or Windows (PuTTYgen) computer. In this case, I have used Linux.
    ssh-keygen
  3. Upload it to your server using the command below.
    scp ~/.ssh/id_rsa.pub yourusername@your_ipv4:
  4. Create a directory from your server.
    mkdir .ssh
  5. Move and change permission to the public key.
    mv id_rsa.pub .ssh/authorized_keys
    chown -R example_user:example_user .ssh
    chmod 700 .ssh
    chmod 600 .ssh/authorized_keys
    
  6. Browse SSH configuration.
    sudo nano /etc/ssh/sshd_config
  7. Disable root login and use ssh authentication by updating to the data below.
    PasswordAuthentication no
    PermitRootLogin no
    
  8. Restart SSH using the command below.
    sudo systemctl restart sshd
Firewall Configuration (Using FirewallD):
  1. Enable the firewall service  using the command below.
    sudo firewall-cmd --permanent --add-service=ssh
  2. Input the following command if you want to use a new port and restarted your SSH server.
    sudo firewall-cmd --permanent --remove-service=ssh
    sudo firewall-cmd --permanent --add-port=4444/tcp
    
  3. For HTTP server, enable the service using the command below.
    sudo firewall-cmd --permanent --add-service=http
  4. For HTTPS or SSL server, enable the service using the command below.
    sudo firewall-cmd --permanent --add-service=https
  5. For email or SMTP server, enable the service using the command below.
    sudo firewall-cmd --permanent --add-service=smtp
  6. To check for additional services, type the following command.
    sudo firewall-cmd --get-services
  7. To check if for your configuration, type the command below.
    sudo firewall-cmd --permanent --list-all
  8. If you are finished, restart or reload your firewall.
    sudo firewall-cmd --reload
  9. Lastly, enable your firewall at boot by the command below.
    sudo systemctl enable firewalld

Probewise

I create WordPress themes and plugins with simplicity for all people. I am also a blogger, layout artist and a computer technician.

Join the Discussion

Your email address will not be published. Required fields are marked *

Back to top