A Basic MySQL Tutorial

MySQL

About MySQL

MySQL is open source database management software that helps users store, organize, and retrieve data. It is a very powerful program with a lot of flexibility—this tutorial will provide the simplest introduction to MySQL

How to Install MySQL on Ubuntu and CentOS

If you don’t have MySQL installed on your droplet, you can quickly download it.

Ubuntu:

sudo apt-get install mysql-server

Centos:

sudo yum install mysql-server

/etc/init.d/mysqld start

How to Access the MySQL shell

Once you have MySQL installed on your droplet, you can access the MySQL shell by typing the following command into terminal:

mysql -u root -p

After entering the root MySQL password into the prompt (not to be confused with the root droplet password), you will be able to start building your MySQL database.

Two points to keep in mind:

  • All MySQL commands end with a semicolon; if the phrase does not end with a semicolon, the command will not execute.
  • Also, although it is not required, MySQL commands are usually written in uppercase and databases, tables, usernames, or text are in lowercase to make them easier to distinguish. However, the MySQL command line is not case sensitive.

How to Create and Delete a MySQL Database

MySQL organizes its information into databases; each one can hold tables with specific data.

You can quickly check what databases are available by typing:

SHOW DATABASES;

Your screen should look something like this:

mysql> SHOW DATABASES;

+——————–+

| Database           |

+——————–+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+——————–+

4 rows in set (0.01 sec)

Creating a database is very easy:

CREATE DATABASE database name;

In this case, for example, we will call our database “events.”

mysql> SHOW DATABASES;

+——————–+

| Database           |

+——————–+

| information_schema |

| events             |

| mysql              |

| performance_schema |

| test               |

+——————–+

5 rows in set (0.00 sec)

In MySQL, the phrase most often used to delete objects is Drop. You would delete a MySQL database with this command:

DROP DATABASE database name;

How to Access a MySQL Database

Once we have a new database, we can begin to fill it with information.

The first step is to create a new table within the larger database.

Let’s open up the database we want to use:

USE events;

In the same way that you could check the available databases, you can also see an overview of the tables that the database contains.

SHOW tables;

Since this is a new database, MySQL has nothing to show, and you will get a message that says, “Empty set”

How to Create a MySQL Table

Let’s imagine that we are planning a get together of friends. We can use MySQL to track the details of the event.

Let’s create a new MySQL table:

CREATE TABLE potluck (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,

name VARCHAR(20),

food VARCHAR(30),

confirmed CHAR(1),

signup_date DATE);

This command accomplishes a number of things:

  1. It has created a table called potluck within the directory, events.
  2. We have set up 5 columns in the table—id, name, food, confirmed, and signup date.
  3. The “id” column has a command (INT NOT NULL PRIMARY KEY AUTO_INCREMENT) that automatically numbers each row.
  4. The “name” column has been limited by the VARCHAR command to be under 20 characters long.
  5. The “food” column designates the food each person will bring. The VARCHAR limits text to be under 30 characters.
  6. The “confirmed” column records whether the person has RSVP’d with one letter, Y or N.
  7. The “date” column will show when they signed up for the event. MySQL requires that dates be written as yyyy-mm-dd

Let’s take a look at how the table appears within the database using the “SHOW TABLES;” command:

mysql> SHOW TABLES;

+——————+

| Tables_in_events |

+——————+

| potluck          |

+——————+

1 row in set (0.01 sec)

We can remind ourselves about the table’s organization with this command:

DESCRIBE potluck;

Keep in mind throughout that, although the MySQL command line does not pay attention to cases, the table and database names are case sensitive: potluck is not the same as POTLUCK or Potluck.

mysql>DESCRIBE potluck;

+————-+————-+——+—–+———+—————-+

| Field       | Type        | Null | Key | Default | Extra          |

+————-+————-+——+—–+———+—————-+

| id          | int(11)     | NO   | PRI | NULL    | auto_increment |

| name        | varchar(20) | YES  |     | NULL    |                |

| food        | varchar(30) | YES  |     | NULL    |                |

| confirmed   | char(1)     | YES  |     | NULL    |                |

| signup_date | date        | YES  |     | NULL    |                |

