In this tutorial, we show you how to create a web server with your Personal Computer. Then, you can upload your files in to your server via FTP, remote access by ssh, and has your website. In this article we use Virtual Box and Ubuntu minimal.
VirtualBox_UbuntuBefore you Boot Ubuntu from ISO file or disk Right click on Ubuntu name (when add ubuntu) then settings/network and in the section ‘Attached to’ change "NAT" to "Bridge Adapter" its gives native physical MAC and IP address to your Ubuntu.
nat_to_bridgeAfter installation you must update Ubuntu and install apache web service and PHP by typing sudo apt-get update
and sudo apt-get install apache2 php
in the command line.
Install_apache_and_phpNow, enter ip addr
in the command line to show your server native IP address.
ipaddrIn the above picture, you can see my ip (red). Now, open a Web Browser in your main Operation System and enter server IPs in URL:
Default_Apache_PageIf you have seen a page like that, it means your server is ready. Now you can edit web page file in /var/www/html. First, go to this directory and remove index.html by typing cd /var/www/html
then sudo rm index.html
.
apachefilesThen, create a new html file by typing sudo nano index.html
and put in your codes and then save and exit from nano editor by (Ctrl+X) and back to Web Browser and refresh the page.
newhtml in Nano Apache_Test_PageNow you should config your modem\router to make your server public. Go to your modem settings with web browser and search for the "Port Forwarding" option in the NAT. If you did not find it, search on the Google by your modem model.
Port_forwarding_modemIf you see "Application" option choose HTTP_Server (or like that). Otherwise, for manually set all options about ports to 80 (because 80 is for HTTP). Then in the "local IP address" Enter your server IP (that we seen with ip addr command) and Apply settings.
Now you need to know your External IP Address. You can see it here: https://dcjtech.info/what-is-my-ip and copy this to your Web Browser! The external IP address is from your ISP.
NOTE: Keep in mind if your external IP address is not static after each modem reboot. The ISP may give you a new dynamic IP address. There are two ways to make your dynamic IP address static (just search in Google).
Your IP AddressYour web server configuring has been complete. You can use Filezilla to transfer your data between main OS and server. Also, you can control the server remotely by using ssh. ssh USERNAME@SERVER EXTERNAL IP ADDRESS
SSH_into_webserver