Jim's
Tutorials

Fall 2019
course
site

Read Chapter 1 of Unix book.

Finished configuring the final part of the LAMP stack with PHP.

sudo mkdir /var/log/php

sudo chown www-data /var/log/php

Which made a log directory for PHP and gave ownership to the Apache system user.

Spent far too long trying to install phpmyadmin only to realize that apache2 being highlighted wasn't enough, I had to hit space to further select it.

Took a bit more time to get the configuration file to populate in the proper spot. Kept checking with ls /etc/apache2/conf-enabled/ until I got it.

Followed this guide: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-18-04

Ran sudo phpenmod mbstring so phpmyadmin could be read. By default no one has permissions so...:

Ran SELECT user,authentication_string,plugin,host FROM mysql.user; Checked table to see why root couldn't login, noticed it was due to being set on auth_socket.

To give root privileges I ran ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

However I decided to use my own user for this, noms, and so I created that user in the database by running:

CREATE USER 'noms'@'localhost' IDENTIFIED BY 'password'; where password was an actual password.

Gave the user privileges over the database with GRANT ALL PRIVILEGES ON . TO 'noms'@'localhost' WITH GRANT OPTION;

Tested login at http://45.79.134.85/phpmyadmin/ and it worked.

Secured phpmyadmin because it's a security hazard by doing:

Edited AllowOverride All to phpmyadmin using: sudo nano /etc/apache2/conf-available/phpmyadmin.conf

<Directory /usr/share/phpmyadmin>
    Options FollowSymLinks
    DirectoryIndex index.php
    AllowOverride All

Restarted Apache to enable htaccess.

Created a file using: sudo nano /usr/share/phpmyadmin/.htaccess

Filled out the file with

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user

AuthType Basic: This line specifies the authentication type that you are implementing. This type will implement password authentication using a password file.

AuthName: This sets the message for the authentication dialog box. You should keep this generic so that unauthorized users won’t gain any information about what is being protected.

AuthUserFile: This sets the location of the password file that will be used for authentication. This should be outside of the directories that are being served. We will create this file shortly.

Require valid-user: This specifies that only authenticated users should be given access to this resource. This is what actually stops unauthorized users from entering.

sudo htpasswd -c /etc/phpmyadmin/.htpasswd noms

Then gave that user a password.

Now there's an additional layer of authentication to phpmyadmin.

Started on a to-do list web application. Will have add, remove, proper updating numbering and will utilize the database.

Created a database named todo. Populated that with a table called tasks with 2 columns. One column named id with a length of 11 and auto-increment on, the other named task type varchar with a length of 255.

Started on the HTML and CSS. I have a page with the button. Still more to do.

Spent far too long troubleshooting why my php wouldn't show up online.. only to find a lone missing semicolon.

Got a bit roadblocked. I thought my code was wrong but I believe there's a problem with mysql as I can't seem to submit anything that will get stored in the database. I have page that will be working once that's fixed, though.

Further troubleshooting: I decided to check to see if the database actually existed. It does, it was created through phpmyadmin.

mysql> show databases; populates todo.

I can then mysql> use todo to open the database, and then mysql> show tables; shows the table 'tasks'. Not quite sure what's going on.

-----------------Miscellaneous other things that took up a good bit of time. Some of this is mostly notes for me for later.-----------------------------

Did a good bit of research and talking to some friends to ask what they're using and would recommend learning. A few things that came up that I'd be interested in looking into would be:

Django (potentially Flask as well)

PostgreSQL (from what I've heard it's more secure than MySQL and may be more current to learn).

Go (programming language). Also Docker.

In general what I found is that it would be good to get a bit of hands on experience with some of this newer software. In particular Django and PostgreSQL together. Learning Python should help with learning Django as well.

I also learned about https://www.heroku.com/ where I can supposedly run up to 5 small servers for free. I'll likely take advantage of that for testing other things in the future along with the Linode server.

I think Django and PostgreSQL would be good to learn together. I have an idea for a Django project that would use PostgreSQL but it would take time to learn. The project idea being a library. There would be fields for name of book, type of book, author, that sort. You could have the option to read, update, create, or destroy books. It would use a database (PostgreSQL) to store the information in a persistent way.

Learned a bit more about Django such as:

model = structure which allows for storage, representation and reference of an instance that desired structure

view = provides the returned values and gateway for an endpoint

serializer = gatekeeper for incoming requests. For posts you can designate the requited values to be passed in order for a 200(get/updating)/201(creating)/204(when deleting). Using something like Django Rest Framework (RDF) can add in basic validators and also allows for easily added custom validator.

For when I get a heroku server for the project:

Run commands:

heroku run python manage.py shell_plus -a

heroku git:remote -a

git remote rename Heroku

git push :master -f

As an aside, -f is force.

*(will have access to shell+ which will pull in all of your models when starting the shell. Ease of use kind of thing. Won’t have to import book object every time you use it).

You could get Django rest library. Helps with views and serializers out of the box. I found some info at https://www.django-rest-framework.org/api-guide/serializers/

It all feels a bit far beyond my current skill level but having a concrete goal like that to work toward usually helps me mentally.

Also talked with my buddy about needing to be forthright when going into an interview as far as programming is concerned. Don't be cocky about code. Be inquisitive about your code and how it could be improved. Be able to provided reasoning for why you code certain ways so it shows you put some technical thought into it. I also know that my code should adapt to company standards for ease of use by others. Also, as you say, having code that's readable is very important as far as naming conventions go.

https://cs.marlboro.college /cours /fall2019 /jims_tutorials /arome /sep26
last modified Thu November 21 2024 5:07 pm