+————-+————-+——+—–+———+—————-+

5 rows in set (0.01 sec)

How to Add Information to a MySQL Table

We have a working table for our party. Now it’s time to start filling in the details.

Use this format to insert information into each row:

INSERT INTO `potluck` (`id`,`name`,`food`,`confirmed`,`signup_date`) VALUES (NULL, “John”, “Casserole”,”Y”, ‘2012-04-11’);

Once you input that in, you will see the words:

Query OK, 1 row affected (0.00 sec)

Let’s add a couple more people to our group:

INSERT INTO `potluck` (`id`,`name`,`food`,`confirmed`,`signup_date`) VALUES (NULL, “Sandy”, “Key Lime Tarts”,”N”, ‘2012-04-14’);

INSERT INTO `potluck` (`id`,`name`,`food`,`confirmed`,`signup_date`) VALUES (NULL, “Tom”, “BBQ”,”Y”, ‘2012-04-18’);

INSERT INTO `potluck` (`id`,`name`,`food`,`confirmed`,`signup_date`) VALUES (NULL, “Tina”, “Salad”,”Y”, ‘2012-04-10’);

We can take a look at our table:

mysql> SELECT * FROM potluck;

+—-+——-+—————-+———–+————-+

| id | name  | food           | confirmed | signup_date |

+—-+——-+—————-+———–+————-+

|  1 | John  | Casserole      | Y         | 2012-04-11  |

|  2 | Sandy | Key Lime Tarts | N         | 2012-04-14  |

|  3 | Tom   | BBQ            | Y         | 2012-04-18  |

|  4 | Tina  | Salad          | Y         | 2012-04-10  |

+—-+——-+—————-+———–+————-+

4 rows in set (0.00 sec)

How to Update Information in the Table

Now that we have started our potluck list, we can address any possible changes. For example: Sandy has confirmed that she is attending, so we are going to update that in the table.

UPDATE `potluck`

SET

`confirmed` = ‘Y’

WHERE `potluck`.`name` =’Sandy’;

You can also use this command to add information into specific cells, even if they are empty.

How to Add and Delete a Column

We are creating a handy chart, but it is missing some important information: our attendees’ emails.

We can easily add this:

ALTER TABLE potluck ADD email VARCHAR(40);

This command puts the new column called “email” at the end of the table by default, and the VARCHAR command limits it to 40 characters.

However, if you need to place that column in a specific spot in the table, we can add one more phrase to the command.

ALTER TABLE potluck ADD email VARCHAR(40) AFTER name;

Now the new “email” column goes after the column “name”.

Just as you can add a column, you can delete one as well:

ALTER TABLE potluck DROP email;

I guess we will never know how to reach the picnickers.

How to Delete a Row

If needed, you can also delete rows from the table with the following command:

DELETE from [table name] where [column name]=[field text];

For example, if Sandy suddenly realized that she will not be able to participate in the potluck after all, we could quickly eliminate her details.

mysql> DELETE from potluck  where name=’Sandy’;

Query OK, 1 row affected (0.00 sec)

 

mysql> SELECT * FROM potluck;

+—-+——+———–+———–+————-+

| id | name | food      | confirmed | signup_date |

+—-+——+———–+———–+————-+

|  1 | John | Casserole | Y         | 2012-04-11  |

|  3 | Tom  | BBQ       | Y         | 2012-04-18  |

|  4 | Tina | Salad     | Y         | 2012-04-10  |

+—-+——+———–+———–+————-+

3 rows in set (0.00 sec)

Notice that the id numbers associated with each person remain the same.

 

A Basic MySQL Tutorial

How to Install Linux, Apache, MySQL, PHP (LAMP) stack On CentOS 6

About LAMP

LAMP stack is a group of open source software used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. Since the server is already running CentOS, the linux part is taken care of. Here is how to install the rest.

Set Up

The steps in this tutorial require the user on the virtual private server to have root privileges.

Step One—Install Apache

Apache is a free open source software which runs over 50% of the world’s web servers.

To install apache, open terminal and type in this command:

sudo yum install httpd

Once it installs, you can start apache running on your VPS:

sudo service httpd start

