Category Archives: Ubuntu 16.10

Install VLC Media Player On Ubuntu 16.10 Yakkety Yak

VLC Media Player is a handy program that can play numerous forms of video, and runs on just about any OS platform. It also runs on Ubuntu, and installing it is quite simple.

First, open up a Terminal window and type this command:

sudo apt-get install vlc

Enter your password to authenticate, and apt will download and install VLC and its various dependencies for you. (You can also install it through Synaptic Package Manager and Ubuntu Software Center.) Afterwards you can launch VLC by going to the Dash, searching for “VLC”, and clicking on the VLC icon.

Of course, VLC needs codecs into order to display certain kinds of video. You may need to install the Ubuntu Restricted Extras package in order to get maximum use out of VLC.
Was this post helpful? These books might be useful:

Install The Ubuntu Restricted Extras In Ubuntu 16.10 Yakkety Yak

The issue of media playback in Ubuntu is kind of a tricky one, legally speaking.

Every media file, whether video or audio, is encoded in digital form in a specific way. In order to decode the file so you can listen to it or watch it, it first needs to be decoded, using a specific piece of software called a “codec.” This sounds simple enough, but codecs are often patented, which means they’re legally protected, and one often has to pay licensing fees to use them.

The problem comes that most of the really popular media formats, like MP3 files, AAC files, and DVD, use codecs that are legally protected. Canonical and Ubuntu, following the lead of Debian, are committed to using free, legally unencumbered software whenever possible. So the codecs for MP3s, DVDs, AAC files, and numerous other media formats are not included by default in a new installation of Ubuntu.

Hence, the Ubuntu Restricted Extras package. This package includes the codecs for MP3, AAC, and other popular media formats, along with Microsoft’s TrueType fonts. Installing the Ubuntu Restricted Extras package will allow you to use these media formats.

Note, however, that the Ubuntu Restricted Extras package may not be legal to use in your country. If it’s not, then you shouldn’t use it – for obvious reasons we’re not going to advocate that anyone break the law.

(The default installer for Ubuntu will offer you the option of installing these items during the installation wizard. If you didn’t install it then, directions on how to do so are below.)

But if it is legal, installing the Ubuntu Restricted Extras package is quite easy. Simply launch Terminal by clicking on the Dash and searching for it in the search field. When the Terminal window opens up, type this command:

sudo apt-get install ubuntu-restricted-extras

Enter your password to authenticate, and apt will download and install the Restricted Extras package for you. The combined files are a couple hundred megabytes, so it might take some time depending on your connection speed. After the installation is done, you can then play most media formats on your Ubuntu system.

Was this post helpful? These books might be useful:

Install Moodle On Ubuntu 16.10 Yakkety Yak

moodle

Moodle is a virtual learning environment used by tens of thousands of schools across the world. Using Moodle, you can create a fully online course, or use it to supplment a traditionally-taught classroom course. Best of all, Moodle is free, and you can install it on Ubuntu 16.10 Yakkety Yak. Installing Moodle on Ubuntu is a bit of work, but once it is finished, you’ll have a robust e-learning server application.

It’s quite possible to install Moodle on a machine running either the desktop or the server version of Ubuntu. This makes an excellent environment for testing and experimentation, since you can tweak and experiment to your heart’s desire without rendering your production site inoperable. Given that Moodle is free, if you have a bit of Linux knowledge, you can use Moodle in lieu of far more expensive alternatives.

Let’s begin!

First, install Ubuntu into your machine of choice. Once Ubuntu is installed and updated, you will need to install five pieces of software: the Apache web server, the MySQL database server version 5.7, PHP version 7, the MySQL module for PHP, and finally the WordPress software itself.

First, install the Apache web server. To install Apache, go to a Terminal window or a command prompt and type this command:

sudo apt-get install apache2

(Technically, you’ll be installing Apache 2, the latest version.)

Enter your password to authenticate, follow the default prompts, and apt will download and install the Apache web server for you.

And that’s it! Apache should now be working. To test it from the web server itself, go to a web browser and visit the address http://127.0.0.1. You’ll remember that this is the “local loopback” address, basically the address the computer uses to refer to itself. Alternatively, you could test it from another computer on the same subnet. For instance, if you installed Apache on a computer with an IP address of 192.168.1.100, you could test it by going to another computer on the same subnet and visiting http://192.168.100 from the web browser.

Regardless, if Apache is working properly, you should see the default Apache/Ubuntu web page with the Ubuntu logo in the upper left-hand corner.

Apache is now operational.

The next step to install WordPress is to install the MySQL database server. Return to the Terminal and type this command:
sudo apt-get install mysql-server-5.7

(As of this writing, MySQL Server version 5.7 is the latest version available in the Ubuntu repositories, though future versions of Ubuntu may receive the newer versions of MySQL.)

