Category Archives: linux

How To Setup Amazon Linux On AWS

The Amazon Linux AMI is a supported and maintained Linux image provided by Amazon Web Services for use on Amazon Elastic Compute Cloud (Amazon EC2). It is designed to provide a stable, secure, and high performance execution environment for applications running on Amazon EC2.

Step 1

Log into your AWS account.

Step 2

Click services and then EC2

Step 3

Click launch Instance

Step 4

Select Amazon Linux 2 AMI

Step 5

Select micro

Step 6

Leave the default values in instance details and click next.

Step 7

If required add more storage and click next add tags

Step 8

Click add tag, type Name in the Key field and then type a server name in the Value feed. Click Next Configure Security group

Step 9

Select my IP for source in the next screen

Step 10

Click review and launch and then launch.

A full Video can be seen here:

 

 

 

 

How to install apache (httpd) on CentOS 8

This tutorial will show you how to install the Apache web server on CentOS 8.

You will need to log into your CentOS 8 server and run the following commands:

  • sudo yum install httpd
    • When prompted press y to confirm the installation.
  • sudo service httpd start
    • This starts the apache service
  • sudo service httpd status
    • This insures that the service is running, your output should look similar to the output below.

  • sudo chkconfig httpd on
    • This insures that the apache service is powered on when the server boots.
  • Next create a file called index.html in the apache root directory by running the following command
    • sudo vi /var/www/html/index.html
  • Press i to go into insert mode and add the following text
    • <html> this is my web serer </html>
  • press esc and then type wq! to quit and save the file.
  • You can now navigate to your servers ip address or dns name, you should now see a screen similar to the one below.

 

A full video can be seen here:

How to check MariaDB version

“MariaDB is a community-developed fork of the MySQL relational database management system intended to remain free under the GNU GPL. Development is led by some of the original developers of MySQL, who forked it due to concerns over its acquisition by Oracle Corporation”

This short MariaDB tutorial will show you how to check the version of MariaDB you are running. We are running MariaDB on CentOS 7 but the process should be much the same for other operating systems.

Step 1 

Log into your MariaDB instance, in our case we log in using the command:

mysql -u root -p

Step 2

After you log in you can see your version in the welcome text – highlighted in the screen-grab below:

Step 3

If you cannot see your version here you can also run the following command to see it:

SELECT VERSION();

A full video tutorial on the process can be found here:

 

 

How to Setup CentOS 7 on AWS

This tutorial will show you how to create a CentOS 7 instance on AWS. We assume that you already have you AWS account created and that you are logged in already.

Step 1

Click Services and then EC2

Step 2

Click Launch Instance

Step 3

  • Click AWS Marketplace
  • Search for CentOS
  • Select the top result – CentOS7

Step 4

Click Continue

Step 5

Select your machine type and click Next Configure Instance details. In our case we will select the t2.micro instance as it is free tier eligible.

Step 6

Change Auto-assign public IP to Enable and click Next: Add storage.

Step 7

Leave the defaults and click Next:Add Tags

Step 8

Click Next: Configure Security Group

Step 9

Click review and Launch.

Step 10

Review your settings and then click Launch.

Step 11

In the drop down menu select create a new key pair, give the key pair a name and Download the Key Pair, then click launch Instances.

Step 12

Click your instance ID to see the instance.

You should now see your instance.

Step 13

To connect to our instance we will need to convert the key we downloaded, to do so we will use putty and puttygen they can be downloaded form here: https://www.putty.org/

Open puttygen and click Load

Step 14

Navigate to where you downloaded your key, click all files, click on your key and click open.

Step 15

Now click Save Private key, when prompted click yes you want to save without a passphrase.

Step 16

Now open putty and enter your public IP into the host name or IP address field, then expand SSH on the left had side.

Step 17

Click auth and then browse, navigate to where you saved your key and select it.

Step 18

Now click open

Step 19

Click Yes

Step 20

Enter centos as the username and click enter.

You will now be logged in

A full video tutorial can be found here:

How to change the hostname in CentOS 7

First edit the hostname file by typing:

sudo vi /etc/hostname

Delete the line that you see in the file so it our case we deleted:

localhost.localdomain

Now  enter your hostname, in our case we called it darrens centos.

 

We then typed

esc wq!

to write and save the file.

 

We then restart the machine by typing

sudo init 6

When the machine has re-booted type in

hostname

to see the new hostname.

A video tutorial can be found here:

How to run a command on Startup on Linux (works on CentOS & Ubuntu)

Hi there,

In this example I had a need to record boot up times in a file that i could access easily. To do so I decided to run a command on startup. This tutorial tool place on CentOS but the commands should also work on Ubuntu.

Step 1

Edit the rc.local file in vi by running:

sudo vi /etc/rc.local

Step 2

Add the following line to the file, update the home directory to represent your home directory.

  • Press i to go into insert mode
  • Enter the line:
    • echo “the computer booted up at” `date` >> /home/darren/bootup.log
  • Press ESC and then wq! and enter to save and quit the file.

Step 3

Give the executable  permission to the rc.local file by running the following command:

chmod +x /etc/rc.d/rc.local

Step 4

Reboot the system by running:

sudo init 6

Step 5

When the machine reboots run the following command to insure the file has been created and that there is content in the file:

cat /home/darren/bootup.log

A full video tutorial can be found here:

How to disable root ssh logins on CentOS 7

If you have a server that’s available over a network it’s generally a good idea to disable root access over ssh.

The reason for this, is that, scripts run attempting to access  your server and these scripts use the root username to try and log in. A simple way to protect yourself is to simply disable root access via SSH.

We will first create a standard user account that we’ll use to administer our system.