That’s it. To check if Apache is installed, direct your browser to your server’s IP address (eg. http://12.34.56.789). The page should display the words “It works!”.

How to find your Server’s IP address

You can run the following command to reveal your server’s IP address.

ifconfig eth0 | grep inet | awk ‘{ print $2 }’

 

Step Two—Install MySQL

MySQL is a powerful database management system used for organizing and retrieving data on a virtual server

To install MySQL, open terminal and type in these commands:

sudo yum install mysql-server

sudo service mysqld start

During the installation, MySQL will ask you for your permission twice. After you say Yes to both, MySQL will install.

Once it is done installing, you can set a root MySQL password:

sudo /usr/bin/mysql_secure_installation

The prompt will ask you for your current root password.

Since you just installed MySQL, you most likely won’t have one, so leave it blank by pressing enter.

Enter current password for root (enter for none):

OK, successfully used password, moving on…

Then the prompt will ask you if you want to set a root password. Go ahead and choose Y and follow the instructions.

CentOS automates the process of setting up MySQL, asking you a series of yes or no questions.

It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.

By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

 

Remove anonymous users? [Y/n] y

… Success!

 

Normally, root should only be allowed to connect from ‘localhost’.  This

ensures that someone cannot guess at the root password from the network.

 

Disallow root login remotely? [Y/n] y

… Success!

 

By default, MySQL comes with a database named ‘test’ that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

 

Remove test database and access to it? [Y/n] y

– Dropping test database…

… Success!

– Removing privileges on test database…

… Success!

 

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

 

Reload privilege tables now? [Y/n] y

… Success!

 

Cleaning up…

 

All done!  If you’ve completed all of the above steps, your MySQL

installation should now be secure.

 

Thanks for using MySQL!

Step Three—Install PHP

PHP is an open source web scripting language that is widely used to build dynamic webpages.

To install PHP on your virtual private server, open terminal and type in this command:

sudo yum install php php-mysql

Once you answer yes to the PHP prompt, PHP will be installed.

PHP Modules

PHP also has a variety of useful libraries and modules that you can add onto your server. You can see the libraries that are available by typing:

yum search php-

Terminal then will display the list of possible modules. The beginning looks like this:

php-bcmath.x86_64 : A module for PHP applications for using the bcmath library

php-cli.x86_64 : Command-line interface for PHP

php-common.x86_64 : Common files for PHP

php-dba.x86_64 : A database abstraction layer module for PHP applications

php-devel.x86_64 : Files needed for building PHP extensions

php-embedded.x86_64 : PHP library for embedding in applications

php-enchant.x86_64 : Human Language and Character Encoding Support

php-gd.x86_64 : A module for PHP applications for using the gd graphics library

php-imap.x86_64 : A module for PHP applications that use IMAP

To see more details about what each module does, type the following command into terminal, replacing the name of the module with whatever library you want to learn about.

yum info name of the module

Once you decide to install the module, type:

sudo yum install name of the module

You can install multiple libraries at once by separating the name of each module with a space.

Congratulations! You now have LAMP stack on your droplet!

We should also set the processes to run automatically when the server boots (php will run automatically once Apache starts):

sudo chkconfig httpd on

sudo chkconfig mysqld on

Step Four—RESULTS: See PHP on your Server

Although LAMP is installed on your virtual server, we can still take a look and see the components online by creating a quick php info page

To set this up, first create a new file:

sudo nano /var/www/html/info.php

Add in the following line:

<?php

phpinfo();

?>

Then Save and Exit.

Restart apache so that all of the changes take effect on your virtual server:

sudo service httpd restart

Finish up by visiting your php info page (make sure you replace the example ip address with your correct one): http://12.34.56.789/info.php

 

It should look similar to this.

php

How to Install Linux, Apache, MySQL, PHP (LAMP) stack On CentOS 6

How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 16.04

 

In this guide, we’ll get a LAMP stack installed on an Ubuntu 16.04.

What is LAMP

A “LAMP” stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps.

This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database, and dynamic content is processed by PHP.

 

Step 1: Install Apache and Allow in Firewall

The Apache web server is among the most popular web servers in the world. It’s well-documented, and has been in wide use for much of the history of the web, which makes it a great default choice for hosting a website.

We can install Apache easily using Ubuntu’s package manager, apt. A package manager allows us to install most software pain-free from a repository maintained by Ubuntu.

For our purposes, we can get started by typing these commands:

  • sudo apt-get update
  • sudo apt-get install apache2

 

Since we are using a sudo command, these operations get executed with root privileges. It will ask you for your regular user’s password to verify your intentions.

Once you’ve entered your password, apt will tell you which packages it plans to install and how much extra disk space they’ll take up. Press Y and hit Enter to continue, and the installation will proceed.

Set Global ServerName to Suppress Syntax Warnings

Next, we will add a single line to the /etc/apache2/apache2.conf file to suppress a warning message. While harmless, if you do not set ServerName globally, you will receive the following warning when checking your Apache configuration for syntax errors:

  • sudo apache2ctl configtest

 

Output

AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message

Syntax OK

Open up the main configuration file with your text edit:

  • sudo nano /etc/apache2/apache2.conf

 

Inside, at the bottom of the file, add a ServerName directive, pointing to your primary domain name. If you do not have a domain name associated with your server, you can use your server’s public IP address:

. . .

ServerName server_domain_or_IP

Save and close the file when you are finished.

Next, check for syntax errors by typing:

  • sudo apache2ctl configtest

Since we added the global ServerName directive, all you should see is:

Output

Syntax OK

Restart Apache to implement your changes:

  • sudo systemctl restart apache2

 

You can now begin adjusting the firewall.

Adjust the Firewall to Allow Web Traffic

Next, assuming that you have followed the initial server setup instructions to enable the UFW firewall, make sure that your firewall allows HTTP and HTTPS traffic. You can make sure that UFW has an application profile for Apache like so:

  • sudo ufw app list

 

Output

Available applications:

Apache

Apache Full

Apache Secure

OpenSSH

If you look at the Apache Full profile, it should show that it enables traffic to ports 80 and 443:

  • sudo ufw app info “Apache Full”

 

Output

Profile: Apache Full

Title: Web Server (HTTP,HTTPS)

Description: Apache v2 is the next generation of the omnipresent Apache web

server.

 

Ports:

80,443/tcp

Allow incoming traffic for this profile:

  • sudo ufw allow in “Apache Full”

 

You can do a spot check right away to verify that everything went as planned by visiting your server’s public IP address in your web browser (

How To Find your Server’s Public IP Address

If you do not know what your server’s public IP address is, there are a number of ways you can find it. Usually, this is the address you use to connect to your server through SSH.

From the command line, you can find this a few ways. First, you can use the iproute2 tools to get your address by typing this:

·         ip addr show eth0 | grep inet | awk ‘{ print $2; }’ | sed ‘s/\/.*$//’

This will give you two or three lines back. They are all correct addresses, but your computer may only be able to use one of them, so feel free to try each one.

An alternative method is to use the curl utility to contact an outside party to tell you how it sees your server. You can do this by asking a specific server what your IP address is:

·         sudo apt-get install curl·         curl http://icanhazip.com

Regardless of the method you use to get your IP address, you can type it into your web browser’s address bar to get to your server.

Step 2: Install MySQL

Now that we have our web server up and running, it is time to install MySQL. MySQL is a database management system. Basically, it will organize and provide access to databases where our site can store information.

Again, we can use apt to acquire and install our software. This time, we’ll also install some other “helper” packages that will assist us in getting our components to communicate with each other:

·         sudo apt-get install mysql-server

Note: In this case, you do not have to run sudo apt-get update prior to the command. This is because we recently ran it in the commands above to install Apache. The package index on our computer should already be up-to-date.

Again, you will be shown a list of the packages that will be installed, along with the amount of disk space they’ll take up. Enter Y to continue.

During the installation, your server will ask you to select and confirm a password for the MySQL “root” user. This is an administrative account in MySQL that has increased privileges. Think of it as being similar to the root account for the server itself (the one you are configuring now is a MySQL-specific account, however). Make sure this is a strong, unique password, and do not leave it blank.

When the installation is complete, we want to run a simple security script that will remove some dangerous defaults and lock down access to our database system a little bit. Start the interactive script by running:

·         mysql_secure_installation

You will be asked to enter the password you set for the MySQL root account. Next, you will be asked if you want to configure the VALIDATE PASSWORD PLUGIN.

Warning: Enabling this feature is something of a judgment call. If enabled, passwords which don’t match the specified criteria will be rejected by MySQL with an error.

This will cause issues if you use a weak password in conjunction with software which automatically configures MySQL user credentials, such as the Ubuntu packages for phpMyAdmin. It is safe to leave validation disabled, but you should always use strong, unique passwords for database credentials.

Answer y for yes, or anything else to continue without enabling.

VALIDATE PASSWORD PLUGIN can be used to test passwords

and improve security. It checks the strength of password

and allows the users to set only those passwords which are

secure enough. Would you like to setup VALIDATE PASSWORD plugin?

 

Press y|Y for Yes, any other key for No:

You’ll be asked to select a level of password validation. Keep in mind that if you enter 2, for the strongest level, you will receive errors when attempting to set any password which does not contain numbers, upper and lowercase letters, and special characters, or which is based on common dictionary words.

There are three levels of password validation policy:

 

LOW    Length >= 8

MEDIUM Length >= 8, numeric, mixed case, and special characters

STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

 

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1

If you enabled password validation, you’ll be shown a password strength for the existing root password, and asked you if you want to change that password. If you are happy with your current password, enter n for “no” at the prompt:

 

Using existing password for root.

 

Estimated strength of the password: 100

Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

For the rest of the questions, you should press Y and hit the Enter key at each prompt. This will remove some anonymous users and the test database, disable remote root logins, and load these new rules so that MySQL immediately respects the changes we have made.

At this point, your database system is now set up and we can move on.

Step 3: Install PHP

PHP is the component of our setup that will process code to display dynamic content. It can run scripts, connect to our MySQL databases to get information, and hand the processed content over to our web server to display.

We can once again leverage the apt system to install our components. We’re going to include some helper packages as well, so that PHP code can run under the Apache server and talk to our MySQL database:

  • sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql

 

This should install PHP without any problems. We’ll test this in a moment.

In most cases, we’ll want to modify the way that Apache serves files when a directory is requested.

Currently, if a user requests a directory from the server, Apache will first look for a file called index.html. We want to tell our web server to prefer PHP files, so we’ll make Apache look for an index.php file first.

To do this, type this command to open the dir.conf file in a text editor with root privileges:

  • sudo nano /etc/apache2/mods-enabled/dir.conf

 

It will look like this:

/etc/apache2/mods-enabled/dir.conf

<IfModule mod_dir.c>

DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm

</IfModule>

We want to move the PHP index file highlighted above to the first position after the DirectoryIndex specification, like this:

/etc/apache2/mods-enabled/dir.conf

<IfModule mod_dir.c>

DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm

</IfModule>

When you are finished, save and close the file by pressing Ctrl-X. You’ll have to confirm the save by typing Y and then hit Enter to confirm the file save location.

After this, we need to restart the Apache web server in order for our changes to be recognized. You can do this by typing this:

  • sudo systemctl restart apache2

 

We can also check on the status of the apache2 service using systemctl:

  • sudo systemctl status apache2

 

Sample Output

  • apache2.service – LSB: Apache2 web server

Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)

Drop-In: /lib/systemd/system/apache2.service.d

└─apache2-systemd.conf

Active: active (running) since Wed 2016-04-13 14:28:43 EDT; 45s ago

Docs: man:systemd-sysv-generator(8)

Process: 13581 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)