Enter your password to authenticate, and apt will download the MySQL files and install them for you. It’s a big set of files, so depending on the speed of your Internet connection, it might take a while to download. After the files are downloaded and are installing, the installer will ask you for a password for MySQL’s root user. Just as the root user in Linux has complete control over the system, the root user in MySQL has absolute control over all databases, tables, permissions, and users. For obvious security reasons, you’ll want to create an extremely strong password (a mixture of uppercase, lowercase, numbers, and punctuation, the longer the better) for your MySQL root user.

(Note that in the password dialog box, if you can’t get the <OK> field selected, you can use the tab key to jump from the text input line to the <OK> field.)

After you enter the root password, the installer will finish working with the MySQL files, and return you to the command line.

Next, you’ll want to run the mysql_secure_installation script to tighten up security on your new MySQL server. Run this command from the prompt:

sudo mysql_secure_installation

First, the mysql_secure_installation script will ask you to enter the current password for the MySQL root user. After you do that, it will ask if you want to change the root password. Since you already set a root password, you can hit “n” (unless you want to change it again for some reason).

Next, the script will ask you to setup the VALIDATE PASSWORD plugin, which checks passwords for appropriate strength. Hit Y to accept, and then set the password strength level by hitting 0 for Low, 1, for Medium, and 2 for Strong.

Next, the script will ask if you want to remove the anonymous user. The anonymous user, like anonymous access in FTP, lets someone log into MySQL without having a proper user account. For security reasons, it’s always best to remove the anonymous user, so hit “y” to continue.

After that, the script will ask if you want to prevent the MySQL root user from logging in remotely to the MySQL server. Always hit “y” to forbid root remote access, since if an attacker guesses your root password, he can destroy your databases or steal the information they contain.

After this, the script will ask if you want to remove the test database. MySQL includes a test database that anyone can access. Again, this is a security hole, so you’ll want to hit “y” to remove the test database.

The script will then ask to reload the privilege tables so the changes take effect. Hit “y”, and the mysql_secure_installation script will conclude and return you to the command line.

MySQL server is now installed on your Ubuntu system.
Now we’ll need to prepare MySQL for use with Moodle. Moodle requires a database and a database user, and full permission for its database user to access its database. To start the MySQL command-line client, use this command:

mysql -u root -p

Enter the password for the MySQL root user, and you’ll find yourself at the MySQL command prompt, which will look like this:

mysql>

Our next steps are to create a Moodle database, create a user to access that database, and grant our new user all rights to the Moodle database.

(An important note before we continue, though. All commands made from the MySQL prompt must end with a semicolon to denote the end of the statement. Any commands that do not end with a semicolon will not work. With that in mind, let’s first create a database.)

To create a database for Moodle, use this command at the mysql> prompt:

CREATE DATABASE moodle;

The MySQL client will respond with a message that should say “Query OK, 1 row affect (0.00 sec).” This means the command was successful, and a new database named “newdatabase” has been created.

Next, you’ll create a user who will access that database and assign a password to that user. In this example, we’ll assign a password of “1234”. However, in real life, just as with the root user, you’ll want to assign a strong password. (This database user won’t have full control over the MySQL user as the root user does, but we will give it full control over the database we just created, and a malicious user who guesses the password could cause all kinds of trouble.):

CREATE USER moodleuser IDENTIFIED BY ‘1234’;

Again you should get the “Query OK” confirmation message. The final step is to assign all privileges on the “moodle” database to the “moodleuser” user. Use this command to assign the permissions:

GRANT ALL PRIVILEGES ON moodle.* TO moodleuser IDENTIFIED BY ‘1234′;

That isn’t a typo – those are single quote marks (‘) instead of the usual double quote marks (“) that were used in the command to set the password. MySQL’s internal syntax, alas, isn’t always consistent. Anyway, if you typed the command correctly, you should get the “Query OK” confirmation again.

Once you are done, use this command to quit the MySQL command-line interface:

exit

The next step to installing Moodle is to install PHP version 5, along with the necessary PHP modules. First, install PHP 5 with this command:

sudo apt-get install php

After this, you will need to install several different PHP extensions not included with the default PHP 5 implementation on Ubuntu. First, install the MySQL module for PHP:

sudo apt-get install php-mysql

You must also install the GD library for PHP:

sudo apt-get install php-gd

The JSON extension is also required:

sudo apt-get install php-json

The CURL extension:

sudo apt-get install php-curl

The XML extension:

sudo-apt-get install php-xml

The XMLRPC extension:

sudo apt-get install php-xmlrpc

The ZIP extension:

sudo apt-get install php-zip

The MBSTRING extension:

sudo apt-get install php-mbstring

The SOAP extension:

sudo apt-get install php-soap

And, finally, the INTL extension:

sudo apt-get install php-intl

After all the plugins have installed, restart Apache so it recognizes the plugins properly:

sudo /etc/init.d/apache2 restart

Finally, download the Moodle software to your Desktop. You can obtain it from this address:

http://download.moodle.org

Move the Moodle files over to the /var/www/html directory. (In this command, I’ll assume you unpacked the moodle files to your home directory; you will have to adjust the command if you unpacked them in a different directory.)

