Apache2 webserver on Linux/Ubuntu

19 2 0
                                    

What's that? You have Windows on your computer?? Ha ha, too bad, loser...XD. Just kidding, there are ways to run Apache2 webserver on Windows. I'm only gonna be covering the one that uses Linux subsystem for Windows (you can get that for free in Microsoft Store) and for further instructions on that go see the "Linux subsystem for Windows" chapter.

STEP 1: open your terminal (...no suprise there).

/* sidenote1

update it if you haven't already

end of sidenote1 */

STEP 2: install Apache2 by typing: sudo apt-get install apache2

STEP 3: start your webserver by typing: sudo service apache2 start

/*sidenote2

If it doesn't work for some reason restart it by typing the same thing with 'restart' instead of 'start' at the end. Also, Linux cares about capital letters so don't make the mistake of typing "Apache2" instead of "apache2".

end of sidenote2 */

STEP 4: if the page doesn't appear automatically type into your browser: localhost (or your IP address)

Now if you are on the Apache2 default page it means your webserver is working. Here are the instruction for replacing that with your own page:

STEP 5: in the terminal type in: cd /var/www/html

/*sidenote3

cd stands for change directory and /var/www/html is the default root folder of the web server. It can be changed by editing apache.conf folder but for this example we will leave it like this. 

sidenote3 */

STEP 5: Now you are in the webserver directory you can list, add or remove files. When you type in 'ls' you should see one file which is the default page named 'index.html'. Remove it by typing: sudo rm index.html

STEP 6: create your own index.html by typing: sudo nano index.html (use also for entering the file)

STEP 7: Welcome to the ultimate Linux editor Nano! (VS code is so much better). Here is some basic information for better orientitation in case you've never used nano before (and the commands at the bottom don't help you):

Move through text with Up, Down, Left, Right arrows

Exit = Ctrl + X

Save = Ctrl+ S

Undo = Alt + U

Redo = Alt+ E

Cut = Ctrl+K

Paste = Right click (if text from somewhere else), Ctrl+U (if previously cut from the file)

Help = Ctrl+ G

Stop the webserver by typing: sudo service apache2 stop

Random computer tricksWhere stories live. Discover now