Process: 13605 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)

Tasks: 6 (limit: 512)

CGroup: /system.slice/apache2.service

├─13623 /usr/sbin/apache2 -k start

├─13626 /usr/sbin/apache2 -k start

├─13627 /usr/sbin/apache2 -k start

├─13628 /usr/sbin/apache2 -k start

├─13629 /usr/sbin/apache2 -k start

└─13630 /usr/sbin/apache2 -k start

 

Apr 13 14:28:42 ubuntu-16-lamp systemd[1]: Stopped LSB: Apache2 web server.

Apr 13 14:28:42 ubuntu-16-lamp systemd[1]: Starting LSB: Apache2 web server…

Apr 13 14:28:42 ubuntu-16-lamp apache2[13605]:  * Starting Apache httpd web server apache2

Apr 13 14:28:42 ubuntu-16-lamp apache2[13605]: AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerNam

Apr 13 14:28:43 ubuntu-16-lamp apache2[13605]:  *

Apr 13 14:28:43 ubuntu-16-lamp systemd[1]: Started LSB: Apache2 web server.

Install PHP Modules

To enhance the functionality of PHP, we can optionally install some additional modules.

To see the available options for PHP modules and libraries, you can pipe the results of apt-cache search into less, a pager which lets you scroll through the output of other commands:

  • apt-cache search php- | less

 