sudo cp -r ~/moodle/* /var/www/html

After that, rename the old index.html file in /var/www so Apache uses Moodle’s PHP files for the site, not the index.html file:

sudo mv index.html index.html.old

Now that we’ve got our software downloaded, we’ll need to configure it.

You will need to create a location for Moodle to save data files. Traditionally, the location is in /var/moodledata. (Creating the data directory inside the web server directory is an extremely bad idea, due to the resultant security holes.) To create the data directory, use this command:

sudo mkdir /var/moodledata

Use this command to change the owner of the directory to the Apache system user. In Ubuntu, the Apache system user is usually named www-data:

sudo chown www-data /var/moodledata

Then use this command to make the /var/moodledata directory writable to Moodle:

sudo chmod -R 744 /var/moodledata

Now that configuration and setup is complete, we are actually read to begin installing Moodle!

Fire up a web browser and navigate to the Moodle location to launch the web-based installer. If your server’s IP address (for example) is 192.168.1.100, the address would look like this:

http://192.168.1.100

This will take you to the Moodle setup page.

First, select the language for your Moodle installation, and then click the Next button.

The installer will then ask for the locations of Moodle’s directories. The defaults will work, especially if you already created the /var/moodledata directory as indicated above. Click the Next button to continue.

Moodle will then ask what kind of database server to use. Since we already set up our MySQL database, select “Improved MySQL” and then hit the Next button.

Then installer will then need you to input the information for the database and database user we created above. Since our MySQL server is on the same machine as Moodle, leave “localhost” for the Database Host field. Enter “moodle” for Database Name, “moodleuser” for Database User, and then ’1234′ for Database Password. Leave the other fields blank, and then click Next.

Moodle will then generate a config.php file. Copy and paste the data of the config.php file, save it as “config.php”, and then transfer it to your server. Make sure to put it in the directory containing the Moodle installation – in this example, /var/www. Once the config.php is in place, make sure to mark it as executable with this command, otherwise the installation will halt:

sudo chmod 744 /var/www/html/config.php

Save config.php file, and then go back to the web browser and click the Next button.

Moodle will then ask if you agree to the terms of service. If you do, click the Continue button.

The installer will then run a system check to make sure your server has all the necessary software to support Moodle. If not (it’s common to forget one of the PHP extensions), the installation will pause to allow you to install the missing software. Once you have, click Reload. If all the checks are passed, you can click the Continue button to continue.

The Moodle installer will then start building the database tables it requires in the database we created earlier. The Moodle database is large and complex, and building the database may take a considerable amount of time, so be patient. As the installer successfully builds database tables, they will scroll down in the browser window. Once the database construction is complete, the Continue button will appear at the very bottom of the page. Click on it to continue.

Moodle will then display a form for you to set up an administrator account for your new site. Enter an appropriate username and a strong password, along with any other required fields. Once you have finished, click on the Update Profile button at the bottom of the page.

The install will then ask you to pick a full site name and a short name for the site. Select suitable names, and then click the Save Changes button.

Congratulations! Your Moodle installation is now complete, and you can begin adding courses and other materials. For additional documentation, the Moodle site contains many useful resources:

http://docs.moodle.org/26/en/Main_page

Was this post helpful? These books might be useful:

Install And Configure MediaWiki On Ubuntu 16.10 Yakkety Yak

Wikipedia, that encyclopedia of a thousand “citations needed”, runs on an open-source web application called MediaWiki. A wiki, if you haven’t heard the term before, is basically an online encyclopedia that relies on user contributions. Wikis can range from broad, general-topic encyclopedias like Wikipedia itself, or devoted to a single topic, like a television show or a computer game. You can quite easily install MediaWiki and host your own wiki off a Ubuntu 16.10 Yakkety Yak system. Installing MediaWiki on Ubuntu takes three steps: first, you install the prerequisite software packages, second, you configure the prerequisites, and third, you install MediaWiki and run its configuration script.

Let’s begin!

First, install Ubuntu into your machine of choice. Once Ubuntu is installed and updated, you will need to install five pieces of software: the Apache web server, the MySQL database server version 5.7, PHP version 7, the MySQL module for PHP, and finally the MediaWiki software itself.

First, install the Apache web server. To install Apache, go to a Terminal window or a command prompt and type this command:

sudo apt-get install apache2

(Technically, you’ll be installing Apache 2, the latest version.)

Enter your password to authenticate, follow the default prompts, and apt will download and install the Apache web server for you.

And that’s it! Apache should now be working. To test it from the web server itself, go to a web browser and visit the address http://127.0.0.1. You’ll remember that this is the “local loopback” address, basically the address the computer uses to refer to itself. Alternatively, you could test it from another computer on the same subnet. For instance, if you installed Apache on a computer with an IP address of 192.168.1.100, you could test it by going to another computer on the same subnet and visiting http://192.168.100 from the web browser.

Regardless, if Apache is working properly, you should see the default Apache/Ubuntu web page with the Ubuntu logo in the upper left-hand corner.

Apache is now operational.

The next step to install MediaWiki is to install the MySQL database server. Return to the Terminal and type this command:

sudo apt-get install mysql-server-5.7

(As of this writing, MySQL Server version 5.7 is the latest version available in the Ubuntu repositories, though future versions of Ubuntu may receive the newer versions of MySQL.)

Enter your password to authenticate, and apt will download the MySQL files and install them for you. It’s a big set of files, so depending on the speed of your Internet connection, it might take a while to download. After the files are downloaded and are installing, the installer will ask you for a password for MySQL’s root user. Just as the root user in Linux has complete control over the system, the root user in MySQL has absolute control over all databases, tables, permissions, and users. For obvious security reasons, you’ll want to create an extremely strong password (a mixture of uppercase, lowercase, numbers, and punctuation, the longer the better) for your MySQL root user.

(Note that in the password dialog box, if you can’t get the <OK> field selected, you can use the tab key to jump from the text input line to the <OK> field.)

After you enter the root password, the installer will finish working with the MySQL files, and return you to the command line.

Next, you’ll want to run the mysql_secure_installation script to tighten up security on your new MySQL server. Run this command from the prompt:

sudo mysql_secure_installation

First, the mysql_secure_installation script will ask you to enter the current password for the MySQL root user. After you do that, it will ask if you want to change the root password. Since you already set a root password, you can hit “n” (unless you want to change it again for some reason).

Next, the script will ask you to setup the VALIDATE PASSWORD plugin, which checks passwords for appropriate strength. Hit Y to accept, and then set the password strength level by hitting 0 for Low, 1, for Medium, and 2 for Strong.

Next, the script will ask if you want to remove the anonymous user. The anonymous user, like anonymous access in FTP, lets someone log into MySQL without having a proper user account. For security reasons, it’s always best to remove the anonymous user, so hit “y” to continue.

After that, the script will ask if you want to prevent the MySQL root user from logging in remotely to the MySQL server. Always hit “y” to forbid root remote access, since if an attacker guesses your root password, he can destroy your databases or steal the information they contain.

After this, the script will ask if you want to remove the test database. MySQL includes a test database that anyone can access. Again, this is a security hole, so you’ll want to hit “y” to remove the test database.

The script will then ask to reload the privilege tables so the changes take effect. Hit “y”, and the mysql_secure_installation script will conclude and return you to the command line.

MySQL server is now installed on your Ubuntu system.

The next step to installing MediaWiki is to install PHP version 7:

sudo apt-get install php

Then install the MySQL module for PHP:

sudo apt-get install php-mysql

Then install the mbstring PHP module:

sudo apt-get install php-mbstring

Then install the xml PHP module:

sudo apt-get install php-xml

Finally, download the MediaWiki software to your Desktop. You can obtain it from this address:

https://www.mediawiki.org/wiki/Download

If you’re working exclusively from the command line, you can use this command to download the MediaWiki software:

wget https://releases.wikimedia.org/mediawiki/1.27/mediawiki-1.27.1.tar.gz

(Note that the version number, and hence the file name, WILL change with future versions of MediaWiki, so double-check before downloading the file.)

Use this command to unpack the MediaWiki files:

tar -xzvf mediawiki-1.27.1.tar.gz

Finally, move the MediaWiki files over to the /var/www/html directory. (In this command, I’ll assume you unpacked the MediaWiki files to your home directory; you will have to adjust the command if you unpacked them in a different directory.)

sudo cp -r ~/mediawiki-1.27.1/* /var/www/html

Now we’ll need to prepare MySQL for use with MediaWiki. MediaWiki requires a database and a database user, and full permission for its database user to access its database. To start the MySQL command-line client, use this command:

mysql -u root -p

Enter the password for the MySQL root user, and you’ll find yourself at the MySQL command prompt, which will look like this:

mysql>

Our next steps are to create a MediaWiki database, create a user to access that database, and grant our new user all rights to the MediaWiki database.

(An important note before we continue, though. All commands made from the MySQL prompt must end with a semicolon to denote the end of the statement. Any commands that do not end with a semicolon will not work. With that in mind, let’s first create a database.)

To create a database for MediaWiki, use this command at the mysql> prompt:

CREATE DATABASE mediawiki;

The MySQL client will respond with a message that should say “Query OK, 1 row affect (0.00 sec).” This means the command was successful, and a new database named “newdatabase” has been created.

Next, you’ll create a user who will access that database and assign a password to that user. In this example, we’ll assign a password of “1234”. However, in real life, just as with the root user, you’ll want to assign a strong password. (This database user won’t have full control over the MySQL user as the root user does, but we will give it full control over the database we just created, and a malicious user who guesses the password could cause all kinds of trouble.):

CREATE USER mediawikiuser IDENTIFIED BY ‘1234’;

Again you should get the “Query OK” confirmation message. The final step is to assign all privileges on the “mediawiki” database to the “mediawikiuser” user. Use this command to assign the permissions:

GRANT ALL PRIVILEGES ON mediawiki.* TO mediawikiuser IDENTIFIED BY ‘1234′;

That isn’t a typo – those are single quote marks (‘) instead of the usual double quote marks (“) that were used in the command to set the password. MySQL’s internal syntax, alas, isn’t always consistent. Anyway, if you typed the command correctly, you should get the “Query OK” confirmation again.

Once you are done, use this command to quit the MySQL command-line interface:

exit

Once is this is done, rename Apache’s default index.html file to index.html.old. Otherwise Apache will access the default sample page instead of starting WordPress:

sudo mv index.html index.html.old

Once the permissions have been set, launch the installation script by navigating here in your Ubuntu system’s web browser:

http://127.0.0.1

The installation script is simply a web form you’ll need to fill out. The default settings will work for the most part. You’ll need to pick a name for your wiki, and you’ll also need to enter the database name, the database user, and the password you created for MySQL. You will also need to set an administrator username and password for the wiki. Once you have appropriate information entered, complete the script, and MediaWiki will be installed.

However, you’ll need to do one more thing to finish the installation. After you complete the install script, MediaWiki will generate a LocalSettings.php file and offer it to you for download. Make sure to download the file and then transfer it to the /var/www/html file in order to complete the installation. (You may need to use SSH and SFTP to do this – see Chapter 10 on how to set them up.)

MediaWiki should now be functioning on your Ubuntu system.

Was this post helpful? These books might be useful:

Install WordPress On Ubuntu 16.10 Yakkety Yak

wordpress

These directions will show how to install WordPress on Ubuntu 16.10 Yakkety Yak.

First, install the Apache web server. To install Apache, go to a Terminal window or a command prompt and type this command:

sudo apt-get install apache2

(Technically, you’ll be installing Apache 2, the latest version.)

Enter your password to authenticate, follow the default prompts, and apt will download and install the Apache web server for you.

And that’s it! Apache should now be working. To test it from the web server itself, go to a web browser and visit the address http://127.0.0.1. You’ll remember that this is the “local loopback” address, basically the address the computer uses to refer to itself. Alternatively, you could test it from another computer on the same subnet. For instance, if you installed Apache on a computer with an IP address of 192.168.1.100, you could test it by going to another computer on the same subnet and visiting http://192.168.100 from the web browser.

Regardless, if Apache is working properly, you should see the default Apache/Ubuntu web page with the Ubuntu logo in the upper left-hand corner.

Apache is now operational.

The next step to install WordPress is to install the MySQL database server. Return to the Terminal and type this command:

sudo apt-get install mysql-server-5.7

(As of this writing, MySQL Server version 5.7 is the latest version available in the Ubuntu repositories, though future versions of Ubuntu may receive the newer versions of MySQL.)

Enter your password to authenticate, and apt will download the MySQL files and install them for you. It’s a big set of files, so depending on the speed of your Internet connection, it might take a while to download. After the files are downloaded and are installing, the installer will ask you for a password for MySQL’s root user. Just as the root user in Linux has complete control over the system, the root user in MySQL has absolute control over all databases, tables, permissions, and users. For obvious security reasons, you’ll want to create an extremely strong password (a mixture of uppercase, lowercase, numbers, and punctuation, the longer the better) for your MySQL root user.

(Note that in the password dialog box, if you can’t get the <OK> field selected, you can use the tab key to jump from the text input line to the <OK> field.)

After you enter the root password, the installer will finish working with the MySQL files, and return you to the command line.

Next, you’ll want to run the mysql_secure_installation script to tighten up security on your new MySQL server. Run this command from the prompt:

sudo mysql_secure_installation

First, the mysql_secure_installation script will ask you to enter the current password for the MySQL root user. After you do that, it will ask if you want to change the root password. Since you already set a root password, you can hit “n” (unless you want to change it again for some reason).

Next, the script will ask you to setup the VALIDATE PASSWORD plugin, which checks passwords for appropriate strength. Hit Y to accept, and then set the password strength level by hitting 0 for Low, 1, for Medium, and 2 for Strong.

Next, the script will ask if you want to remove the anonymous user. The anonymous user, like anonymous access in FTP, lets someone log into MySQL without having a proper user account. For security reasons, it’s always best to remove the anonymous user, so hit “y” to continue.

After that, the script will ask if you want to prevent the MySQL root user from logging in remotely to the MySQL server. Always hit “y” to forbid root remote access, since if an attacker guesses your root password, he can destroy your databases or steal the information they contain.

After this, the script will ask if you want to remove the test database. MySQL includes a test database that anyone can access. Again, this is a security hole, so you’ll want to hit “y” to remove the test database.

The script will then ask to reload the privilege tables so the changes take effect. Hit “y”, and the mysql_secure_installation script will conclude and return you to the command line.

MySQL server is now installed on your Ubuntu system.

The next step to installing WordPress is to install PHP version 7:

sudo apt-get install php

Then install the MySQL module for PHP:

sudo apt-get install php-mysql

You may also want to install the GD library for PHP, since many WordPress plugins rely on it for graphical manipulation (note that this is an optional step):

sudo apt-get install php-gd

Finally, download the WordPress software to your computer. You can obtain it from this address:

http://wordpress.org/latest.tar.gz

If you’re working exclusively from the command line, you can use this command to download the WordPress software:

wget http://wordpress.org/latest.tar.gz

Use this command to unpack the WordPress files:

tar -xzvf latest.tar.gz

Move the WordPress files over to the /var/www/html directory. (In this command, I’ll assume you unpacked the WordPress files to your home directory; you will have to adjust the command if you unpacked them in a different directory.)

sudo cp -r ~/wordpress/* /var/www/html/

Now that we’ve got our software installed and downloaded, we’ll need to configure it. First, we’ll need to prepare MySQL for use with WordPress. WordPress requires a database and a database user, and full permission for its database user to access its database. To start the MySQL command-line client, use this command:

mysql -u root -p

Enter the password for the MySQL root user, and you’ll find yourself at the MySQL command prompt, which will look like this:

mysql>

Our next steps are to create a WordPress database, create a user to access that database, and grant our new user all rights to the WordPress database.

(An important note before we continue, though. All commands made from the MySQL prompt must end with a semicolon to denote the end of the statement. Any commands that do not end with a semicolon will not work. With that in mind, let’s first create a database.)

To create a database for WordPress, use this command at the mysql> prompt:

CREATE DATABASE wordpress;

The MySQL client will respond with a message that should say “Query OK, 1 row affect (0.00 sec).” This means the command was successful, and a new database named “newdatabase” has been created.

Next, you’ll create a user who will access that database and assign a password to that user. In this example, we’ll assign a password of “1234”. However, in real life, just as with the root user, you’ll want to assign a strong password. (This database user won’t have full control over the MySQL user as the root user does, but we will give it full control over the database we just created, and a malicious user who guesses the password could cause all kinds of trouble.):

CREATE USER wordpressuser IDENTIFIED BY ‘1234’;

You should get the “Query OK” message again. The final step is to assign all privileges on the “wordpress” database to the “wordpressuser” user. Use this command to assign the permissions:

GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser IDENTIFIED BY ‘1234′;

That isn’t a typo – those are single quote marks (‘) instead of the usual double quote marks (“) that were used in the command to set the password. MySQL’s internal syntax, alas, isn’t always consistent. Anyway, if you typed the command correctly, you should get the “Query OK” confirmation again.

Once you are done, use this command to quit the MySQL command-line interface:

exit

Now that we have MySQL prepared, we can now configure WordPress itself. Specifically, we’ll have to configure WordPress to talk to the database we just created. To do so, you must create a wp-config.php file in the WordPress directory. Fortunately, WordPress includes a handy wp-config-sample.php you can use as a template.

Type this command to create a wp-config file (assuming you installed WordPress in the /var/www/html directory):

sudo cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wp-config.php

Next, use vi to edit the newly created wp-config file:

sudo vi /var/www/html/wp-config.php

You’ll see that the wp-config.php file contains a number of variables. Change the following three variables:

-Change putyourdbnamehere to wordpress .

-Change usernamehere to wordpressuser .

-Change yourpassword here to 1234 .

Once you have your changes made (after double-checking the spelling, of course), switch vi to Command mode, and save your changed file.

Once is this is done, rename Apache’s default index.html file to index.html.old. Otherwise Apache will access the default sample page instead of starting WordPress:

sudo mv index.html index.html.old

Everything should now be ready. Open up a web browser, and navigate to http://127.0.0.1/. (If you want to access it from a different machine, of course, use the IP address of the WordPress server, for instance – http://192.168.1.100.) If you configured everything correctly, you should then be greeted by the WordPress configuration page. You’ll pick a username, and WordPress will assign you a password. Follow the prompts, and you will have a functional WordPress blog installed on a Ubuntu machine. Congratulations!

One final note: if you configure your blog from a local browser, it will probably set your blog’s address as http://127.0.0.1. This is fine if you only want to view it from the host machine, but if you want to view it over the network, you’ll need to change it. Fortunately, you can do so quickly by going Options in the WordPress admin interface, and then to General, and changing the blog’s URL.

Was this post helpful? These books might be useful:

Backup & Restore MySQL Databases In Ubuntu 16.10 Yakkety Yak

mysql

MySQL databases are often used to power web applications such as WordPress or Moodle, which means that those MySQL databases often wind up holding vital information. Therefore, it is important to back them up on a regular basis. A quick and easy way to backup a MySQL database is with the mysqldump command-line tool. This tool downloads the database into a single SQL file, which you can store as a backup or use to transfer the database to another MySQL server, and is quite easy to use in Ubuntu 16.10 Yakkety Yak.

To use mysqldump, you will need to know the root password of the MySQL server (or a user with permissions to the database you need to download).

In this example, we will dump a database named data into a file named data.sql:

mysqldump -u root -p data > data.sql

Enter the root password, and mysqldump will dump the database information into the data.sql file.

To transfer the database to a new server, first create a blank database on the server from the MySQL command prompt. In this example, this command will create a new database named datanew:

CREATE DATABASE datanew;

Then transfer the data.sql file to the new server and write it onto the new database with this command:

mysql -u root -p datanew < data.sql

The datanew database will receive all the tables and columns contained in the data.sql file. Note that this command completely overwrites the target database with the information in the SQL file, so make sure to select the correct database!

Was this post helpful? These books might be useful:

Using The MySQL Client In Ubuntu 16.10 Yakkety Yak

mysql

The most common use for MySQL on a Ubuntu 16.10 Yakkety Yak system is to provide a backend for a dynamic website of some kind, usually content management systems like WordPress or MediaWiki. To host these websites on a Ubuntu machine, you’ll need to create a database and a database user for the website. MySQL Server can support many different databases, limited by the amount of hardware and disk space available on the machine. (Hosting multiple active databases at the same time places a high level of demand upon a hard drive.)

Like Samba, MySQL has its own collection of user accounts, separate from the main system accounts, called “database users.” A database user is simply a MySQL user that has access to a particular database, or specific tables within a database. In this section, we’ll show you how to create database and users with the command-line client.

First, you’ll need to get to the MySQL client prompt. The MySQL command-line client, like the command-line clients for FTP and SFTP, has its own prompt. To access that prompt and start the client, use this command:

mysql

However, if you simply type the command, it will bounce back with an error message. To use the MySQL command-line client, you need to add the -u and the -p switches as well. The -u switch tells it what MySQL user you want to use to log into the client (similar to the -l switch with SSH). The -p switch tells it to ask for the password. So, to use the MySQL client as the MySQL root user, the command should look like this:

mysql -u root -p

Enter the password for the MySQL root user, and you’ll find yourself at the MySQL command prompt, which will look like this:

mysql>

Our next steps are to create a database, create a user to access that database, and grant our new user all rights to that database. Generally, when you’re installing a web application like WordPress, you’ll give the database user you create for the WordPress application all rights to the WordPress database so it can function properly. Not giving the application user all rights to the database can cause the application to act erratically or even fail entirely (though some applications can work with limited access to its database).

An important note before we continue, though. All commands made from the MySQL prompt must end with a semicolon to denote the end of the statement. Any commands that do not end with a semicolon will not work. With that in mind, let’s first create a database.

To create a database, use this command at the mysql> prompt:

CREATE DATABASE newdatabase;

The MySQL client will respond with a message that should say “Query OK, 1 row affect (0.00 sec).” This means the command was successful, and a new database named “newdatabase” has been created.

Next, you’ll create a user who will access that database:

CREATE USER newdatabaseruser;

You should get the “Query OK” message again. Once the new user is created, we’ll need to set a password for the user before we can assign any permissions. In this example, we’ll assign a password of “1234”. However, in real life, just as with the root user, you’ll want to assign a strong password. (This database user won’t have full control over the MySQL server as the root user does, but we will give it full control over the database we just created, and a malicious user who guesses the password could cause all kinds of trouble.) To create the password, use this command:

SET PASSWORD FOR newdatabaseuser= PASSWORD(“1234”);

Again you should get the “Query OK” confirmation message. The final step is to assign all privileges on the “newdatabase” database to the “newdatabaseuser” user. Use this command to assign the permissions:

GRANT ALL PRIVILEGES ON newdatabase.* TO newdatabaseuser IDENTIFIED BY ‘1234;

That isn’t a typo – those are single quote marks (‘) instead of the usual double quote marks (“) that were used in the command to set the password. MySQL’s internal syntax, alas, isn’t always consistent. Anyway, if you typed the command correctly, you should get the “Query OK” confirmation again.

Once you are done, use this command to quit the MySQL command-line interface:

exit

You’ve now set up a database, created a database user, and given that user full control over that database.

Was this post helpful? These books might be useful:

Install MySQL Server On Ubuntu 16.10 Yakkety Yak

To install MySQL Server on Ubuntu 16.10 Yakkety Yak, make your way to a Terminal window or a command prompt, and type this command:

sudo apt-get install mysql-server-5.7

(As of this writing, MySQL Server version 5.7 is the latest version available in the Ubuntu repositories, though future versions of Ubuntu may receive the newer versions of MySQL.)

Enter your password to authenticate, and apt will download the MySQL files and install them for you. It’s a big set of files, so depending on the speed of your Internet connection, it might take a while to download. After the files are downloaded and are installing, the installer will ask you for a password for MySQL’s root user. Just as the root user in Linux has complete control over the system, the root user in MySQL has absolute control over all databases, tables, permissions, and users. For obvious security reasons, you’ll want to create an extremely strong password (a mixture of uppercase, lowercase, numbers, and punctuation, the longer the better) for your MySQL root user.

(Note that in the password dialog box, if you can’t get the <OK> field selected, you can use the tab key to jump from the text input line to the <OK> field.)

After you enter the root password, the installer will finish working with the MySQL files, and return you to the command line.

Next, you’ll want to run the mysql_secure_installation script to tighten up security on your new MySQL server. Run this command from the prompt:

sudo mysql_secure_installation

First, the mysql_secure_installation script will ask you to enter the current password for the MySQL root user. After you do that, it will ask if you want to change the root password. Since you already set a root password, you can hit “n” (unless you want to change it again for some reason).

Next, the script will ask you to setup the VALIDATE PASSWORD plugin, which checks passwords for appropriate strength. Hit Y to accept, and then set the password strength level by hitting 0 for Low, 1, for Medium, and 2 for Strong.

Next, the script will ask if you want to remove the anonymous user. The anonymous user, like anonymous access in FTP, lets someone log into MySQL without having a proper user account. For security reasons, it’s always best to remove the anonymous user, so hit “y” to continue.

After that, the script will ask if you want to prevent the MySQL root user from logging in remotely to the MySQL server. Always hit “y” to forbid root remote access, since if an attacker guesses your root password, he can destroy your databases or steal the information they contain.

After this, the script will ask if you want to remove the test database. MySQL includes a test database that anyone can access. Again, this is a security hole, so you’ll want to hit “y” to remove the test database.

The script will then ask to reload the privilege tables so the changes take effect. Hit “y”, and the mysql_secure_installation script will conclude and return you to the command line.

MySQL server is now installed on your Ubuntu system.

Was this post helpful? These books might be useful:

Configure Apache Virtual Hosts On Ubuntu 16.10 Yakkety Yak

apache2

It is easy to set up a simple web server with Apache on Ubuntu 16.10 Yakkety Yak. However, you might need a more complex web server, one that can host multiple separate websites, rather than subdirectories within a larger website.

How do you do this?

Apache has a feature called “virtual hosts” that lets you run separate websites, with completely different domain names, on the same physical server. Fortunately, implementing virtual hosts for Apache is actually quite simple to do. In this example, we’ll show you how to set up a new website called “examplename.com” on an Apache web server.

First, you’ll need to set a location for your new web site’s files. Apache, you might recall, by default stores the web files in /var/www/html. For this example, create a new folder for the website with this command:

sudo mkdir /var/www/html/w2

Next, you’ll need to create a configuration file for the new website in the /etc/apache2/sites-available directory. Fortunately, that directory contains a default file you can simply copy and use as a template with this command:

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/examplename.conf

(Make sure to include .conf extension. Ubuntu 14.04 Trusty Tahr and above run Apache 2.4, which requires it.)

The next step is to edit the new configuration file with the correct settings. You can do this using the vi text editor:

sudo vi /etc/apache2/sites-available/examplename.conf

(We discussed how to use vi back in Chapter 6.)

Once editing the file with vi, you’ll need to make a few changes.

Change the “Document Root” directive from /var/www/html to the proper location of your new website, in this case, /var/www/html/w2.

Also change the “Directory” directive from /var/www/html to /var/www/html/w2.

Finally, under the line that begins “ServerAdmin”, add a new line for the new website’s domain name. For our website named “examplename.com”, add a line like this:

ServerName examplename.com

Save changes to the configuration file, and then exit vi.

Now you’ll need to modify Apache to display the new domain names to web visitors. Fortunately, you can do this with the a2ensite command:

sudo a2ensite examplename.conf

(Note that “examplename” would change depending upon what you named your configuration file.)

One final step – restart Apache to force it to re-read its configuration files and start serving the new website:

sudo /etc/init/d apache2 restart

Make sure you have some sort of index.html file in /var/www/html/w2, and the examplename.com website should now be working.

Was this post helpful? These books might be useful:

Install Apache Web Server On Ubuntu 16.10 Yakkety Yak

apache2

As installations go, installing Apache on Ubuntu 16.10 Yakkety Yak is a breeze. (Configuring it, of course, is substantially more difficult.) To install Apache, type this command at a Terminal window or a command prompt:

sudo apt-get install apache2

(Technically, you’ll be installing Apache 2, the latest version.)

Enter your password to authenticate, follow the default prompts, and apt will download and install the Apache web server for you.

And that’s it! Apache should now be working. To test it from the web server itself, go to a web browser and visit the address http://127.0.0.1. You’ll remember that this is the “local loopback” address, basically the IP address the local computer uses to refer to itself. Alternatively, you could test it from another computer on the same subnet. For instance, if you installed Apache on a computer with an IP address of 192.168.1.100, you could test it by going to another computer on the same subnet and visiting http://192.168.100 from the web browser.

Regardless, if Apache is working properly, you should see the default Apache/Ubuntu web page with the Ubuntu logo in the upper left-hand corner.

Apache is now operational.

Was this post helpful? These books might be useful: