self hosting
BASIC PROCESS
Install a web server on a computer which will host the website.
Configure some firewall rules to allow traffic in and out of the system.
Log into the router to direct the traffic from the internet to your local computer.
Add a index.html file.
Build considerations
Webservers can be setup for a range of purposes.
MS Windows works well at hosting standard websites but if your mostly familiar with Apple or interested in a personal cloud a Linux distro would be a better fit.
https://about.gitlab.com/ is a good place to start for specific webserver projects.
if your setting up a dedicated PC for your server you should provide it a hardwired ethernet/cat5 internet connection.
SERVER SOFTWARE
For both ease of setup as well as superior compatibility/functionality I suggest installing either XAMPP which contains Apache, MarieDB, PHP, and Perl, or WAMP which contains Apache2, MySQL, and PHP bundled together.
Both XAMPP and WAMP are simple and straight forward to install.
Windows Pro does come with IIS (Internet Information Services) installed which might be a more familiar interface for those only familiar with Windows.
IIS Instructions - WEB SERVER SETUP
Download and install .NET Framework here and here.
Turn on Internet Information Services (IIS)
Open the control panel (Start Menu > control)
Control Panel //> Programs and Features
Turn Windows features on or off
Turn on the following: (check the box next to each)
Internet Information Services
FTP Server
Web Management Tools
World Wide Web Services
Internet Information Services Hostable Web Core
Navigate to: Control Panel > Administrative Tools > View Local Services
Locate and Start: IIS Administrative Services
Internet Information Services (IIS) Manager
Run IIS Manager
Select "Application Pool" > Select "DefaultAppPool" > Right Click "Edit Basic Settings > Choose ".NET Framework" > Managed pipeline mode: Integrated" > Check "Start application pool immediately" > Click "OK" > Select "Sites" > Default Web Site" > Right Click and choose "Edit Bindings" > Click "Add" > Type: http > IP address: All Unassigned > Port: 80 > Host name: blank
Select "Sites > Default Web Site" > Right Click and choose "Edit Bindings" > Click "Add" > Type: http > IP address: 192.168.0.1
(local ip address if you don't know yours open command prompt (cmd) and type "ipconfig" look for your IPv4 Address. > Port: 80 >
Host name: blank Click Application Pools
Right Click "Default Application Pool"
Click "Advanced Settings"
Expand "Process Model"
Change "Idle Time-out (minutes) to "0"
Download and install Microsoft Web Platform Installer 5.0 which is basically an app store for IIS.
PHP SQL .NET Frameworks and Power shell are located under "Products/Frameworks".
- Optional: Download MySQL Community Server which is a SQL installer similar to Microsoft Web Platform for IIS)
FIREWALL CONFIGURATION
Launch Windows Firewall (start menu "windows firewall")
click "Advanced Settings" to set Inbound rules on specific ports.
Set the following two rules:
Click "Inbound Rules" > Click "New Rule" > Click "Port" >Click "Next"
Select "TCP" > Specific local ports: 80 > Select "Domain"
Select "Private" > Select "Public" > Click "Next"
Select "Allow the connection" > Click "Next" > Name: server
Click "Finish"
Click "Inbound Rules" > Click "New Rule" > Click "Port"
Click "Next" > Select "TCP" > Specific local ports: 8080
Select "Domain" > Select "Private" > Select "Public"
Click "Next" > Select "Allow the connection" >
Click "Next" > Name: server 80
Click "Finish"
PORT FORWARDING
Log into your router by entering its IP into a web browser. Generally it will be http://192.168.0.1/ or http://172.16.0.1/
Once logged in go to your Port Forwarding options to send incoming traffic to your router onto your webserver by creating IPv4 forwards with the following rules.
External IP Address & Start/End Point = 0.0.0.0 = 80= 80
Local IP Address & Start/End Point = 192.168.0.2 = 80 =80
(this IP address should match your computers.
To find it open command prompt "cmd" and type "ipconfig" look for your IPv4 address.)
Description = server
Protocol = TCP
Forwarding = YES
External IP Address & Start/End Point = external-ip = 8080= 8080
(this IP should be the address of your router. )
Local IP Address & Start/End Point 192.168.0.2 = 8080= 8080
Description = server = 80 = 80
Protocol = TCP
Forwarding = YES
Next locate your DHCP settings and specifically your webserver computer in the list of devices connected to your network.
Reserve it's local IP address so it doesn't change the next time you reboot your router.
DOMAIN AND DNS
To find your external IP either run (win+r) cmd and enter ipconfig /all or visit a site like https://www.ipchicken.com/
Visit http://domains.google.com to register a domain.
You can either select the domain forwarding (Manage>Forward) options to point yourdomain.com to your external IP or you can set a custom DNS record to ensure your name resolves instead of your IP.
For custom DNS settings enter the following Registered Hosts records
Hostname IPv4 address
www.domain.com external ip
domain.com external ip
Custom Resource Records
Name Type TTL Data
@ A 1h external ip
* CNAME 1h domain.com
a A 1h external ip
Address Overview
Step Complete: Webserver Installed http://127.0.0.1
Step Complete: Firewall + Port Forwarding Configured http://external-ip
Step Complete: Domain + DNS configured http://domain.com
EMAIL FORWARDING
To use an user@domain.com address to send and receive messages from your gmail account.
visit domains.google.com
Navigate to: Email > Email Forwarding > Add Email Alias
Create a forwarding email address
visit myaccount.google.com
Enable Multi Factor Authentication
Navigate to: Security > App Passwords
Select: app = mail
Select: device = other and name it something
copy the password
visit gmail.com
Navigate to: Settings > See All Settings
Select: accounts and import > add another email address
Enter a name and the fowarding email address
make sure: treat as alias is checked
SMTP = smtp.gmail.com
username = gmail account username
password = the password you copied in step 1
log into your gmail account and click the confirmation message.
WEBSITE SETUP
Now that you have your webserver up and running you'll now need an actual website. Which is comprised of mostly .html files stored on your server in locations such as \inetpub\wwwroot for IIS servers and \xampp\htdocs\dashboard for XAMPP.
If you have no web coding (html,css,js,php) background and don't plan on learning, a good alternative option is Wordpress which is a CMS or Content Management System used to create webpages, so no coding is required.
Once your site is built don't forget to visit a Favicon Generator and then Submit your site to Google as final steps.
If your main reason for setting up a server is to open an online store, WooCommerce is an option as the standard store-engine plugin for Wordpress.
However, if your store doesn't plan on managing all payments, production, and shipping it may be simpler to save yourself the work of setting up and maintaining a webserver and instead simply forward your domain to a pre-existing marketplace connected via API to a third party drop-shipper. To do this visit Printify or Printful to get started.
INTRODUCTION INTO WEB CODING
Websites incorporate a variety of different overlapping languages which pull and compile different assets into a end user experience.
If you're completely new to coding I would suggest installing httrack which allows you to download a local copy of a page.
Also get use to utilizing "view-source" and "inspect-element" options while browsing the web to learn how different web pages work.
Next focusing on learning the below in top-to-bottom order.
Click here for a good place to start learning, if you already know the basics then instead try codepen
HTML HyperText Markup Language
JS JavaScript
ANGULAR App Platform|BS optional
Python General Purpose Language
.NET Framework
SELF HOSTed SERVICE RESOURCES
Lychee install
Lychee is a free photo-management tool. Either download and extract lychee to a directory inside your webserver or if you use GIT open command prompt (cmd) navigate to a folder inside your webserver and type "git clone https://github.com/electerious/Lychee.git"
Next you'll need to create a database for Lychee, to do this open a command prompt (cmd) and type the following:
run command: mysql enter password: password run command: CREATE DATABASE lychee; run command: CREATE USER "username"@"localhost" IDENTIFIED BY "password"; GRANT ALL PRIVILEGES ON lychee.* TO "username"@"localhost";
Next you need to navigate to the folder with the lychee install in it. c:\inetpub\wwwroot\Lychee and set permissions to allow all privilledges to all groups.
If the read option will not save after being unselected, open a command prompt and naviate to the the folder.
Type: icacls Lychee /grant:r "Administrators":(OI)(CI)M
Navigate to Lychee via web browser http://127.0.0.1/Lychee and enter the following values; host: localhost or blank, username: username, password: password, database: lychee.
KIWI IRC INSTALL
Kiwi is a IRC web client. Before installing be sure to download NPM then open a command prompt and navigate to your server folder.
Type command: mkdir kiwi-irc,
Type command: cd kiwi-irc,
Type command: git clone https://github.com/prawnsalad/KiwiIRC.gif && cd KiwiIRC
Type command: npm install Type command: copy config.example.js config.js
Type command: kiwi build Type command: kiwi start
Thats it. You can now access Kiwi by visiting http://localhost:7778 to manually start kiwi navigate to the directory via cmd and type command: kiwi start
MIME TYPES
Once your webserver is online it will require additional configuration to fine tune it to your needs.
MIME stands for Multipurpose Internet Mail Extensions which really doens't matter. What does matter is that without setting mime type values certain types of files will not be allowed through your webserver.
For instance without a MP4 MIME value your site won't allow online downloading or streaming of song.mp4 files you host.
On IIS servers MIME values can be entered by opening the MIME Type app inside of IIS Manager, on Apache MIME values are entered either into the httpd.conf or .htaccess files.
IIS Server Example
fileExtension=".mp4"
mimeType="video/mp4"
fileExtension=".webm"
mimeType="video/webm"
Apache Server Example
AddType application/json
json
AddType video/mp4
mp4 m4v f4v f4p
NGINX Server Example
text/css
css;
text/xml
xml;
Enabling SSL
To enable SSL (https) on your server you will need to create an account with a trusted Certificate Authority (CA) to issue you your certificate. There are multiple types of SSL certificates available each requiring different forms of authorization, the most common options are.
EVSSL - $75 annually - Extended Validation
OVSSL - $30 annually - Organization Validated
DVSSL - $9 annually - Domain Validated
If you are expecting your SSL certificate to be trusted everywhere the best option is an EVSSL certificate the downsize is they cost more, require more forms to be filled out, and take longer to initially enable. If instead you would like the non-secure warning pages to go away but don't require a PCI level of trust/encryption then a DVSSL may be a better option as it is cheap and can be activated relatively quickly.
Once you have purchased your certificate open IIS Manager and open "Server Certificates". Select "create certificate request" and complete the fields - Common Name = your sites domain name (www.site.com). Save the file to your local drive and then open it in notepad to copy the generated key. Return to the CA website and select "Generate Certificate", enter your key and server information (MS IIS5.x+ later) and click submit. Next verify ownership of the domain (DVSSL) via whois email, file upload, or CNAME record. Once ownership has been validated your certificate will be issued (emailed to you). Return to IIS Manager, click on Server Certificates, and select "Complete Certificate Request". If an error is thrown click cancel and hit the F5 key to refresh the list. If your certificate is listed then proceed to bindings. If it is not listed proceed to MMC.
Troubleshooting via MMC: Click start and enter MMC. Select Add/Remove Snap-In, Add Certificates, Computer Account, Local Computer. Next select - Certificates > Personal > Certificates > All Tasks > Advanced > Create Custom Request > Next/Next/Next. Then expand "Details" and select "Properties".
select - Base64 and complete the general tab
Switch to the Subject tab and enter the following values
Subject Name:
Common Name: Domain (URL)
Country: USA
Locality: Town
Organization: Name
State: State
Alternative Name:
IP address (V4): server IP address
URL: domain name
Switch to the Private Key tab
Key options - make key exportable
select size 2048
Now generate a new certificate request, save it locally, open it, copy the key and paste it into your CA website to generate a new certificate. Then return to IIS select Server Certificates and click on "Complete Certificate Request". If error is still thrown hit F5 (refresh) - it should now be in the list.
Select the site you wish to add the SSL Certificate to and click "Edit site > bindings". Add Type: https, Ip address: All Unassigned, Port: 443, and select the SSL Certificate from the drop down list.
SSL should now be active on your domain, if it isn't try visiting your domain name provider (domains.google.com) and ensure SSL is turned on in your DNS settings.
.htaccess
The .htaccess file is a optional addition to add to your server which allows for additional security and configuration.
To create a .htaccess file open Notepad++ enter your configuration and save the file to your web directory as .htaccess
To password protect a file you'll also need a .htpasswd file.
For the .htaccess example below the .htpasswd file would contain username:$apr1$aSqRMyB4$xt0CkXVpEzJfe3L0hiOZP.
# Rewrite to www Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^cascadiagoat.com[nc] RewriteRule ^(.*)$ http://www.adrian.systems/$1 [r=301,nc]
# 301 Redirect Old File Redirect 301 /oldfilepath.html /newfilepath.html
# 301 Redirect Entire Directory RedirectMatch 301 /olddirectory(.*) /newdirectory/$1
# Caching schema <FilesMatch "\.(jpg| css)$"> Header set Cache-Control "public, max-age=780" </FilesMatch>
# Password Protect file <Files /safe> AuthName "Prompt" AuthType Basic AuthUserFile /hidden/secrets/path Require valid-user </Files>
# Stop hotlinking RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?google.com/.*$ [NC] RewriteRule \.(jpg|png|gif)$ http://www.example.com/hotlinker.png[R=302,L]
# Custom 400 errors ErrorDocument 400 /errorpages/400.html
# Custom 401 errors ErrorDocument 401 /errorpages/401.html
# Custom 403 errors ErrorDocument 403 /errorpages/403.html
# Custom 404 errors ErrorDocument 404 /errorpages/404.html
# Custom 500 errors ErrorDocument 500 /errorpages/500.html
# Block users by IP order allow,deny deny from 192.168.1.99 allow from 0.0.0.0.
# Block bad bots RewriteEngine On RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]
RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR]
RewriteCond %{HTTP_USER_AGENT} ^Custo [OR]
RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR]
RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR]
RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR]
RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR]
RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR]
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]
RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR]
RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR]
RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR]
RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR]
RewriteCond %{HTTP_USER_AGENT} ^HMView [OR]
RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR]
RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR]
RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR]
RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR]
RewriteCond %{HTTP_USER_AGENT} ^larbin [OR]
RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR]
RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR]
RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR]
RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR]
RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR]
RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR]
RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR]
RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR]
RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR]
RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR]
RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]
RewriteCond %{HTTP_USER_AGENT} ^Widow [OR]
RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus RewriteRule ^.* - [F,L]
# Change default directory page DirectoryIndex notindex.html
# Prevent viewing of .htaccess file <Files .htaccess> order allow,deny deny from all </Files>
# Prevent directory listings Options All -Indexes
Additional Tips and Troubleshooting
PYTHON
To enable Python after it has been installed open CMD prompt and type: set path=%path%;C:\Users\ServiceUser\AppData\Local\Programs\Python\Python37 then hit enter next type: python --version and hit enter again to confirm. *Be sure to change "ServiceUser" to your current username.
READ WRITE PRIVILEGES
To force remove read privileges from a folder that wont let you navigate to the containing directory of the folder you want to edit in CMD. cd C:\inetpub\wwwroot\ then type command: icacls trickyfolder /grant:r "Administrators":(OI)(CI)M
WEBSITE INACCESSIBLE
How to fix it when your server is live but your site isn't
If when you navigate to http://localhost and get the error System.ServiceModel.Activation.HttpModule
open cmd and browse to cd\%windir%\Microsoft.NET\Framework64\v4.0.30319 then run cmd:aspnet_regiis.exe /iru
IPCONFIG UNRECOGNIZED
How to fix a cmd that isn't recognized For example if ipconfig is no longer recognized
Check that the default command still works which is: windows\system32\ipconfig /all
To fix this right click "My Computer" & select "Properties." > Click "Advanced" tab. >Click "Environment Variables" button. Then in the "System variables" box, scroll down to "PATH" and highlight it. Click the "Edit" button and in the "Variable value:" box, add this string to the very beginning of the text "C:\WINDOWS\system32;" without my quotation marks. Make sure you include the semicolon. Then click OK three times.
That should of have done it to test open cmd, right-click and select "run as administrator", Type cd C:\ hit enter, Type ipconfig, hit enter.
AUTO START SERVICE
Open file explorer and navigate to or create C:\autoboot Open notepad and type a command, for example: cd C:\inetpub\wwwroot\server node server.js or cd c:\inetpub\wwwroot\KiwiIRC kiwi start then save the file as filename.bat then open a blank notepad and type
Set oShell = CreateObject ("Wscript.Shell")
Dim strArgs
strArgs = "cmd /c filename.bat"
oShell.Run strArgs, 0, false
then save the file as filename.vbs close notepad and navigate to C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup create a shortcut to C:\autoboot\filename.vbs
AUTO RESTART SERVICES
Run services.msc and select the service you want to restart. Right-click properties and take note of the service name.
Open notepad and type the following:
@echo off
NET STOP servicename
timeout /t 5 /nobreak > NUL
NET START servicename
timeout /t 2 /nobreak > NUL
save the file as a .bat and double click it to run.
INTRODUCTION TO LINUX
Linux Tips for those mostly familiar with Apple or interested in a personal cloud server.
Download: Elementary Linux and Rufus to install the OS.
Below is a list of some terminal commands to get your started
Command Function
sudo su - switch to admin
cd .. up dir
ls list directory
chown user filename.txt take ownership
chmod -r 755 read/run all
chmod -r 777 read/write/run all
sudo apt-get upgrade app upgrades
sudo apt-get update app update
git config --global user.name "your name" for git repos
killall appname end process
cd opt/lampp sudo ./manager-linux-x64.run Run xampp gui