Use the arrow keys to scroll up and down, and q to quit.

The results are all optional components that you can install. It will give you a short description for each:

libnet-libidn-perl – Perl bindings for GNU Libidn

php-all-dev – package depending on all supported PHP development packages

php-cgi – server-side, HTML-embedded scripting language (CGI binary) (default)

php-cli – command-line interpreter for the PHP scripting language (default)

php-common – Common files for PHP packages

php-curl – CURL module for PHP [default]

php-dev – Files for PHP module development (default)

php-gd – GD module for PHP [default]

php-gmp – GMP module for PHP [default]

:

To get more information about what each module does, you can either search the internet, or you can look at the long description of the package by typing:

  • apt-cache show package_name

 

There will be a lot of output, with one field called Description-en which will have a longer explanation of the functionality that the module provides.

For example, to find out what the php-cli module does, we could type this:

  • apt-cache show php-cli

 

Along with a large amount of other information, you’ll find something that looks like this:

Output

Description-en: command-line interpreter for the PHP scripting language (default)

This package provides the /usr/bin/php command interpreter, useful for

testing PHP scripts from a shell or performing general shell scripting tasks.

.

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used

open source general-purpose scripting language that is especially suited

for web development and can be embedded into HTML.

.

This package is a dependency package, which depends on Debian’s default

