Linux developers can install everything they need using their particular Linux distribution’s package manager. Learn how the installation steps differ from one distribution to the next. Ubuntu Linux, one of the most popular distributions out there, is shown.
- [Instructor] Developers who want to work with Apache, MySQL and PHP on Linux, can install everything they need using their particular distribution's package manager. The steps differ from one distribution to the next. I'm going to show you how to do this on Ubuntu Linux, one of the most popular desktop distributions out there. If you're using a different distribution, please check the Linux vendor's documentation. I'm particularly using Ubuntu Linux 16.04 code name Xenial. This is the most recent long-term support release from Ubuntu.
These long-term support or LTS releases, are guaranteed to be maintained for at least five years, so they make a great, stable platform for development. The first step before installing Apache, is to make sure you've updated your package manager. Here's how you do this on Ubuntu Linux. I'll click the Search icon at the top left and type terminal and then when I see the terminal application appear, I'll click on it. Now I'm going to be doing everything from the command line on Linux, so I want to be able to get to terminal easily.
I'll right-click on the icon that appeared on the task bar on the left, And choose Lock to Launcher. Now that icon will always be available. Now I'm going to update my package manager. I'll start with sudo, which is super user do, then apt-get and then update. When prompted for my admin password, I'll type it in. It'll take just a few moments to download and install everything that's needed, but when it's done, I'll have and up-to-date listing of everything that's available for my particular installation of Linux.
And I'll come back to the command line. I'll type clear and that gives me a clean screen. And now I'm ready to install Apache. Once again I'll start with sudo apt-get, then I'll type in install as the command and apache2 as the module that I want to install. It'll take a few moments for the app-get package manager to determine what needs to be installed. It shows me a listing of everything it's going to download and install, and then I'll confirm by pressing y and enter.
This will be a larger download than the previous update, so if it's taking a little while, just step away from the computer and come back in a few minutes. When the process is complete, Apache will have been completely installed and it will have been started up. You can test it by going to your browser, I'm using Firefox, and then typing http://localhost and you should see this default page appear for Apache2.
Now to stop and and start Apache, on your Linux machine, go back to terminal and then, just as I did on Mac, I'll start with sudo and then apachectl and I'll type stop. I see a message indicating that there's a potential issue with my configuration. So now I'll show where all these files are installed. I'll go to my File Manager by clicking on the File icon at the top left, then I'll click on the computer, that's the root of the disk, and from there I'll go to etc and then to apache2.
The file apache2.conf is your primary configuration file. Now I can look at it by double-clicking and it will open up in gedit, but I won't have rights to edit it here. So instead, I'm going to go back to the command line, and I'm going to switch to that directory. /etc/apache2 I'll use ls to make sure I'm in the right place, and I see my configuration file is there. Then I'll type sudo nano, that's my command line editor, and then apache2.conf.
Now I'm going to go down to the very bottom of the file by pressing the page down key a bunch of times then I'll make a new line down here and I'll type in ServerName, make sure you spell this exactly the same way I'm showing it here, and then localhost. I'll press Control-X to exit, y and enter to confirm. Now I'm going to stop and restart Apache. I'll type Sudo apachectl stop and I see that it wasn't actually running because I had stopped it previously, then I'll press the up arrow to bring that command back and I'll change it to start.
This time I don't see any error messages. Once again, I'll go back to Firefox, and I'll refresh, and I see the page again. Finally I'll show you where that file is located. In the default configuration, your web document root for Apache 2 on Ubuntu Linux is under var, www, html. I'm going to open this file with gedit and show you that it's a basic html page with some CSS.
And this is the page that I displayed in the browser when I navigated to localhost. So that's how you get started with updating the package manager and installing and doing some very basic configurations of Apache on Ubuntu Linux.
- Installing Apache on Windows
- Working with PHP on Windows and macOS
- Installing MySQL on Windows and macOS
- Adding MySQL bin directory to the PATH
- Starting and stopping Apache on macOS
- Configuring personal site folders
- Installing Apache, PHP, and MySQL on Linux
- Installing and managing WampServer
- Defining WampServer directory aliases
- Installing MAMP on macOS
- Configuring Apache and MySQL server ports on MAMP
- Handling port conflicts on Windows and macOS
- Configuring the Apache web document root