Running Web Server – PHP – MySQL Easily in Your VPS

It is very easy, here is the command for El-based.

Or if you are using Debian-based

Real easy, isn’t it? You are ready to get your site up and running. Or if you want to read a little bit more detail about the installation and there is maybe tips and trick, you can continue reading this article.

1. Preliminary
2. Installing Apache
3. Installing MySQL
4. Installing PHP

People buying VPS are from various circles, some of them are newbies, and some of them are experts. For some reasons, newbies (like the author) in any purposes just don’t want to know about the complexity of configuring and installing webserver to make their website up and running. Websites in the present commonly utilize PHP for the script / programming and MySQL for database. And for the home of both softwares, they use Apache because of its htaccess compatibility required by many scripts. So what we need is Apache – PHP – MySQL, or some other called it LAMP (Linux Apache MySQL PHP) stack.

Installing Apache
First time using VPS, after installing with Linux OS (mostly CentOS, Debian, Ubuntu) we can check whether Apache has been installed or not.

or for Debian based

If there is Apache running then continue with MySQL installation, otherwise install it first. Whether it is El or Debian based, update your repository and/or packages first before using it.

or

Now install and start Apache web server.

or

Open your box’s IP address in browser to make sure your Apache has been running, cool isn’t it? Now before we continue installing MySQL, i want to tell another way to check whether Apache’s already installed or not in your vps, this kind of easy but funny way. We now that Apache’s default html directory is “/var/www“, right? Then just check whether the directory exist or not, that’s the way. 😀

Installing MySQL
Two steps installing and securing MySQL, here they are

or

Here’s what MySQL Secure Installation looks like

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we’ll need the current
password for the root user. If you’ve just installed MySQL, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:

Password updated successfully!
Reloading privilege tables..
… Success!

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!

MySQL installation ends with securing it. In some rare case, mysql_secure_installation script doesn’t work, so you need to manually do secure it, let’s describe it one by one.

First question will be your MySQL root password, have you set it? If you haven’t then set it with mysqladmin command

MySQL root password set, now login to your MySQL using root user and password you set before

Next, what is asked by the script?

  • Remove anonymous user
  • Disallow root login remotely
  • Remove test database
  • Reload privilege

The command in sequence plus additional securing command will be

Finished, but i have a little note, when i wanted to install MySQL in my 256 box Debian, i got this error.

FATAL -> Failed to fork.

Your VPS memory exhausted buddy, stop one of memory consuming service like Apache for a while and then try again install MySQL.

Installing PHP
Yes now we will install PHP into the VPS.

or

After that, create phpinfo file inside your “/var/www” or “/var/www/html” directory and try to access it with your ip address.

That’s it, upload your website to “/var/www” or “/var/www/html” directory, create database, rock ‘n roll!

You want to use your domain? Will write the tuts later, stay tune at this blog for update.

Leave a Reply