Setting Up Ubuntu Linux as a Server or Local Development Enviroment
To follow this tutorial I am assuming you already went over on how to install Ubuntu Linux on a desktop. Now we can move on to installing application services and turn our desktop into a server or local development environment.
Keep in mind that there is a wide variety of options you can use. In this guide, we will focus on setting up PHP, MySQL, and Apache. The reason is simple – the majority of websites use a combination of these to run.
The first thing to do is to head to the Ubuntu Software Center. The path to follow is System –> Administration –> Synaptic Package Manager.
These are the names of the packages you want to search:
Go ahead and install all these by applying the changes once you are prompted to confirm them. It depends on your network connection, but it shouldn’t take more than a couple of minutes to install the packages.
During the installation, you will have to provide a “root” password for the MySQL. There is no need to reboot – wait until the process finished, and that’s it!
Testing Your Ubuntu Web Server
Although you can use other internet browsers to perform the test, feel free to go with Mozilla Firefox as that is the default choice on Ubuntu. Open the browser and type the following into the address bar:
You will receive a short confirmation that your web server works. As the notification says, it is the default web page as the server is still waiting for content.
Keep in mind that MySQL and Apache will start each time you boot your computer and stay active in the background.
You can head to /var/www to make changes to files and see how your website changes live.
Identifying the IP Address of the Server
Are you ready to make the server visible to everyone? Before we can do that, we should discover the local IP address of our server.
Open the Network Connection options by using the right click of your mouse. Notice the “Connection Information” and open that tab. You will see various information here, including IP address, Primary DNS, broadcast address, subnet mask, and default route.
Go ahead and write all this somewhere or simply take a picture. The important thing is that you know all these numbers (no room for mistakes) as you will need them later.
Use your mouse once again to right click on the “Network Connection.” This time, head to the “Edit Connections” tab. Choose your adapter (in most cases, you will only have one), and head to the IPV4 tab. Notice the Method dropdown menu and change from Automatic to Manual.
On to The Edits
Use the information you wrote down to edit the connection settings. Make sure to double-check everything to so that there are no mistakes.
You will, however, need to make one change to the IP address. Your IP address will be in the following format: “XXX.YYY.ZZZ.Q.” Leave the “XXX.YYY.ZZZ” part unchanged and only change “Q” to a high value under 254. The crucial thing is to ensure your network doesn’t use this number. If you are certain it’s free, you can use 5 or 10, too. However, to be on the safe side, we advise you to go ahead and enter “240.”
The newly-formed IP address will be your local static IP, and you should memorize it.
Uploading Files to Your Linux Machine
The easiest way to do this is by sharing a folder with the outside world. The crucial thing to memorize it that this might make your shares vulnerable. You should only share folders located on a private network. That means the internet connection should only be yours and there are no other users who can connect and access your shared folders. Keep in mind that users may access your network both via cable or by utilizing a wireless connection.
If you are certain that your desired shared folder is safe from others, let’s make it accessible to the outside world. Head to Applications –> Accessories –> Terminal. Use this command:
$ sudo chmod 777 /var/www
You will need to enter your password to confirm that you are the one adjusting the permissions. Keep in mind that there will be no confirmation here, so make sure to enter the right password.
Next, head to Computer–>File System–>/var/. Here, adjust sharing options by ticking the “Share Folder” box.
Security or Comfort?
You will have the option of choosing whether you want to protect the folder with a password. Leaving access to the folder unrestricted is easier, but it can be unsafe. On the other side, using the password every time can be a hassle, but it is raising the security to the next level.
Aside from that, you also want to tick the box that lets others change the files within the folder.
If you want to access these files via your web browser, type the following into the address bar:
http:////XXX.YYY.ZZZ.Q/ – this is nothing else but your local static IP address.
What You Need to Know about Port Forwarding
Here is the deal – each computer connected to the web uses an IP address. The rest of the internet might not see your computer’s IP. Instead, it is in a private range, such as “10.x.x.x.” or “192.168.x.x.”
Due to that fact, you will need to utilize port forwarding to make your website accessible to the rest of the world. Think of these ports as doors that allow you to enter a room. Each port is a different door and lets you access a particular service.
The default port that the web servers utilize is 80.
Go ahead and find “Applications” or “Port Forwarding” tab under your router settings. You want to set TCP port 80 to use the IP address provided above and forward inside your network. We cannot offer specific instructions here as there are many routers available out there. The instructions are different for each of them, which is why you should consult the router’s manual.
A Static Hostname
Here is another free tech lesson – the majority of home-based connections utilize dynamic IPs. That means your IP address will change over time, most likely in a week. You have two solutions here:
- Purchasing a static IP address from your web provider
- Using No-IP managed DNS service to update your IP address regularly
The former may be an easier option, but it costs money. If you want to keep things free, you should use the No-IP managed DNS. The first thing you should do is to set up a free account on their official website.
Once you have done that, head to your router settings and configure the Dynamic DNS service. It depends on the router but what you’re looking for is a section where you should be able to enter a hostname and other relevant data for Dynamic DNS.
Confirm the changes and reset your router to be on the safe side (in some case, the router will automatically restart).
Once everything is set up, you can try visiting your website from another computer by typing the web address you picked when registering for the No-IP service (for example http://mywebsite.hopto.org).
With everything in place, you can now access your server anytime with a remote connection. You can also upload new files to it depending on what you want to show to the world.
Our official Twitter page is now up, follow us in order to stay up to date with our latest Linux articles.Follow