Linux Part 2
Installing MySQL
Server
1.) We will now install the MySQL
server so that we can use it to store our data. So type in the command line
sudo apt-get -y install mysql-server
2.) When a screen prompts open from the terminal that looks like the below picture, you can use any password as your default root user. But for me, it’s going to be root
.
Too Much Update
1.) Sorry, but I must tell you that we are going to update your system again. Don’t you like that?
OPTIONAL CHMOD
1.) I don’t know what I was doing here so you can follow along if you want. I believe I chmod once more because new files that are created don’t get the same exact permissions as their current parent. They receive permissions based on their parent parent directory. Since /var/www/html
isn’t the “parent parent”, the permission the new file will most likely receive will be from /var/
which we SHOULD NEVER touch. I’ve done stupid mistakes and changing permission on /var/
was one of them so don’t chmod
on /var/
if you don’t know what you are doing.
Creating Our Projects
1.) So for now, we’re just going to be doing something simple. We’re just going to output the PHP
info to make sure that PHP
is running correctly. So you can now right click and open the file without needing the terminal since we gave the directory read-write-execute
permissions. So in your index.php
file, type in
<?php
info();
And then save it and close it out.
2.) Restart Apache
again to make sure that it works. Well, technically, it should be working without the need to restart Apache
, but let’s just do it in case something wrong happens. So let’s type in the command line
sudo systemctl restart apache2
3.) Browse back to your favorite web browser and refresh the page that you were on. It should of been at localhost.com
. Once it has been refreshed, you should now see the PHP
info or something similar to the picture below.
4.) Open up a new tab and type in sample.localhost.com
to see if sample.localhost.com
shows the old Apache
file. If it does like the picture below, then it works. You have a working main domain and a working sub-domain. When a sub-domain doesn’t work, it will normally show the main domain contents (localhost.com
in this case). This can either mean that you don’t have permission to that directory or the configurations are wrong. You might want to double check if that happens.
Installing PHPMyAdmin
1.) Open up a new tab and type in phpmyadmin.net
. It will lead you to PHPMyAdmin
’s official website.
2.) On the right hand side of your screen, you should be able to see 3 green buttons. It should read
Download x.x.x.x
Try Demo
Donate
Download x.x.x.x
will vary depending on which version PHPMyAdmin
is on. Currently as of this tutorial, it is on 4.6.5.2
. So click on Download x.x.x.x
.
3.) We’re just going to right-click on the downloaded file and we’re going to open it from where it was downloaded to. For this tutorial, it’s going to be located in ~/Downloads
or in your Downloads
folder for your current logged in account on your local machine.
4.) Next, extract the folder. You can either extract the folder to a new folder or you can choose “Extract Here” from the context menu.
5.) Browse into the extracted folder and look for the file named config.sample.inc.php
and rename it to config.inc.php
. We’ll need to modify this file in order to have PHPMyAdmin
working.
6.) Right-click on config.inc.php
and open it with gedit
. You don’t need the terminal for this one because you have permissions within your own Downloads
folder.
7.) Switch back to your favorite web browser and open up a new tab. This time, go to google.com
and then search for the term phpmyadmin blowfish secret generator
. The link should be the first one as shown on both pictures below.
8.) Click on the link. It should lead you to the website question-defense.com
as shown in the pictures below. Scroll down until you see Copy The Output Below To Use For Your phpMyAdmin $cfg['blowfish_secret']:
9.) Copy the 44-character sequence and browse back to your gedit
and then paste it inside of $cfg['blowfish_secret']
in your config.inc.php
file.
10.) Scroll down to where you can see the lines that read // $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
and uncomment from there until the end of // $cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';
and then save the file and close out.
Don’t NEED To Do This Step
1.) For some reason, I keep restarting Apache
and updating the system, but you don’t have to if you don’t want to. I am simply just doing my thing. But if you want to follow a long, you can if you want.
Installing PHPMyAdmin
… Continued
11.) Open up the terminal if you don’t have it already opened and type in the command line
ls -l
We are basically listing all the contents within the current directory we are in. You shouldn’t be in the Downloads
directory because we’re using the terminal. You should be in your Home
directory in the terminal. On the file explorer however, you are in the Downloads
directory. That much is clear.
12.) So having our terminal open, we should change the directory to the Downloads
directory. So in the command line type in
cd Downloads
This however only works if you are within the Home
directory of your current account on your local machine. If you are NOT in the Home
directory of your current account on your local machine on the terminal, you can type in cd ~/Downloads
to change directly into the Downloads
folder from where ever you may be.
13.) We will now do another ls -l
to list out what contents are in the Downloads
directory.
14.) Using what we know from the above step (step 13), we know that our PHPMyAdmin
folder is within this directory. So it is safe to say that we can now move the PHPMyAdmin
directory to /usr/share
. But we cannot move it manually because just like /var/
, we don’t have permissions to /usr/
nor /usr/share/
so we’ll have to do this via the terminal with root permission. So in the command line type in
sudo mv phpMyAdmin /usr/share/
15.) Browse back to your favorite web browser again and open up another new tab. This time, type in the address bar phpmyadmin.localhost.com
. It should work and look similar to the picture below.
16.) Log into your MySQL
account. The default root username should always be root
while the password is what you typed in earlier when we installed the MySQL
server.
17.) Upon successfully logging into your root account on PHPMyAdmin
, you should see something similar to the first picture below. However, it isn’t over yet. You still need to correct some errors if you want PHPMyAdmin
to work.
18.) So again, open up another new tab and go to google.com
again. This time, search for the keyword phpmyadmin examples/create_tables.sql
.
19.) It should always be the first result, but if you can’t find it. It’s on github.com.
20.) Next, click on the Raw
button in the middle of the screen which should redirect you to the raw version of the file. Once you are there, highlight all and copy it.
21.) Browse back to phpmyadmin.localhost.com
on your other tabs and click on the SQL
tab in the top middle of the screen or you can go to any SQL
tab on any tables.
22.) Paste the raw create_tables.sql
that you copied from github.com
into the SQL
text area. Like the below pictures. And click on the Go
button at the bottom right hand screen.
23.) Once you have successfully created the right tables that you need for PHPMyAdmin
not to complain about, you can browse back to the PHPMyAdmin
home page on phpmyadmin.localhost.com
to see if you need anything else.
MISTAKES CAN HAPPEN, I DON’T KNOW WHAT I WAS DOING
So, I am kind of embarrassed to show you guys this part of the tutorial, but I’ll have to show you guys any how since we’re not yet finished with the tutorial. To finish off a good section, we must check to make sure that everything is working correctly. So I went off-screen and created a test
database with a users
table. I then gave it a few columns and I inserted data into it. I then tried to connect to my database using mysqli_*
. Next, for some reason, it wouldn’t work. I didn’t look at the errors correctly so I thought I had installed PHP
incorrectly because I installed PHP
before I installed the MySQL
server. But this was not the case. I later then found out I mis-spelled mysql
and actually had it as myql
.