Monthly Archives: October 2016

Apache on CentOS Linux For Beginners

We learned the basics of running the Apache HTTP server on the Debian/Ubuntu/etc. family of Linux distributions in Apache on Ubuntu Linux For Beginners and Apache on Ubuntu Linux For Beginners: Part 2. Now we’re going to tackle CentOS/Fedora/andtherest. It’s the same Apache; the differences are package names, configuration files, and that never-ending source of fun times, SELinux.

Install Apache in the usual way with Yum, set it to automatically start at boot, and then start it:

$ sudo yum -y install httpd
$ sudo systemctl enable httpd.service
$ sudo systemctl start httpd.service

Point a web browser to http://localhost, and you should see a test page (Figure 1).

It works! We are wonderful.


CentOS installs with an active SELinux configuration set to SELINUX=enforcing in /etc/sysconfig/selinux, which will prevent your new virtual hosts from operating. There are two ways to handle this. One way is to disable SELinux by changing SELINUX=enforcing to SELINUX=permissive, and then rebooting. This keeps your rules active without enforcing them, and logs all SELinux messages so you can study how the rules are working, and if they are set correctly.

The other way is to leave SELinux in enforcing mode and create a ruleset for your new virtual host. In the following examples our virtual host root is /var/www/html/

$ sudo semanage fcontext -a -t httpd_sys_rw_content_t 
restorecon -RF /var/www/html/

While you’re testing and learning, you could make this ruleset apply to your entire web root by using '/var/www/html(/.*)?' instead of creating rules for each individual virtual host. Note that neither of these rulesets are very secure; they’re for making testing easier. A more secure SELinux configuration is more fine-grained and applied to individual directories; I leave it as your homework to study how to do this.

Configuration Files

CentOS/etc. use a different configuration file structure than the Debian Linux family. Apache configuration files are stored in /etc/httpd. The default CentOS 7 installation supplies these directories:


conf contains the main server configuration file, httpd.conf. You probably won’t edit this file very often. This contains global configurations such as the location of the configuration files, include files, the Apache user and group, document root, and log file location and format.

conf.d is where your virtual hosts and any other custom configurations go. It contains welcome.conf, which is is the default virtual host that displays the default welcome page. autoindex.conf enables directory listings, and php.conf controls how Apache interacts with PHP.

All files in conf.d must have a .conf extension. This is controlled in httpd.conf, so you have the option to change it to whatever you want. Really. Even something goofy, like .feedme or .hiapache.

conf.modules.d loads whatever installed modules you want to use.

logs, modules, and run are all symlinks to other directories. Take a little time to study your configuration files and see what is in them.

Create a new virtual host

Now that we have an inkling of what to do, let’s create a new virtual host and its welcome page. In this example it is

$ sudo mkdir -p /var/www/html/
$ cd /var/www/html/
$ sudo nano index.html

You are welcome to copy this fabulous custom welcome page:

<title> index page</title>
<h1>Hello, welcome to! It works!</h1>            
<h2>That is all I have to say. If you don't 
see this then it doesn't work.</h2>

Test your new index page by opening it in a web browser (Figure 2), which in this example is file:///var/www/html/

Excellent, the welcome page renders correctly. Now let’s configure a virtual host to serve it up, /etc/httpd/conf.d/mysite.conf.

$ cd /etc/httpd/conf.d/
$ sudo nano mysite.conf

This is a basic barebones virtual host:

<VirtualHost *:80>
    ServerAdmin carla@localhost
    DocumentRoot /var/www/html/

Now point a web browser to http://localhost/ to (Figure 3).

Behold! Your fab new virtual host lives! If it doesn’t look right restart Apache, and force your browser to bypass its cache by pressing Shift+reload. After years of testing multiple setups and running Apache on all kinds of Linux distributions, I’m rather muddled on when you need to restart or reload the configuration without restarting, or when Apache picks up new configurations automatically. During your testing, you can restart it with gay abandon.

Multiple virtual hosts

For quick easy testing map your server’s IP address to your domain names in /etc/hosts:

Now you can access and without the localhost portion of the address. Copy these /etc/hosts entries to other hosts on your LAN, and they should also have access to your site.

To set up more sites repeat these steps, creating different document roots and domains for each one, and their corresponding entries in /etc/hosts. For example, adding second virtual host looks like this:

And beware of SELinux.

When you’re ready to roll out a production server refer to Dnsmasq For Easy LAN Name Services to learn how to set up DNS on your LAN with the excellent Dnsmasq name server.

Creating a publicly accessible Internet web server is a much bigger job that involves registering domain names, setting up careful and correct DNS, and building a good firewall. Do please study this with great care.

The fine Apache documentation is exhaustively thorough, and it makes more sense when you have a live server running, and have some idea of how things work.

Advance your career in Linux System Administration! Check out the Essentials of System Administration course from The Linux Foundation.

Linux Voice Joins the Linux New Media Family