Run the command:

useradd darren

Next we’ll set a password for the user

passwd darren

Now let’s give the account admin permissions:

visudo

Add the following line to the file:

darren = ALL=(ALL) ALL

Now lets stop root from accessing the server via ssh:

vi /etc/ssh/sshd_config

Edit the line:

PermitRootLogin yes

To make it read:

PermitRootLogin no

 

Now restart SSH:

service sshd restart.

Next make sure your you can ssh into the account you created:

ssh darren@192.168.123.67

Run a command with sudo to insure you have sudo access

sudo ls

Once you have confirmed you can exit the server knowing that root access is now disabled for the server.

 

 

 

 

 

 

How to install Fedora 27 on VMWare Workstation 12

Hi there,

This tutorial will show you how to install Fedroa 27 in VMware Workstation 12. Fedora is an excellent operating system that is open source and free. It runs great on older hardware so is a great option for older laptops. With that said let’s get stuck into the tutorial.

  • When the ISO file has downloaded, open VMWare Work station, click File and then new Virtual machine.
  • In the next screen leave the configuration as typical and select next.
  • Now click browse and navigate to where you downloaded the .iso file, once it is added in click next.

  • Give your machine a name or leave as the default and click next.
  • Up the hardrive to 40GB and click next
  • Click customise hardware.
  • Increase the memory to 2GB of RAM and add an extra processor and click close.

  • Finally click finish.
  • When the machine boots up select “Test this media & start Fedora-Workstation-Live 27”
  • Select install to Hard drive.
  • Select your language and click continue.
  • Click installation destination.
  • Click on the desk and click Done.

  • Click Begin installation.
  • Set a root password.
  • Create a new user and make the user and administrator by clicking the relevant checkbox.

  • Click quit when the install is done.
  • Then restart the machine.

You should then have Fedora installed. A full video tutorial can be found below and if you have any trouble following along with this tutorial please do comment below 🙂

How to Install WordPress on Nginx on CentOS 7

Hi there,

This tutorial will show you how to install WordPress using Nginx on CentOS 7. You will need the following commands to follow along with this tutorial.

First we’ll need to install additional repos that include php71 and then install php71. The commands to do so are:

  • sudo wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
  • sudo rpm -Uvh remi-release-7.rpm
  • sudo yum install yum-utils -y
  • sudo yum-config-manager –enable remi-php71
  • sudo yum –enablerepo=remi,remi-php71 install php-fpm php-common
  • sudo yum yum –enablerepo=remi,remi-php71 install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongodb php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

 

Next we will download WordPress, place it in the directory that we want and then correct the permissions for that folder.

  • sudo wget https://wordpress.org/latest.tar.gz
  • sudo mv latest.tar.gz /usr/share/nginx/htm
  • cd /usr/share/nginx/htm
  • sudo tar -zxvf latest.tar.gz
  • sudo chown -R nginx:nginx /usr/share/nginx/html/wordpress
  • sudo chmod -R 755 /usr/share/nginx/html/wordpress
  • sudo setenforce 0

Now lets set up a config file for our wordpress site. Run the command below and then copy and paste the text into your file, insuring that you enter your IP address into the file.

  • sudo vi /etc/nginx/conf.d/default.conf
server {
 listen 80;
 server_name YOURIPADDRESS;
 
 # note that these lines are originally from the "location /" block
 root /usr/share/nginx/html/wordpress;
 index index.php index.html index.htm;
 
 location / {
 try_files $uri $uri/ =404;
 }
 error_page 404 /404.html;
 error_page 500 502 503 504 /50x.html;
 location = /50x.html {
 root /usr/share/nginx/html;
 }
 
 location ~ \.php$ {
 try_files $uri =404;
 fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;
 }
}

Next make some final changes to your php configuration. Run the command:

  • sudo vi /etc/php-fpm.d/www.conf

Make the following changes to this file.

  • user = apache to user = nginx
  • group = apache to group = nginx
  • listen.owner = nobody to listen.owner = nginx
  • listen.group = nobody to listen.group = nginx
  • Finally append under  this line listen = 127.0.0.1:9000
    • listen = /var/run/php-fpm/php-fpm.sock

Now restart all relevant services and ensure that they are all configured to start when the server boots.

  • sudo service php-fpm restart
  • sudo service nginx restart
  • sudo chkconfig php-fpm on
  • sudo chkconfig nginx on

Now lets do the DB settings needed.

  • mysql -u root -p
  • CREATE DATABASE wordpress;
  • GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY ‘password123’;
  • FLUSH PRIVILEGES

How to Install Nginx Web Server on CentOS 7

NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. It is a rival to the Apache web server and used extensively throughout the internet.

This tutorial will show you how to install Nginx on CentOS 7.

So to begin we’ll need to ensure that we have epel repository installed. We can do so by running the command:

  • sudo yum install epel-release

Next we can install Nginx using yum. The command to do so is:

  • sudo yum install nginx.

Next we’ll start the Nginx web server and insure it starts when the server is powered on. The two commands to do this are:

  • sudo service nginx start
  • sudo chkconfig nginx on

Now we need to navigate to our localhost. To do so open a browser window and type in localhost. You should see a screen similar to the one below:

Now that we know that Nginx is working as we expect, lets remove the default Index.html and enter our own. First delete the default index.html by running:

  • sudo rm /usr/share/nginx/html/index.html

Now create your own file using vi:

  • sudo vi /usr/share/nginx/html/index.html

Enter some test text into your file and save it. Now refresh your browser window. You should see the changes replicated. When we refreshed ours it looked like the image below:

 

A full video tutorial on how to install Nginx can be found here: