# Resources for Setting Up New Server

[Upcloud](https://upcloud.com/pricing/) and [A2hosting](https://www.a2hosting.com/vps-hosting) are two fantastic VPS hosting.

## SETTING UP NEW SERVER ON A2 HOSTING

{% hint style="info" %}
This is for CentOS 7 on A2server
{% endhint %}

A2 hosting was chosen because of:

{% embed url="https://websitesetup.org/hosting-reviews/best-vps-hosting-review/" %}



### 1. Setting up LAMP stack

{% embed url="https://www.howtoforge.com/tutorial/centos-lamp-server-apache-mysql-php/" %}

### &#x20;   2. Accessing your account:

{% embed url="https://www.a2hosting.com/kb/getting-started-guide/accessing-your-account" %}

* SSH set up: [https://www.a2hosting.com/kb/getting-started-guide/accessing-your-account/using-ssh-secure-shell](https://www.a2hosting.com/kb/getting-started-guide/accessing-your-account/using-ssh-secure-shell)
  * [https://www.digitalocean.com/community/tutorials/initial-server-setup-with-centos-7](https://www.digitalocean.com/community/tutorials/initial-server-setup-with-centos-7)
  * [https://wiki.centos.org/HowTos/Network/SecuringSSH](https://wiki.centos.org/HowTos/Network/SecuringSSH)
* SSH using keys: [https://www.a2hosting.com/kb/getting-started-guide/accessing-your-account/using-ssh-keys](https://www.a2hosting.com/kb/getting-started-guide/accessing-your-account/using-ssh-keys)
  * [https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server](https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server)
  * Possible error while setting up ssh key: [http://unix.stackexchange.com/questions/36540/why-am-i-still-getting-a-password-prompt-with-ssh-with-public-key-authentication](http://unix.stackexchange.com/questions/36540/why-am-i-still-getting-a-password-prompt-with-ssh-with-public-key-authentication)
    * [http://askubuntu.com/questions/110814/server-keeps-asking-for-password-after-ive-copied-my-ssh-public-key-to-authoriz](http://askubuntu.com/questions/110814/server-keeps-asking-for-password-after-ive-copied-my-ssh-public-key-to-authoriz)
* Disable SSH login for root (recommended): [https://www.a2hosting.com/kb/getting-started-guide/accessing-your-account/disabling-ssh-logins-for-root](https://www.a2hosting.com/kb/getting-started-guide/accessing-your-account/disabling-ssh-logins-for-root)
* FTP: [https://www.a2hosting.com/kb/getting-started-guide/accessing-your-account/using-ftp-file-transfer-protocol](https://www.a2hosting.com/kb/getting-started-guide/accessing-your-account/using-ftp-file-transfer-protocol)
* SCP: [https://www.a2hosting.com/kb/getting-started-guide/accessing-your-account/transferring-files-using-scp-secure-copy](https://www.a2hosting.com/kb/getting-started-guide/accessing-your-account/transferring-files-using-scp-secure-copy)

&#x20;  &#x20;

### &#x20;   3. Back-up data (document from A2), also should see Khoi’s document on OE:

* [https://www.a2hosting.com/kb/getting-started-guide/backing-up-your-data/backups-on-dedicated-servers-and-vps](https://www.a2hosting.com/kb/getting-started-guide/backing-up-your-data/backups-on-dedicated-servers-and-vps)
* [https://www.experts-exchange.com/questions/28429417/CentOS-How-to-Back-Up-and-Restore-Full-Server.html](https://www.experts-exchange.com/questions/28429417/CentOS-How-to-Back-Up-and-Restore-Full-Server.html)
* To make a script to delete files older than X days when there is less than XGB left, see this:
  * [https://stackoverflow.com/questions/8110530/check-free-disk-space-for-current-partition-in-bash/37167246#37167246](https://stackoverflow.com/questions/8110530/check-free-disk-space-for-current-partition-in-bash/37167246#37167246)
* To monitor uptime for the server, use: [https://uptimerobot.com/](https://uptimerobot.com/)
* Rclone is used to automatically backup file toGoogle Drive account:
  * Install: [https://rclone.org/install/](https://rclone.org/install/)
  * Configuration for Google Drive: [https://rclone.org/drive/](https://rclone.org/drive/) or [https://linoxide.com/file-system/configure-rclone-linux-sync-cloud/](https://linoxide.com/file-system/configure-rclone-linux-sync-cloud/)
  * Usage: [https://rclone.org/docs/](https://rclone.org/docs/)
  * For Rclone filtering: [https://rclone.org/filtering/](https://rclone.org/filtering/)
* To back up the whole VPS, follow this:
  * [https://www.serverpronto.com/kb/page.php?id=Backing+Up+and+Restore+Your+Server](https://www.serverpronto.com/kb/page.php?id=Backing+Up+and+Restore+Your+Server)
  * This is more options: [http://tamxuanla.blogspot.com/2015/10/how-to-backup-full-centos-server\_22.html](http://tamxuanla.blogspot.com/2015/10/how-to-backup-full-centos-server_22.html)
  * Modified script as this:

```bash
tar cvpzf /backups/backup-$(date +\%Y\%m\%d).tgz --exclude=/proc --exclude=/lost+found --exclude=/backups --exclude=/dev --exclude=/sys --exclude=/boot/grub --exclude=/etc/fstab --exclude=/etc/sysconfig/network-scripts/ --exclude=/etc/udev/rules.d/70-persistent-net.rules --exclude=/home/some_other_folders
```

&#x20;  &#x20;

### &#x20;   4. Install EPEL repository on CentOS 7:

{% embed url="https://www.a2hosting.com/kb/developer-corner/linux/installing-the-epel-repository-on-centos" %}



### &#x20;   5. Change timezone on Linux shell:&#x20;

{% embed url="https://www.a2hosting.com/kb/developer-corner/linux/changing-the-time-zone-in-the-linux-shell" %}



### &#x20;   6. Set default text Editor:

{% embed url="https://www.a2hosting.com/kb/developer-corner/linux/setting-the-default-text-editor-in-linux" %}



### &#x20;   7. Obtaining free SSL certificate (from Let’sEncrypt):

* First: Make sure you have the _your\_site.com_.conf file inside /etc/httpd/conf.d. Following the following website: [https://www.rosehosting.com/blog/apache-virtual-hosts-on-centos/](https://www.rosehosting.com/blog/apache-virtual-hosts-on-centos/) ; For more elaborate see: [https://devops.profitbricks.com/tutorials/how-to-set-up-name-based-virtual-hosting-vhosts-with-apache-web-server-on-centos-7-1/](https://devops.profitbricks.com/tutorials/how-to-set-up-name-based-virtual-hosting-vhosts-with-apache-web-server-on-centos-7-1/)
* Optional, here is another way the step above can be set up (Note: this website set up a bit different than the one above, specifically, the above website use /etc/httpd/conf.d/ instead of /etc/httpd/sites-enabled): [https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7](https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7)
* danielromogroup.com and other sites on this server has been set up using /etc/httpd/conf.d/_site.com_.conf
* This is a good installation for Certbot Let’sEncrypt (ignore the multiple certificate setting): [https://certbot.eff.org/#centosrhel7-apache](https://certbot.eff.org/#centosrhel7-apache)
* Using Certbot (Intro): [https://certbot.eff.org/#centosrhel7-other](https://certbot.eff.org/#centosrhel7-other)
* Doc: [https://certbot.eff.org/docs/intro.html](https://certbot.eff.org/docs/intro.html)
* Rate limit for Let’sEncrypt: [https://community.letsencrypt.org/t/rate-limits-for-lets-encrypt/6769](https://community.letsencrypt.org/t/rate-limits-for-lets-encrypt/6769)
* To test your SSL for your site:
  * &#x20;[https://www.ssllabs.com/ssltest/](https://www.ssllabs.com/ssltest/)
  * [https://www.digicert.com/help/](https://www.digicert.com/help/)
* To read more about SSL: [https://yoast.com/dev-blog/move-website-https-ssl/](https://yoast.com/dev-blog/move-website-https-ssl/)
* To strengthen your SSL connection:
  * Info:
    * &#x20;[https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/](https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/)
    * [https://yoast.com/dev-blog/move-website-https-ssl/](https://yoast.com/dev-blog/move-website-https-ssl/)
  * Remove SSLv3 SSLv2: [https://www.digitalocean.com/community/tutorials/how-to-protect-your-server-against-the-poodle-sslv3-vulnerability](https://www.digitalocean.com/community/tutorials/how-to-protect-your-server-against-the-poodle-sslv3-vulnerability)
  * HSTS Strict-Transport-Security:
    * &#x20;[https://itigloo.com/security/how-to-configure-http-strict-transport-security-hsts-on-apache-nginx/](https://itigloo.com/security/how-to-configure-http-strict-transport-security-hsts-on-apache-nginx/)
    * [https://raymii.org/s/tutorials/HTTP\_Strict\_Transport\_Security\_for\_Apache\_NGINX\_and\_Lighttpd.html](https://raymii.org/s/tutorials/HTTP_Strict_Transport_Security_for_Apache_NGINX_and_Lighttpd.html)
    * [https://www.howtoforge.com/community/threads/hsts-centos-7.72384/](https://www.howtoforge.com/community/threads/hsts-centos-7.72384/)
  *   OCSP Stapling: help with all SSL security connection a little faster:

      * [https://wiki.apache.org/httpd/OCSPStapling](https://wiki.apache.org/httpd/OCSPStapling)
      * [https://www.digitalocean.com/community/tutorials/how-to-configure-ocsp-stapling-on-apache-and-nginx](https://www.digitalocean.com/community/tutorials/how-to-configure-ocsp-stapling-on-apache-and-nginx)
      * [https://www.digicert.com/ssl-support/apache-enable-ocsp-stapling-on-server.htm](https://www.digicert.com/ssl-support/apache-enable-ocsp-stapling-on-server.htm)



### &#x20;   8. Setting up owner of /var/www/html folders, to easy update website:&#x20;

{% embed url="https://www.centos.org/forums/viewtopic.php?t=47214" %}



### &#x20;   9. Creating groups, users; Assigning passwords:

* [https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-a-centos-7-server](https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-a-centos-7-server)
* Assinging password and require immediate pass change after log in: [https://access.redhat.com/documentation/en-US/Red\_Hat\_Enterprise\_Linux/7/html/Security\_Guide/chap-Hardening\_Your\_System\_with\_Tools\_and\_Services.html#sec-Password\_Security](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide/chap-Hardening_Your_System_with_Tools_and_Services.html#sec-Password_Security)
*   Add Linux users to a group: [http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/](http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/)

    * [http://www.howtogeek.com/50787/add-a-user-to-a-group-or-second-group-on-linux/](http://www.howtogeek.com/50787/add-a-user-to-a-group-or-second-group-on-linux/)
    * [http://www.tecmint.com/add-users-in-linux/](http://www.tecmint.com/add-users-in-linux/)



### &#x20;   10. Force using https access using .htaccess:

* [http://www.inmotionhosting.com/support/website/ssl/how-to-force-https-using-the-htaccess-file](http://www.inmotionhosting.com/support/website/ssl/how-to-force-https-using-the-htaccess-file)
* [http://www.webhostinghub.com/help/learn/website/ssl/force-website-to-use-ssl](http://www.webhostinghub.com/help/learn/website/ssl/force-website-to-use-ssl)



### &#x20;   11. Configure PHP to read .htaccess file on a CentOS 7 server

We need to modify the `httpd.conf` file:

```bash
vi /etc/httpd/conf/httpd.conf
```

In this file: after `<Directory "/var/www/html">`, modify `AllowOverride None` to `AllowOverride Options`.

&#x20;Save the file (hit Esc, type `:wq` and then Enter)

![](https://1203731670-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fuser-guides%2F-Lv6iQsxlcmWQpVpKscm%2F-Lv6kkl8HVY8UYGf8Wlw%2F14.png?generation=1575309486800017\&alt=media)

Restart httpd service:

```bash
systemctl restart httpd
```



### &#x20;   12. Dreamweaver:

*   Creating Template:

    * [http://www.thesitewizard.com/dreamweaver/dreamweaver-cs5-5-tutorial-7.shtml](http://www.thesitewizard.com/dreamweaver/dreamweaver-cs5-5-tutorial-7.shtml)
    * [https://helpx.adobe.com/dreamweaver/using/creating-dreamweaver-template.html](https://helpx.adobe.com/dreamweaver/using/creating-dreamweaver-template.html)
    * [https://www.siteground.com/tutorials/dreamweaver/dreamweaver\_templates.htm](https://www.siteground.com/tutorials/dreamweaver/dreamweaver_templates.htm)
    * [http://www.dummies.com/how-to/content/how-to-save-any-page-as-a-dreamweaver-template.html](http://www.dummies.com/how-to/content/how-to-save-any-page-as-a-dreamweaver-template.html)



### &#x20;   13. Setting up firewall for CentOS 7:

* **DON’T FORGET TO OPEN PORT 7822 FOR SSH WHILE USING A2 SERVER**
* If forgot to open port 7822, follow this link: [https://www.a2hosting.com/kb/getting-started-guide/accessing-your-account/using-the-solusvm-control-panel#Using-the-serial-console](https://www.a2hosting.com/kb/getting-started-guide/accessing-your-account/using-the-solusvm-control-panel#Using-the-serial-console)
* [https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-firewalld-on-centos-7](https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-firewalld-on-centos-7)
* [http://www.codero.com/knowledge-base/questions/377/](http://www.codero.com/knowledge-base/questions/377/)
* [https://www.linode.com/docs/security/firewalls/introduction-to-firewalld-on-centos](https://www.linode.com/docs/security/firewalls/introduction-to-firewalld-on-centos)



### &#x20;   14. MySQL/MariaDB

* Error that need to change packet size: [http://stackoverflow.com/questions/8062496/how-to-change-max-allowed-packet-size](http://stackoverflow.com/questions/8062496/how-to-change-max-allowed-packet-size)



### &#x20;   15. Installing phpMyAdmin

* [https://docs.phpmyadmin.net/en/latest/setup.html](https://docs.phpmyadmin.net/en/latest/setup.html)
* [https://github.com/phpmyadmin/phpmyadmin/wiki](https://github.com/phpmyadmin/phpmyadmin/wiki)
* [https://docs.phpmyadmin.net/en/latest/setup.html](https://docs.phpmyadmin.net/en/latest/setup.html)
* [https://docs.phpmyadmin.net/en/latest/faq.html#security](https://docs.phpmyadmin.net/en/latest/faq.html#security)
* [https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-with-apache-on-a-centos-7-server](https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-with-apache-on-a-centos-7-server)



### &#x20;   16. Working with tar files

* [http://www.techbrown.com/linux-tar-commands-examples-centos-7-rhel-7.shtml](http://www.techbrown.com/linux-tar-commands-examples-centos-7-rhel-7.shtml)
* [https://www.tecmint.com/18-tar-command-examples-in-linux/](https://www.tecmint.com/18-tar-command-examples-in-linux/)
* [https://stackoverflow.com/questions/18681595/tar-a-directory-but-dont-store-full-absolute-paths-in-the-archive](https://stackoverflow.com/questions/18681595/tar-a-directory-but-dont-store-full-absolute-paths-in-the-archive)
* [https://serverfault.com/questions/339762/how-to-tarball-a-directory-without-carrying-over-path-to-folder](https://serverfault.com/questions/339762/how-to-tarball-a-directory-without-carrying-over-path-to-folder)



### &#x20;   17. Setting up multiple websites with multiple domains on the same server

* On current A2 hosting, the server config can be found in /etc/httpd/conf/httpd.conf
* [https://devops.profitbricks.com/tutorials/how-to-set-up-name-based-virtual-hosting-vhosts-with-apache-web-server-on-centos-7-1/](https://devops.profitbricks.com/tutorials/how-to-set-up-name-based-virtual-hosting-vhosts-with-apache-web-server-on-centos-7-1/)
* Setting up multiple Let’sEncrypt certificates for multiple hosts on the same server: [https://www.digitalocean.com/community/tutorials/how-to-set-up-let-s-encrypt-certificates-for-multiple-apache-virtual-hosts-on-ubuntu-14-04](https://www.digitalocean.com/community/tutorials/how-to-set-up-let-s-encrypt-certificates-for-multiple-apache-virtual-hosts-on-ubuntu-14-04) (this is for Ubuntu)
  * For CentOS, generate two #.conf files in /etc/httpd/conf.d/. For example: /etc/httpd/conf.d/site1.com.conf and /etc/httpd/conf.d/site2.com.conf. Each conf file is the apache set up for the site. Example of the content of site2.com.conf:

```bash
<VirtualHost XX.XX.XX.XX:80>
    DocumentRoot /var/www/html/site2.com
    ServerName server.site2.com
    ServerAlias site2.com www.site2.com
</VirtualHost>
```

*
  * After that use “/usr/local/sbin/certbot --apache -d example.com -d [www.example.com](http://www.example.com/)” . The content of site2.com.conf file will be automatically changed. Here is example of the content of site2.com.conf after running the “certbot-auto…”

```bash
<VirtualHost XX.XX.XX.XX:80>
    DocumentRoot /var/www/html/site2.com
    ServerName server.site2.com
    ServerAlias site2.com www.site2.com
</VirtualHost>
<IfModule mod_ssl.c>
    <VirtualHost XX.XX.XX.XX:443>
        DocumentRoot /var/www/html/site2.com
        ServerName server.site2.com
        ServerAlias site2.com www.site2.com
        SSLCertificateFile /etc/letsencrypt/live/site2.com/cert.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/site2.com/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateChainFile /etc/letsencrypt/live/site2.com/chain.pem
    </VirtualHost>
</IfModule>
```

* Read here for more info about a set up a conf file for SSL certificate: [https://www.linode.com/docs/security/ssl/ssl-certificates-with-apache-2-on-centos](https://www.linode.com/docs/security/ssl/ssl-certificates-with-apache-2-on-centos)



### &#x20;   18. Working with WordPress

* Initial Install: [https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-centos-7](https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-centos-7)
  * From A2: [https://www.a2hosting.com/kb/installable-applications/manual-installations/installing-wordpress-manually](https://www.a2hosting.com/kb/installable-applications/manual-installations/installing-wordpress-manually)
  * WP security, from A2 hosting: [https://www.a2hosting.com/kb/security/application-security/wordpress-security](https://www.a2hosting.com/kb/security/application-security/wordpress-security)
  * UpdraftPlus Plugin is used to back up WordPress. To restore Wordpress
    * Create a fresh install of wordpress as in the link above
    * Install Updraftplus plugin
    * Load the backup files
    * Restore
    * If there is issue after restore, check here first. A common issue is the rewrite link issue (Wordpress Permanet link), follow the solution in “Using ‘Pretty’ permalinks” in this link: [https://codex.wordpress.org/Using\_Permalinks](https://codex.wordpress.org/Using_Permalinks)
  * Optimizing WP, from A2 hosting: [https://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-the-a2-optimized-plugin](https://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-the-a2-optimized-plugin);
    * &#x20;[https://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix](https://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix)
* Multiple sites (using WordPress) installation: [https://www.digitalocean.com/community/tutorials/how-to-set-up-multiple-wordpress-sites-using-multisite](https://www.digitalocean.com/community/tutorials/how-to-set-up-multiple-wordpress-sites-using-multisite)
* Moving Wordpress site(s): [https://codex.wordpress.org/Moving\_WordPress](https://codex.wordpress.org/Moving_WordPress)
* Uninstall Wordpress: [https://www.tipsandtricks-hq.com/how-to-uninstall-and-reinstall-wordpress-245](https://www.tipsandtricks-hq.com/how-to-uninstall-and-reinstall-wordpress-245)
* To use 1-click update on Wordpress, you need
  * Wordpress folder (in this case /var/www/html/baylorcpritlab.com) to be owned by apache:apache with 755 permission
  * To secure Wordpress, all **folders** inside the baylorcpritlab.com should have 755 persmission and all **files** should have 644 permission
* Wordpress login trouble: [https://codex.wordpress.org/Login\_Trouble](https://codex.wordpress.org/Login_Trouble)



### &#x20;   19. Setting up Booked Scheduler

* See here for official guide: [http://www.bookedscheduler.com/help](http://www.bookedscheduler.com/help)
* Note: when change the info in the config.php file, make sure to change the:
  1. Install password
  2. User: to ‘root’
  3. Password to ‘_root\_passowrd_’
* Also see: [https://www.bookedscheduler.com/images/community-contrib/CentOS\_booked\_v3.pdf](https://www.bookedscheduler.com/images/community-contrib/CentOS_booked_v3.pdf)
