Software to install:
You will need some sort of *AMP stack, such as WAMP, MAMP, or LAMP. You will also need MySQL Workbench if you’re on Windows, or a terminal window if you’re on macOS or Linux.
Windows:
Bitnami WAMP: https://bitnami.com/stack/wamp
MySQL Workbench: https://dev.mysql.com/downloads/workbench/
Macs:
Bitnami MAMP: https://bitnami.com/stack/mamp
Linux:
Bitnami LAMP: https://bitnami.com/stack/lamp
Please note: although it’s fine to use MAMP or WAMP on your development machine, such as your laptop or desktop, the fact of the matter is that LAMP is what you’ll find on most web servers (although it might be a different LAMP stack rather than the one that Bitnami provides).
Section 11.2 includes step-by-step setup instructions for how to install and set up *AMP and MySQL Workbench. Just wait until you’ve read that far before installing anything.
I also highly recommend using a password manager, because you’ll be making accounts and passwords for things like databases, server OSes, and more. And if you eventually get domain names and web hosting, you’ll need accounts there too. A password manager is a secure way to store login information. Instead of trying to memorize it all, use the same password for everything, or write things down on paper, it’s better to use a password manager such as LastPass:
If you’d rather use something that is offline and open source, check out KeePass:
Front-end, back-end, and full stack
Front-end is code that runs on a client’s device. Back-end is code that runs on a server. Requests, such as Ajax or HTTP, are how you communicate between the two. The combination of software you use for a website is called a stack. A full stack web developer is someone who writes front-end and back-end code, as well as deals with how stuff happens in between them. This book concentrates on a stack called LAMP, which stands for Linux, Apache, MySQL, and PHP. Linux is the OS a server will run (some people might say “actually, Linux is a kernel, not an OS” but you get the idea), Apache is a web server platform used for turning a computer into a web server that users can visit to see web pages, MySQL is database-related software, and PHP is a server-side programming language. You don’t usually run PHP on a computer directly (unless you’re a software developer), but when you go to a website in a browser, that website’s server might be running PHP code behind the scenes to make things happen.
MAMP is LAMP but for Macs. WAMP is LAMP for Windows. Aside from that, they are basically the same.
If you want to see the tech stacks that different companies use, check out this site: https://stackshare.io/
Introduction to back-end and databases
- Databases make data-centric software possible. Social media content or login systems would not be possible without databases. When you leave a comment on Youtube, you’re putting data into a database. When you view Youtube comments, a server is fetching data from a database and sending it to you. When you send a tweet, you’re putting data into a database. When you like someone’s post, you’re adding 1 to an int column (numberOfLikes += 1 for post ID #3424234234234) in a record in a table in a database. When you change your account password, you are updating an existing record in a database. When you submit a login request on Amazon, Amazon’s servers compare your submission to the correct credentials in a database and makes sure they’re the same. If your submitted username and password don’t match what’s in their database, they won’t let you log in. More on passwords in databases later in the chapter though, as that’s a complicated issue.
- When you make an online purchase, a record is created in a table in a database. When you look up a product on an online store, your request is handled by a web server program (such as Apache), it contacts a database management system (such as MySQL), and the product’s data is retrieved from a database (almost always using SQL and a server-side language such as PHP) and then combined with a web layout (HTML, CSS, and JavaScript). If a website tracks information about its users, it might be putting data into a database that says what page you visited, how long you visited it for, what your browser and operating system are, when it happened, what your tracking cookie ID is, what your IP address is, and so on. Even without a database, user requests are stored in log files, but that is a separate topic.
- Earlier in this book, you learned how to make simple websites, but you did so by putting the content of the site directly into the HTML files, which is called hard-coding (which is simpler for beginners, but considered a bad practice). In most cases, data will actually be stored in a database and web page template files are stored separately. A web server’s back-end code will combine data from a database with a template and deliver it to a user. All the details of how this happens are hidden from the user. Data is separate from the presentation of data. Data could be the text in a comment. Presentation would be the font, color, size, and placement on a page. In hard-coding, they are combined, which is bad.
Classes, functions, print statements, and loops are nice and all, but there’s much more to coding than just that. Without data and databases, programming wouldn’t be very useful at all.
SQL is a programming language that is made specifically for dealing with data. Unlike something like Java, SQL is not really general purpose, but instead focuses on databases and the queries you can perform on them. SQL stands for Structured Query Language. It’s the way that you can talk with, or query, databases. And you usually don’t use SQL by itself, either. SQL is usually used in conjunction with a DBMS such as MySQL and a back-end language such as PHP, and a server platform such as Apache. Front-end code, such as HTML, CSS, and JavaScript, is relatively easy to make, but also static. You can’t make a site with persistent interactivity with just front-end code. Sure, JavaScript can change things, but not in the same way that SQL can. JS by itself can only do non-persistent front-end interactivity that does not change a server. With SQL (along with PHP), you can make software that lets a user of a website have an account, or send a message to someone else. That is simply not possible with front-end code alone. So to make more useful websites rather than landing pages, you will need to learn back-end development and database queries.
When a company gets “hacked,” what often happened is that a hacker performed SQL injection to get private data from a database that they’re not supposed to be able to see. There are many other types of hacking, but the point is that databases often hold very valuable and private data in them, such as payment information, usernames and passwords, customer contact information, and more. Some data might be public, but not all.
I’ve heard some non-programmers criticize web development before, and they talked about how HTML is easy and web developers aren’t “real” programmers. But to be a full stack developer (meaning front-end and back-end and communication between the two), you need to learn HTML, CSS, JavaScript, maybe JS or CSS frameworks like Bootstrap or jQuery, Ajax, HTTP requests, Apache, MySQL, PHP, Linux, security, SSL certificates, VMs on cloud servers, SSH, cPanel, domain registration, DNS records, and more. In some cases, people even make native app wrappers using something like Electron to turn a website into a program you can install. That’s actually quite complicated. It’s much more than “just HTML.”