PHP version (currently 7.0).

If, after researching, you decide you would like to install a package, you can do so by using the apt-get install command like we have been doing for our other software.

If we decided that php-cli is something that we need, we could type:

  • sudo apt-get install php-cli

 

If you want to install more than one module, you can do that by listing each one, separated by a space, following the apt-get install command, like this:

  • sudo apt-get install package1 package2 …

 

At this point, your LAMP stack is installed and configured. We should still test out our PHP though.

Step 4: Test PHP Processing on your Web Server

In order to test that our system is configured properly for PHP, we can create a very basic PHP script.

We will call this script info.php. In order for Apache to find the file and serve it correctly, it must be saved to a very specific directory, which is called the “web root”.

In Ubuntu 16.04, this directory is located at /var/www/html/. We can create the file at that location by typing:

  • sudo nano /var/www/html/info.php

 

This will open a blank file. We want to put the following text, which is valid PHP code, inside the file:

info.php

<?php

phpinfo();

?>

When you are finished, save and close the file.

Now we can test whether our web server can correctly display content generated by a PHP script. To try this out, we just have to visit this page in our web browser. You’ll need your server’s public IP address again.

The address you want to visit will be:

http://your_server_IP_address/info.php

The page that you come to should look something like this:

This page basically gives you information about your server from the perspective of PHP. It is useful for debugging and to ensure that your settings are being applied correctly.

If this was successful, then your PHP is working as expected.

You probably want to remove this file after this test because it could actually give information about your server to unauthorized users. To do this, you can type this:

  • sudo rm /var/www/html/info.php
How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 16.04

WordPress hosting

WordPress Hosting

WordPress is the most hot blogging software powering millions websites. WordPress is quite easy to create a website or blog because of the visual and easy-to-use interface. There are over thousands free WordPress themes and plugins that the webmasters can use to easily customize their websites.