Linux Magazine and Linux Voice magazine ( have reached an agreement to merge within the same folio. Linux Voice joins the Linux New Media family and will live on as a special section within Linux Magazine.

The four Linux Voice founders, Graham Morrison, Ben Everard, Mike Saunders, and Andrew Gregory, will continue to write for Linux Voice in its new form, along with Simon Phipps and other longtime LV contributors. The Linux Voice team will also continue their popular podcast. According to Linux Magazine publisher Brian Osborn, “This change will put us in a stronger position to meet the challenges of the marketplace. Each of these magazines has a loyal following of readers. Our goal is to keep both teams doing what they do best.”

Linux Voice editor Ben Everard says the focus is on the readers. “By bringing together two groups of enthusiastic Linux writers and evangelists, we hope we can make the magazine the community deserves.”

Linux Magazine editor Joe Casad adds that he is excited about the challenge of delivering the best available material to the readers of both publications. “We love the energy and insight these guys bring to what they do, and the truth is, they really know Linux. If any one of them had approached us individually to write for the magazine, we would have been delighted. Now we’re getting all of them at once. I think our readers will quickly see the value when they look inside.”

According to Casad, the task of making room for the Linux Voice authors was smoother and easier than anyone expected. “If you look at the number of words on a page, Linux Magazine has always been super packed with content compared with the other magazines in our market. We’re confident we can make room for all four of the Linux Voice founders, plus a selection of their most popular contributors, and still have room to do what we have always done, which is provide our own brand of concise technical content for Linux power users and admins.”

Linux Magazine 193, the first issue of Linux Magazine with Linux Voice, will be available online and on UK newsstands on October 29. Linux Pro Magazine (the North American edition) will reach newsstands around November 25.

See the FAQ at the Linux Voice site for more information ( For all other inquiries, reach us at

Source link

Ubuntu 16.10 (Yakkety Yak) released and Download Link Included

Sponsored Link

Codenamed “Yakkety Yak”, Ubuntu 16.10 continues Ubuntu’s proud tradition of integrating the latest and greatest open source technologies into a high-quality, easy-to-use Linux distribution. The team has been hard at work through this cycle, introducing new features and fixing bugs.

Under the hood, there have been updates to many core packages, including a new 4.8-based kernel, a switch to gcc-6, and much more.

Ubuntu Desktop has seen incremental improvements, with newer versions of GTK and Qt, updates to major packages like Firefox and LibreOffice, and stability improvements to Unity.

Ubuntu Server 16.10 includes the Newton release of OpenStack, alongside deployment and management tools that save devops teams time when deploying distributed applications — whether on private clouds, public clouds, x86, ARM, or POWER servers, z System mainframes, or on developer laptops. Several key server technologies, from MAAS to juju, have been updated to new upstream versions with a variety of new features.

Download ubuntu 16.10

You can download ISOs and flashable images from from: (Ubuntu Desktop and Server) (Less Popular Ubuntu Images) (Ubuntu Cloud Server) (Ubuntu Netboot) (Kubuntu) (Lubuntu) (Ubuntu Studio) (Ubuntu GNOME) (Ubuntu Kylin) (Ubuntu MATE) (Xubuntu)

Sponsored Link

Related posts

Upgrade Ubuntu Desktop/Server from 16.04 (Xenial Xerus) to 16.10 (Yakkety Yak)

Sponsored Link

Codenamed “Yakkety Yak”, Ubuntu 16.10 continues Ubuntu’s proud tradition of integrating the latest and greatest open source technologies into a high-quality, easy-to-use Linux distribution. The team has been hard at work through this cycle, introducing new features and fixing bugs.

Under the hood, there have been updates to many core packages, including a new 4.8-based kernel, a switch to gcc-6, and much more.

Ubuntu Desktop has seen incremental improvements, with newer versions of GTK and Qt, updates to major packages like Firefox and LibreOffice, and stability improvements to Unity.

Upgrade Ubuntu desktop from 16.10 to 16.04

Open the “Software & Updates” Setting in System Settings.

Select the 3rd Tab called “Updates”.

Set the “Notify me of a new Ubuntu version” dropdown menu to “For any new version”.

Press Alt+F2 and type in “update-manager” (without the quotes) into the command box.

Update Manager should open up and tell you: New distribution release ‘16.10′ is available.

If not you can also use “/usr/lib/ubuntu-release-upgrader/check-new-release-gtk”

Click Upgrade and follow the on-screen instructions.

Upgrade Ubuntu server from 16.10 to 16.04

Install the update-manager-core package if it is not already installed.

Make sure the Prompt line in /etc/update-manager/release-upgrades is set to normal.

Launch the upgrade tool with the command sudo do-release-upgrade.

Follow the on-screen instructions.

Sponsored Link

Related posts

An Introduction to MySQL

At some point in your life as a Linux administrator, you’re going to have to work with a database. And because you’re working with the Linux platform, chances are high that database will be MySQL. In some cases, you’ll only need to interact with MySQL long enough to create an empty database to be used for a web-based tool, such as OrangeHRM, WordPress, Drupal, or Nextcloud. You might also be on track to learn the open source database tool, in hopes of someday serving as a database administrator for a company.

Regardless of why, you need to get up to speed with MySQL…and that very well might mean starting from the very beginning. That’s exactly what we’re here for: to install MySQL and learn how to use it, without having to depend upon a GUI tool for all the heavy lifting.

I’ll be demonstrating on a fresh install of Ubuntu 16.10. Let’s kick this off by installing MySQL.


There are a number of ways to install MySQL. You can install it as a standalone server from the command line, you can install it from the GUI package manager (as in Ubuntu Software), or you can install it alongside a full-blown LAMP (Linux Apache MySQL PHP) server. Because, more often than not, you’ll be using MySQL on a LAMP server, let’s go that route. Why? Because it tends to be the most reliable method of installing MySQL on a Debian-based distribution.

The installation of a LAMP server will differ from distribution to distribution. For Ubuntu, that goal can be achieved with a single command:

sudo apt-get install lamp-server^

The above command will install all the necessary dependencies for your LAMP server. During the installation, you’ll be prompted to enter (and verify) a password for the MySQL “root” user (Figure 1).

Do not leave this blank. Enter a strong password for the MySQL root user and tab down to OK, hit Enter on your keyboard, and then retype the new password. The installation will continue to completion. You are now ready to begin working with MySQL.

Logging into MySQL

To work with MySQL, you have to log into what is called the MySQL Shell. This is quite different from your normal bash shell, and you are limited to MySQL-only commands. When you log into MySQL use the root user and the password you just created (during installation).

When logging in, you can specify not only which user to work with but also which database to use. We haven’t created a database yet, so we will only be specifying a user. To log in, open up a terminal window, and issue the command:

mysql -u root -p

The -u option indicates what user you will log in with and the -p option tells MySQL to require a password. When prompted, enter the password you created during installation and you will be greeted with the MySQL Shell (Figure 2).

Creating a new database

The first thing to do is create a new database. Let’s say we want to create a new database called clients. To do this, you’d issue the command:


Notice the ending “;” character. This is important, as it instructs MySQL of the command end. You could issue that command as:


And MySQL would return a > prompt. If there were more to that command, you could enter it there. Once you’d completed the command, type ; and hit the Enter key on your keyboard. I prefer to enter my commands all at once (to avoid confusion).

When you issue the complete command, MySQL will return:

Query OK, 1 row affected (0.00 sec)

Your database has been created. As it stands, you cannot work with that database, because you’re not using it. To use the newly created clients database, you must issue the command:

USE clients;

MySQL will return:

Database changed


You can now work with the newly created database.

Creating a table

Unless you are simply creating the database to be used by a third-party application (and the installation of said third-party software will populate the database with the necessary information), your database needs data. For a database, data starts with tables. Let’s say we want to create a table for our new client database that will contain the following information:

To do this, you first must know what kind of characters will be necessary for each entry. The three basic types available are:

All three points of information for our table (name, email, phone) will be VARCHAR. Why?

  • Not all names and emails will be the same length

  • For clarity, phone numbers are broken into 123-456-7890 and the “-” character is not an integer.

Let’s create a table for the clients database, called hardware. To do so, enter the command (from the MySQL Shell):

CREATE TABLE hardware (name VARCHAR(20), email VARCHAR(20), phone VARCHAR(20));

The table will be created (Figure 3), and you will be returned to the MySQL prompt.

Now that you have a database and a table, all that remains is to add data to the newly created table.

Adding data to tables

We’re going to add our first entry to the hardware table (which could be a list of clients that sell or buy hardware). The entry will be:

Name: Bethany Nitshimi


Phone: 555-123-4567

Here’s what the MySQL command will look like:

INSERT INTO hardware (name,email,phone) VALUES ("Bethany Nitshimi","",”555-123-4567”);

The data will be added to the table and MySQL will return you back to the prompt (Figure 4).

If you don’t want to manually enter the data one row at a time, you can always import it from a text file. The text file in question would have to formatted similarly as was in the above command. So, to import data into the hardware table, each entry of the text file would have to be (one per line):

name    email    phone

As in:

Bronson Coulter    555-987-6543

NOTE: The data must be delineated by a tab.

Once you have that file created (we’ll call it data), go back to the MySQL Shell (make sure to use the clients database), and issue the command:

LOAD DATA LOCAL INFILE '/path/data' INTO TABLE hardware;

Where path is the exact path to the data file.

You can view the contents of the hardware table with the command:

SELECT * FROM hardware;

MySQL will issue a report on all the data contained with that table (Figure 5).

Your database is ready

Once you’ve added all the tables and data to your database, you can issue the command exit to leave the MySQL Shell. Your database is ready to be used. Although this will only serve as an introduction to MySQL, you should now have a solid understanding of how to install MySQL, log in, create a database, create a table, and fill the table with data. When you’re ready to move onto more advanced topics, you can always check out the official MySQL documentation.

Want to learn more about database and system administration? Check out the Essentials of System Administration course from The Linux Foundation.