Resources
The Linux Command Line by William Shotts
Free Ebook: http://www.linuxcommand.org/tlcl.php/
Instructions
At this point you should already have a functioning Ubuntu Server up and running. Now we will configure it to have a LAMP stack!
Our LAMP stack will consist of the following:
- Linux (Ubuntu Server 18.04)
- Apache
- PostgreSQL (instead of MySQL)
- Python (Flask)
The Linux step of LAMP
The first thing we want to do is verify that our server is up-to-date. Note: When prompted for a password in the terminal, it will not show typing, but it is working. Simply type your password and hit enter.
sudo apt update will make sure our repository is up to date so we pull from the correct locations.
sudo apt upgrade will upgrade the software on our server to the newest versions.
Once that finishes, we are all set for the Linux step!
Installing Apache
Apache is software that allows us to run a webserver to deliver files via http(s). In more basic terms, it is a piece of software that will allow us to host our own website, albeit for now on our own network only.
The beautiful part about Linux is how easy it is to install software. Many people shy away from using a terminal because initial responses are usually that it is complex; however, you will find that it is simple and the quickest method.
To install Apache simply execute the command:
sudo apt install apache2
We can verify that everything is working correctly by testing the default webpage. First, we need to find the ip address of our server.
Find the IP address of your server:
ip address
The results will include 2 adapters, the first will be 127.0.0.1 for your internal loopback address. The second is the IP address of your server and should be an IP address in your own network like 192.168.0.X or 10.0.0.X. Take note of the address.
To test our webserver, simply put that IP address into the address bar of the browser of your choice. If you get the following webpage, you are working!
Installing PostgreSQL
PostgreSQL will be the database we use for our stack. I prefer PostgreSQL as it is a free, open-source product that has all of the features of the most advanced database systems. It is growing in popular among developers and businesses.
To install PostgreSQL
sudo apt install postgresql postgresql-contrib
We will need to do more to setup and configure Postgre for our project. However, for now we just needed it installed. So we are all set for the database portion of our LAMP stack!
Installing Python
The last part of our LAMP stack will be Python. Ubuntu Server 18.04+ should have Python3 already installed.
To verify that it is installed
sudo apt install python3
We also need a few extra python components.
sudo apt install python3-venv
sudo apt install python3-pip
And just like that we have our Python components ready.
The LAMP Stack Base
Our LAMP stack is all installed and ready but there still is quite a bit of configuring to do. This is a good base though depending upon which technologies you are using for your project. In our case, we will finish configuring our components as we start building and tying the system together.
Bonus: FTP
If you want FTP on your server, so you can edit files on your host machine with an editor of your choice, you can install it pretty easily.
Install vsftp
sudo apt install vsftpd
Configure it so it is write enabled
sudo nano /etc/vsftpd.conf
Uncomment the line:
write_enable=YES
Restart the service:
sudo service vsftpd restart
Then you should be able to connect to your server using your credentials using the FTP tool of your choice (Like Filezilla).