Why you choose us for your WordPress hosting

  1. Auto Install – WordPress is well known for its easy installation. If you’re not experienced in the technical skill, you may be still in trouble on uploading WordPress files, WordPress configuration, MySQL configuration, themes and plugin configuration. 4hostings hosts offer application cPanel or Plesk control panel that it can automatically setup WordPress for you within minutes. And with the help of auto installer, the further upgrade is automatic also.
  2. Affordability – the main consideration for most of bloggers whoever intends to have a private or business weblog based on our survey. So the cost effective is another main ranking factor. The cost effective WordPress hosting means that you can pay less money but having a reliable shared. 4hostings host with a strong technical support team background.
  3. WordPress Experience – for which reason is WordPress experience imperative? If the web host you exercise possesses no former information of WordPress, they may not have the capacity to help you scheme the road round it. But from 4hostings, you can enjoy an enhanced experience with our recommendations.
  4. Fast Response – this is a must-have feature. When you confront with an handing matter, the responsive technical support helps you save the downtime and traffic. 4hostings provide 24×7 technical support via telephone, live chat, email.

 

WordPress Hosting Compatibility

Written in PHP and backed by MySQL database, WordPress normally requires a PHP version of 4.3 or even greater, MYSQL version 4.1.2 or even greater, and the mod rewrite Apache module. Almost web hosting plans can meet such an environment. However, if you want your site to run more securely and smoothly, it’s better to choose a WordPress hosting with the most up-to-date stable releases of PHP, MySQL, and Apache.

Most of the web hosts meet these requirements. But it is advisable to look at other factors which are relatively helpful with regards to WordPress hosting, such as the Operating System, PHP memory_limit, suPHP, etc.

  • Although the PHP, MYSQL and Apache run in a very smooth manner in the Windows. It is wiser to use Linux since it is undoubtedly the best.
  • PHP memory_limited is suggested to be set over 64 MB, ensuring that a wide variety of purposes.
  • PHP should run as suPHP to crease security.
  • The Apache mod_rewrite 2 modules should be installed to support URL customization and for better SEO.
Best WordPress Hosting Enhanced Features of 4hostings

wordpress hosting

There are plenty of features in common among thousands of WordPress hosting. But these are rarely offered enhanced features – extremely friendly to a WordPress site owner.

  1. Daily (or weekly) backup – If your database or site is destroyed, the backup helps you quickly restore the site from the damage.
  2. 24/7 server monitoring. If the web host monitors your server 24/7  for the entire attacks or problems. You can be assured for the site security and performance.
  3. SFTP (SSH file transfer protocol) & SSH (secure shell) – utilize a web hosting plan that you could need to encrypt a mainframe.

4hostings provides you best hosting for your WordPress developed site.

WordPress hosting

Open Source Mail Servers Solutions for Linux and UNIX servers

Most mail servers made of Mail delivery agent (MDA) and Mail Transfer Agents (MTA).  MDA software used to routes e-mail to its destination. MTA software used to transfers e-mail between servers or computers. Apart from these, you need to install and use Antispam, Antivirus, Webmail and other software too. You need to make sure your IP address stay clean. Apart from mail server software configuration, you need to install some database to store user names, email IDs, password and other information. Setting up and maintaining a full-fledged email server is a complicated task.

However, you can skip many of configuration problems and setup complete email solution for privacy and security reasons. So, I am going to list important features of software that can turn any Linux, FreeBSD, OpenBSD or Unix-powered into mail server out of a box with the following goals:

  • The software must be open source
  • The software must run on Linux or Unix-like server
  • It must deploy quickly
  • The software setup must be easy for new sysadmin
  •  Software must support multiple users and multiple domain names
  • Must promote privacy and decentralization

You can take back control of your email with this easy-to-deploy our 4hostings service

4hostings lets you become your own mail service provider in a few easy steps. It’s sort of like making your own gmail, but one you control from top to bottom. Technically, 4hostings turns a fresh cloud computer into a working mail server. But you don’t need to be a technology expert to set it up. It implements modern mail protocols (SPF, DKIM, and DMARC) and the latest security best practices, including opportunistic TLS, strong ciphers, and HSTS. When enabled, DNSSEC (with DANE TLSA) provides a higher level of protection against active attacks. Exchange ActiveSync is also available as a beta feature.

4hostings systems feature

  1. Spam filtering
  2. TLS/SSL
  3. Manage your calendars (CalDAV), address books (CardDAV), tasks on a easy to use web UI or your mobile devices (iOS, Android, BlackBerry 10, Windows Phone)
  4. SpamAssassin, ClamAV, SPF, DKIM, greylisting, whitelisting, blacklisting. Quarantining detected spam into SQL database for further review
  5. Stores mail accounts in your favourte backend: OpenLDAP, MySQL, MariaDB, PostgreSQL
  6. Web mail
  7. Web admin panel

We are very happy to see you’re globally interested by this  4hostings system. Do not hesitate to give your feedback.

Open Source Mail Servers Solutions for Linux and UNIX servers

Website speed test

The speed of a website can be a critical factor to its success. Faster loading websites can benefit from higher SEO rankings, higher conversion rates, lower bounce rates, longer visitor duration on site, better overall user experience, and engagement.

For website speed test it is important part to understand a few idea behind how these tools work so that you can better analyze the data and then optimize your site accordingly. It is not only for test the speed of your web, but also you can measure your performance

Here are just a few of common ways to increase website speed

Time to First Byte (TTFB)

Time to first byte (TTFB) is the measurement of the responsiveness of a web server. Essentially it is the time it takes your browser to start receiving information after it has requested it from the server. By using a speed tool you can dramatically minimize the force of the load on your origin server, it helps to decrease your TTFB.

Render-Blocking Javascript & CSS

Blocking refers to Javascript and CSS that are keeping your page from loading as quickly as it could.

Javascript

Google consult removing JavaScript that interferes with loading the above the fold content of your webpages.

You will then also want to optimize your CSS delivery to keep it from causing delays on page load. Here are a few ways to fix this:

  1. Properly call your CSS files
  2. Reduce the amount of CSS files
  3. Use less CSS overall

CSS is a render blocking resource, get it down to the client as soon and as quickly as possible to optimize the time to first render!

Reduce of Resources

Reduce of resources means removing unnecessary characters from your HTML, Javascript, and CSS that are not required to load, such as:

  • White space characters
  • New line characters
  • Comments
  • Block delimiters

This speeds up your load times as it reduces the amount of code that has to be requested from the server.  To remove all the unnecessary characters, you can use a tool. Or if you are running WordPress you can use a plugin which will minify all of your HTML, Javascript, and CSS for you.

HTTP Requests

When your browser brings data from a server it does so using HTTP (Hypertext Transfer Protocol). It is a request/response between a client and a host. In usual the more HTTP requests your web page makes the slower it will load.

There are many ways that can reduce the number of requests such as:

  • Combining your CSS and Javascript files
  • Inline your Javascript (only if it is very small)
  • Using CSS Sprites
  • Reducing assets such as 3rd party plugins that make a large number of external requests

Here presents some website speed test tools, which helps you to test your site’s speed

Pingdom tool

Pingdom

Pingdom offers cost-effective and reliable uptime and performance monitoring for your websites.They use more than 70 global polling locations to test and verify our customers’ sites 24/7, all year long. With Pingdom you can monitor your website’s uptime, performance, and interactions for a better end-user-experience.

SPEEDTEST

SPEEDTEST

Speedtest by Ookla is the definitive way to measure your internet performance. With billions of active uses to date, Speedtest is the dominant global leader in internet performance testing and metrics.

KeyCDN tool 

KeyCDN

KeyCDN is a powerful and easy to use Content Delivery Network (CDN) made to satisfy your needs!Speed up your games, software delivery, advertisements, CMS, websites and many more.

Monitis Website Speed Test

Monitis Website Speed Test

Everyone knows how annoying slow loading websites can be. In fact, web pages take longer than 20 seconds to load,lose 50% of users. Fast and optimized pages guarantee better conversions, higher sales and number of visitors.

Yellow Lab tools

Yellow

 PageScoring 

PageScoring

Website Speed Test is an online web tool by PageScoring.com to provide webmasters with valuable information about the loading speed of their domain and website. This tool will check everything from your domain resolving speed to your download times.

WebPagetest is an open source project that is primarily being developed and supported by Google as part of  efforts to make the web faster.

These tools help you to measure your website speed

Order-Now-4Hosting

Website speed test