Displaying items by tag: how to

set_up_your_own_web_server.png 

 

The great thing about hosting is that similar to setting up your own site, you can make it as simple as you would like or you can get really complex, the reality is whichever method you choose is up to you. This is not a project for the faint of heart – indeed, you should be techy and much into the intricacy of hosting your own site. Someone who is interested in setting up their own server is a person with time to dedicate to this task and looks forward to the fulfillment of completing something that can be arduous even for the most tech-savvy.

Before getting into how to do your own hosting, you need to be aware of a few issues. Hosting your site requires a lot of electricity and you could deal with power outages, plus you are responsible for the efficacy and maintenance of hardware and software. Self-hosting has slower speeds than paid, dedicated hosts as well. However, the challenge of setting up your own hosting is invigorating, and a great next step on your tech journey.

Before you get started on hosting your own sites, it is a wise move to consider the benefits of paid hosting. The first thing you should know about paid hosting is generally things move faster on a paid host; these servers are dedicated to getting everything going and they don’t have the upload limitations that your ISP imposes upon you. That said, the other benefit a paid host has over self-hosting is that a paid host is responsible for the software and hardware. If anything goes wrong, you have to fix it instead of relying on the paid server company to perform maintenance. While sometimes it is easier to get any web hosting by simply paying with PayPal, the reality is hosting your own site is something for techy people that is really fun and as you improve in this endeavor, you develop skills that are quite marketable.

You can do web hosting with Windows and with Linux. Here is how with both systems.


 

 


Windows

 

Windows is not a popular way to host. The people who like Windows for hosting are those using ASP.NET or C# to code. If using these systems, Windows is the best option, despite being less popular than Linux.

 

Step 1: Get WAMP

One of the best installation programs is WampServer. This helps you work in Windows, Apache, PHP, and MySQL. Get the massive package when you download this, as the individual packages can be onerous and less accurate than the ones coming with WampServer. Once you get your WAMP, you can create subdirectories within it. Clicking on the Local Host link will take you to a URL that says, http://localhost in your main screen of WampServer.

 

Step 2: Simple Page Creation and Configuration of MySQL

As with anything, you want to test what you are doing. The next step is creating a new file with sample code. This could be something simple as a test using PHP. You can check in on this by going to the info section. However, if you click on phpMyAdmin, you can get going on configuring the MySQL information. This means the screen will open for admin credentials, but if you type in Admin to the log in name, rarely do you need a password. Once you get there, you can set and reconfigure your MySQL databases, and some CMS’s like WordPress do it for you.

 

Step 3: Make Your Site Public
Apache by default doesn’t want to make your site public, so you need to go in Apache and turn on the public settings. This will allow not just you to view your site, but the public as well.

 

Step 4: Domain Names
Setting up your DNS is not the easiest. What you do here is associate your IP address with a particular domain name. This will allow any DNS to pick out your domain name and download your site to get the information they need.


 


Linux

 

This is the most popular system used for web hosting. Learning about Linux will give you plenty of advantages while using a platform most folks are comfortable with.

 

Step 1: Use LAMP Software on the Terminal

The first thing you do with your terminal is to write a line of code to start your LAMP software installation. These tutorials will help you get started:

 

Step 2: Check if your PHP is Working

The way to test your PHP is to place a test file in the webserver root directory. Once there, you can visit the page by going to http://localhost/info.php. At this point, you’ll get a lot of information including the current version of PHP, configuration, and the installed modules. The good news is you can use Ubuntu to get the newest PHP modules. You can also use a simple command-line technique to get the same information as well.

 

Step 3: Get MySQL Under Control

Testing the MySQL for your site is imperative. This is especially important when you are using a CMS like Drupal, Joomla, or WordPress. Once there, you have to look at the server issue. Unfortunately, like the other servers, these one needs you to guide them. Most of the time, the system itself takes care of these MySQL databases. That said, you may have to enter some manually.

 

Step 4: DNS Configuration

Use the A record to get the IP address for your server using the dig tool. Once you do this, the next step is to associate your domain name with an IP address. The DNS step is vitally important because getting your domain associated with the IP means people won’t have to type in random numbers to see your site. Use Apache to set up the domain name, the index file, and any other files and set up permissions as well, and that gets your hosting done for you. You can use Namecheap to buy a domain name, read this review to help you decide.

This is just a short intro to self-hosting. You should do more research on security, setting up and maintaining servers, and a lot more. Though it’s a fun thing to do, it still requires a lot of skills and knowledge.

 

Published in Technology
Saturday, 30 May 2020 17:35

How to : Install PHP 7.2 to 7.4 on Ubuntu

php_ubuntu_server.png 

Finally, the third part of our LAMP tutorial series: how to install PHP on Ubuntu. In this tutorial, we’ll show you how to install various versions of PHP, including PHP 7.2, PHP 7.3, and the latest PHP 7.4

This tutorial should work for any Ubuntu release and other Ubuntu-based releases. Ubuntu 14.04, Ubuntu 16.04, Ubuntu 18.04, even Ubuntu 19.10.

 

Tutorials here:

  • Before we begin
  • How to install PHP 7.4 on Ubuntu 18.04 or 16.04
  • How to Install PHP 7.2 on Ubuntu 16.04
  • How to Install PHP 7.2 on Ubuntu 18.04
  • How to Install PHP 7.3 on Ubuntu 18.04 or 16.04
  • How to change the PHP version you’re using
  • How to upgrade to PHP 7.3 (or 7.4) on Ubuntu
  • Speed up PHP by using an opcode cache

 

 

For the first part of our LAMP series, go to our Ubuntu: How to install Apache

And for the second part, go to How to Install MySQL/MariaDB on Ubuntu

 

 

Before we begin installing PHP on Ubuntu

 

  • PHP has different versions and releases you can use. Starting from the oldest that is currently supported – PHP 7.2, and onto PHP 7.3 and the latest – PHP 7.4. We’ll include instructions for PHP 7.4, PHP 7.2 (the default in Ubuntu 18.04) and the default PHP version in the Ubuntu 16.04 repositories – PHP 7. We recommend that you install PHP 7.3 as it’s stable and has lots of improvements and new features. If you still use PHP 7.1, you definitely need to upgrade ASAP because its security support ended at 2019.
  • You’ll obviously need an Ubuntu server. You can get one from Vultr. Their servers start at $2.5 per month. Or you can go with any other cloud server provider where you have root access to the server.
  • You’ll also need root access to your server. Either use the root user or a user with sudo access. We’ll use the root user in our tutorial so there’s no need to execute each command with ‘sudo’, but if you’re not using the root user, you’ll need to do that.
  • You’ll need SSH enabled if you use Ubuntu or an SSH client like MobaXterm if you use Windows.
  • Check if PHP is already installed on your server. You can use the ‘which php’ command. If it gives you a result, it’s installed, if it doesn’t, PHP is not installed. You can also use the “php -v” command. If one version is installed, you can still upgrade to another.
  • Some shared hosts have already implemented PHP 7.3 and PHP 7.4 in their shared servers, like Hawk Host and SiteGround.

Now, onto our tutorial.

 

How to install PHP 7 on Ubuntu 16.04

Currently, as of January 2018, the default PHP release in the Ubuntu 16.04 repositories is PHP 7.0. We’ll show you how to install it using Ubuntu’s repository.

You should use PHP 7.2 or 7.3 instead of the default, outdated PHP version in Ubuntu 16.04. Skip these instructions and follow the instructions below for a newer version.

 

Update Ubuntu

First, before you do anything else, you should update your Ubuntu server:

apt-get update && apt-get upgrade

 

Install PHP

Next, to install PHP, just run the following command:

apt-get install php

This command will install PHP 7.0, as well as some other dependencies:

php-common
php7.0
php7.0-cli
php7.0-common
php7.0-fpm
php7.0-json
php7.0-opcache
php7.0-readline

To verify if PHP is installed, run the following command:

php -v

You should get a response similar to this:

php-v-ubuntu.jpg

 

And that’s it. PHP is installed on your Ubuntu server.

 

 

Install PHP 7.0 modules

You may need some additional packages and PHP modules in order for PHP to work with your applications. You can install the most commonly needed modules with:

apt-get install php-pear php7.0-dev php7.0-zip php7.0-curl php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-xml libapache2-mod-php7.0

 

Depending on how and what you’re going to use, you may need additional PHP modules and packages. To check all the PHP modules available in Ubuntu, run:

apt-cache search --names-only ^php
You can tweak the command to only show ^php7.0- packages etc.

 

If you want to use the latest PHP version, follow the next instructions instead.

 

How to Install PHP 7.2 on Ubuntu 16.04
PHP 7.2 is a stable version of PHP and has many new features, improvements, and bug fixes. You should definitely use it if you want a better, faster website/application.

 

Update Ubuntu
Of course, as always, first update Ubuntu:

apt-get update && apt-get upgrade

 

Add the PHP repository
You can use a third-party repository to install the latest version of PHP. We’ll use the repository by Ondřej Surý.

 

First, make sure you have the following package installed so you can add repositories:

apt-get install software-properties-common

 

Next, add the PHP repository from Ondřej:

add-apt-repository ppa:ondrej/php

And finally, update your package list:

apt-get update


 


Install PHP 7.2

After you’ve added the repository, you can install PHP 7.2 with the following command:

apt-get install php7.2

 

This command will install additional packages:

libapache2-mod-php7.2
libargon2-0
libsodium23
libssl1.1
php7.2-cli
php7.2-common
php7.2-json
php7.2-opcache
php7.2-readline

And that’s it.

 

To check if PHP 7.2 is installed on your server, run the following command:

php -v

 

Install PHP 7.2 modules
You may need additional packages and modules depending on your applications. The most commonly used modules can be installed with the following command:

apt-get install php-pear php7.2-curl php7.2-dev php7.2-gd php7.2-mbstring php7.2-zip php7.2-mysql php7.2-xml

And that’s all. You can now start using PHP on your Ubuntu server.

 

If you want to further tweak and configure your PHP, read our instructions below.

 

How to Install PHP 7.2 on Ubuntu 18.04
PHP 7.2 is included by default in Ubuntu’s repositories since version 18.04. So the instructions are pretty similar to PHP 7 for 16.04.

 

Update Ubuntu
Again, before doing anything, you should update your server:

apt-get update && apt-get upgrade
Install PHP 7.2

 

Next, to install PHP 7.2 on Ubuntu 18.04, just run the following command:

apt-get install php

This command will install PHP 7.2, as well as some other dependencies.

 

To verify if PHP is installed, run the following command:

php -v
You should get a response similar to this:

PHP 7.2.3-1ubuntu1 (cli) (built: Mar 14 2018 22:03:58) ( NTS )
And that’s it. PHP 7.2 is installed on your Ubuntu 18.04 server.

 

Install PHP 7.2 modules
These are the most common PHP 7.2 modules often used by php applications. You may need more or less, so check the requirements of the software you’re planning to use:

apt-get install php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php

To check all the PHP modules available in Ubuntu, run:

apt-cache search --names-only ^php

 

How to install PHP 7.3 on Ubuntu 18.04 or 16.04
PHP 7.3 is a stable version that you can safely use on your servers.

Update Ubuntu

First, update your Ubuntu server:

Add the PHP repository
To install PHP 7.3 you’ll need to use a third-party repository. We’ll use the repository by Ondřej Surý that we previously used.

First, make sure you have the following package installed so you can add repositories:

apt-get install software-properties-common
Next, add the PHP repository from Ondřej:

add-apt-repository ppa:ondrej/php
And finally, update your package list:

apt-get update
Install PHP 7.3

After you’ve added the repository, you can install PHP 7.3 with the following command:

apt-get install php7.3

 

This command will install additional packages:

libapache2-mod-php7.3
libaprutil1-dbd-sqlite3
php7.3-cli
php7.3-common
php7.3-json
php7.3-opcache
php7.3-readline
…and others.
And that’s it. 

 

To check if PHP 7.3 is installed on your server Run the following command:

php -v

 

Install PHP 7.3 modules
You may need additional packages and modules depending on your applications. The most commonly used modules can be installed with the following command:

apt-get install php-pear php7.3-curl php7.3-dev php7.3-gd php7.3-mbstring php7.3-zip php7.3-mysql php7.3-xml
And that’s all. You can now start using PHP on your Ubuntu server.

If you want to further tweak and configure your PHP, read our instructions below.

 

 

How to install PHP 7.4 on Ubuntu 18.04 or 16.04

PHP 7.4 is the latest version of PHP that has lots of improvements. The instructions are pretty similar to PHP 7.3.

Update Ubuntu

First, update your Ubuntu server:

apt-get update && apt-get upgrade
Add the PHP repository

To install PHP 7.4 you’ll need to use a third-party repository. We’ll use the repository by Ondřej Surý that we previously used again.

 

First, make sure you have the following package installed so you can add repositories:

apt-get install software-properties-common
Next, add the PHP repository from Ondřej:

add-apt-repository ppa:ondrej/php

And finally, update your package list:

apt-get update
Install PHP 7.4

 

After you’ve added the repository, you can install PHP 7.4 with the following command:

apt-get install php7.4

This command will install additional packages:

libapache2-mod-php7.4
libaprutil1-dbd-sqlite3
php7.4-cli
php7.4-common
php7.4-json
php7.4-opcache
php7.4-readline
…and others.

And that’s it. To check if PHP 7.4 is installed on your server, run the following command:

php -v
Install PHP 7.4 modules

 

You may need additional packages and modules depending on your applications. The most commonly used modules can be installed with the following command:

apt-get install php-pear php7.4-curl php7.4-dev php7.4-gd php7.4-mbstring php7.4-zip php7.4-mysql php7.4-xml

And that’s all. You can now start using PHP on your Ubuntu server.

If you want to further tweak and configure your PHP, read our instructions below.

 

How to change the PHP version you’re using
If you have multiple PHP versions installed on your Ubuntu server, you can change what version is the default one.

To set PHP 7.2 as the default, run:

update-alternatives --set php /usr/bin/php7.2

 

To set PHP 7.3 as the default, run:

update-alternatives --set php /usr/bin/php7.3

 

To set PHP 7.4 as the default, run:

update-alternatives --set php /usr/bin/php7.4

 

If you’re following our LAMP tutorials and you’re using Apache, you can configure Apache to use PHP 7.3 with the following command:

a2enmod php7.3

And then restart Apache for the changes to take effect:

systemctl restart apache2

 

How to upgrade to PHP 7.3 or 7.4 on Ubuntu

If you’re already using an older version of PHP with some of your applications, you can upgrade by:

  • Backup everything.
  • Install the newest PHP and required modules.
  • Change the default version you’re using.
  • (Optionally) Remove the older PHP (Required) Configure your software to use the new PHP version. You’ll most likely need to configure Nginx/Apache, and many other services/applications. If you’re not sure what you need to do, contact professionals and let them do it for you.
  • Speed up PHP by using an opcode cache
  • You can improve the performance of your PHP by using a caching method. We’ll use APCu, but there are other alternatives available.

 

If you have the ‘php-pear’ module installed (we included it in our instructions above), you can install APCu with the following command:

pecl install apcu

There are also other ways you can install APCu, including using a package.

 

To start using APCu, you should run the following command for PHP 7.2:

echo "extension=apcu.so" | tee -a /etc/php/7.2/mods-available/cache.ini

Or this command for PHP 7.3:

echo "extension=apcu.so" | tee -a /etc/php/7.3/mods-available/cache.ini

 

And the following command for PHP 7.4:

echo "extension=apcu.so" | tee -a /etc/php/7.4/mods-available/cache.ini
If you’re following our LAMP tutorials and you’re using Apache, create a symlink for the file you’ve just created.

For PHP 7.2:

ln -s /etc/php/7.2/mods-available/cache.ini /etc/php/7.2/apache2/conf.d/30-cache.ini

 

For PHP 7.3:

ln -s /etc/php/7.3/mods-available/cache.ini /etc/php/7.3/apache2/conf.d/30-cache.ini

 

For PHP 7.4:

ln -s /etc/php/7.4/mods-available/cache.ini /etc/php/7.4/apache2/conf.d/30-cache.ini

 

And finally, reload Apache for the changes to take effect:

systemctl restart apache2

To further configure APCu and how it works, you can add some additional lines to the cache.ini file you previously created. The best configuration depends on what kind of server you’re using, what applications you are using etc. Either google it and find a configuration that works for you, or contact professionals and let them do it for you.

That’s it for our basic setup. Of course, there are much more options and configurations you can do, but we’ll leave them for another tutorial.

 

Published in GNU/Linux Rules!
Saturday, 30 May 2020 15:55

Ubuntu: How to install Apache

ubuntu-head-apache2.png 

These instructions should work on any Ubuntu-based distro, including Ubuntu 16.04, Ubuntu 18.04, and even non-LTS Ubuntu releases like 19.10.20.04+were tested and written for Ubuntu 18.04.

Apache (aka httpd) is the most popular and most widely used web server, so this should be useful for everyone.

 

Before we begin installing Apache
Some requirements and notes before we begin:

 

 

  • Apache may already be installed on your server, so check if it is first. You can do so with the “apachectl -V” command that outputs the Apache version you’re using and some other information.
  • You’ll need an Ubuntu server. You can buy one from Vultr, they’re one of the best and cheapest cloud hosting providers. Their servers start from $2.5 per month.
  • You’ll need the root user or a user with sudo access. All commands below are executed by the root user so we didn’t have to append ‘sudo’ to each command.
  • You’ll need SSH enabled if you use Ubuntu or an SSH client like MobaXterm if you use Windows.

That’s most of it. Let’s move onto the installation.

 

Install Apache on Ubuntu

The first thing you always need to do is update Ubuntu before you do anything else. You can do so by running:

apt-get update && apt-get upgrade
Next, to install Apache, run the following command:

apt-get install apache2
If you want to, you can also install the Apache documentation and some Apache utilities. You’ll need the Apache utilities for some of the modules we’ll install later.

apt-get install apache2-doc apache2-utils
And that’s it. You’ve successfully installed Apache.

You’ll still need to configure it.

 

Configure and Optimize Apache on Ubuntu
There are various configs you can do on Apache, but the main and most common ones are explained below.

 

Check if Apache is running
By default, Apache is configured to start automatically on boot, so you don’t have to enable it. You can check if it’s running and other relevant information with the following command:

systemctl status apache2

 apache-running.jpg

 

And you can check what version you’re using with

apachectl -V

A simpler way of checking this is by visiting your server’s IP address. If you get the default Apache page, then everything’s working fine.

 

Update your firewall

If you use a firewall (which you should), you’ll probably need to update your firewall rules and allow access to the default ports. The most common firewall used on Ubuntu is UFW, so the instructions below are for UFW.

To allow traffic through both the 80 (http) and 443 (https) ports, run the following command:

ufw allow 'Apache Full'

Install common Apache modules

Some modules are frequently recommended and you should install them. We’ll include instructions for the most common ones:

 

Speed up your website with the PageSpeed module
The PageSpeed module will optimize and speed up your Apache server automatically.

First, go to the PageSpeed download page and choose the file you need. We’re using a 64-bit Ubuntu server and we’ll install the latest stable version. Download it using wget:

wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb

Then, install it with the following commands:

dpkg -i mod-pagespeed-stable_current_amd64.deb
apt-get -f install

Restart Apache for the changes to take effect:

systemctl restart apache2

Enable rewrites/redirects using the mod_rewrite module
This module is used for rewrites (redirects), as the name suggests. You’ll need it if you use WordPress or any other CMS for that matter. To install it, just run:

a2enmod rewrite
And restart Apache again. You may need some extra configurations depending on what CMS you’re using, if any. Google it for specific instructions for your setup.

Secure your Apache with the ModSecurity module
ModSecurity is a module used for security, again, as the name suggests. It basically acts as a firewall, and it monitors your traffic. To install it, run the following command:

apt-get install libapache2-modsecurity

And restart Apache again:

systemctl restart apache2

ModSecurity comes with a default setup that’s enough by itself, but if you want to extend it, you can use the OWASP rule set.

 

Block DDoS attacks using the mod_evasive module
You can use the mod_evasive module to block and prevent DDoS attacks on your server, though it’s debatable how useful it is in preventing attacks. To install it, use the following command:

apt-get install libapache2-mod-evasive

By default, mod_evasive is disabled, to enable it, edit the following file:

nano /etc/apache2/mods-enabled/evasive.conf
And uncomment all the lines (remove #) and configure it per your requirements. You can leave everything as-is if you don’t know what to edit.

 mod_evasive.jpg

And create a log file:

mkdir /var/log/mod_evasive
chown -R www-data:www-data /var/log/mod_evasive

 

That’s it. Now restart Apache for the changes to take effect:

systemctl restart apache2
There are additional modules you can install and configure, but it’s all up to you and the software you’re using. They’re usually not required. Even the 4 modules we included are not required. If a module is required for a specific application, then they’ll probably note that.

 

Optimize Apache with the Apache2Buddy script
Apache2Buddy is a script that will automatically fine-tune your Apache configuration. The only thing you need to do is run the following command and the script does the rest automatically:

 curl -sL https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl | perl

  

You may need to install curl if you don’t have it already installed. Use the following command to install curl:

apt-get install curl

Additional configurations
There’s some extra stuff you can do with Apache, but we’ll leave them for another tutorial. Stuff like enabling http/2 support, turning off (or on) KeepAlive, tuning your Apache even more. You don’t have to do any of this, but you can find tutorials online and do it if you can’t wait for our tutorials.

 

Create your first website with Apache
Now that we’re done with all the tuning, let’s move onto creating an actual website. Follow our instructions to create a simple HTML page and a virtual host that’s going to run on Apache.

The first thing you need to do is create a new directory for your website. Run the following command to do so:

mkdir -p /var/www/example.com/public_html
Of course, replace example.com with your desired domain. You can get a cheap domain name from Namecheap.

Don’t forget to replace example.com in all of the commands below.

 

Next, create a simple, static web page. Create the HTML file:

nano /var/www/example.com/public_html/index.html

And paste this:



Simple Page


If you're seeing this in your browser then everything works.




Save and close the file.

 

Configure the permissions of the directory:

chown -R www-data:www-data /var/www/example.com
chmod -R og-r /var/www/example.com

 

Create a new virtual host for your site:

nano /etc/apache2/sites-available/example.com.conf

 

And paste the following:


ServerAdmin This email address is being protected from spambots. You need JavaScript enabled to view it.
ServerName example.com
ServerAlias www.example.com

DocumentRoot /var/www/example.com/public_html

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

This is a basic virtual host. You may need a more advanced .conf file depending on your setup.

Save and close the file after updating everything accordingly.

 

Now, enable the virtual host with the following command:

a2ensite example.com.conf

And finally, restart Apache for the changes to take effect:

systemctl restart apache2

That’s it. You’re done. Now you can visit example.com and view your page.

 

Published in GNU/Linux Rules!
Tagged under
Wednesday, 26 February 2020 17:52

How to: Install jekins on your linux

Guys, Before talking about how to install jenkins on linux, shall we discuss a little bit about actually what is jenkins ? It is a automation tool which has written in java language. It is an open source application. Jenkins helps for automation tasks and mostly used by system administrators, cloud engineers, DevOps engineers and developers.

 

 

As an example if we take running Ansible playbooks on the ansible master node itself, we can use jenkins tool for running ansible playbooks. Since jenkins is a web tool, system

administrators/DevOps can easily use it taking the advantage of it’s different types plugins for specific purposes. Jenkins is also very useful for Continuos Integration and Continous delivery

(CI/CD ). Thanks to  jenkins, developers can build and test their software projects by doing the changes continously and can take the project to the production level without any distruption to the

users because of the pre testing stages running in continous delivery.

 

So we are going to see different ways of how to install jenkins on Linux.

 

1) Install Jenkins using yum command

commands :
sudo yum update -y
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo yum install jenkins -y
sudo systemctl start jenkins
sudo systemctl enable jenkins
Note : Since Jenkins is a java application, first of all you must have installed java on your centos.

 jekins1.png

 

 command – sudo yum install java-1.8.0-openjdk-devel

 

 jenkins2.png

 

 We can check if the port for jenkins has opened. Remember that jenkins is using port 8080 as it’s default port. But we can change it if we need. 

 

jenkins3.png 

To access your Jenkins after the Installation, Open your web browser and got to your centos local ip

with port 8080 ( or localhost:8080 ) or if you are running a virtual machine your public ip with port 8080

could be accessed. I am here using the public ip attached to my virtual machine to get the jenkins web

interface. 

 

jenkins4.png

 

As shown in the browser you need to access that /var/lib path and get the Initial Admin password.

Then Install suggested plugins and login as admin ( if needed you can create another account ).

here we go, finally we have installed jenkins.

 

jenkins5.png 

 

 

2) Install Jenkins on a tomcat

What is tomcat ? Actually tomcat is a application server from apache foundation which executes java

servlets and renders the webpages which is having java coding. Since Jenkins is a tool build with

java, we are trying to install jenkins on tomcat.

 

commands :

sudo yum update -y
sudo yum install java-1.8.0-openjdk-devel
cd ~
wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.0.M10/bin/apache-tomcat-9.0.0.M10.tar.gz
tar xzfv apache-tomcat-9.0.0.M10.tar.gz
mkdir Tomcat9
mv apache-tomcat-9.0.0.M10 Tomcat9
cd Tomcat9/bin
./startup.sh

Now  we have installed tomcat on one of our directories in home folder and started tomcat server. You

can check of the port 8080 has opened.

sudo netstat -plunt |grep 8080

Now open the browser with your localhost:8080 or if you are running a virtual machine then your vm

local machine ip with port 8080 or your public ip with port 8080.

 

 jenkins6.png

 

 Ok, now tomcat is ready to searve for java applications. Let’s get our jenkins into tomcat.

Download the jenkins war file from this link. Jenkins war releases. I use version 2.214 ( latest war file ).

commands :

cd ~/Tomcat9/webapps

wget http://updates.jenkins-ci.org/download/war/2.214/jenkins.war

 

jenkins7.png 

Now we will get back to the browser.

try now the url as your tomcat url/jenkins, like localhost:8080/jenkins

 

jenkins8.png 

 See now you are running your jenkins on tomcat. You can check the java process on the server. ps -ef|grep java

 

jenkins9.png 

 If you want to shutdown or restart the jenkins, you can do it by shutting down the tomcat node. Simply

do as below

cd ~/Tomcat9/bin


./shutdown.sh – this will shutdown the tomcat, so jenkins will also be shutdown


./startup.sh = this will start your tomcat and jenkins will be back online

 

 jenkins10.png

 

4) Install Jenkins on a docker container

commands :

First we need to install docker engine in our centos, So follow the below

sudo yum update -y


sudo yum install -y yum-utils device-mapper-persistent-data lvm2 -y

sudo yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo

sudo yum -y install docker-ce

sudo systemctl start docker && sudo systemctl enable docker

now switch to root user – sudo su

 

To verify docker, use command docker ps and docker version to check the docker version.

 

jenkins11.png 

 Guys now we have installed docker on our centos. Now we will pull our jenkins image to our centos.

 

jenkins12.png

 

jenkins13.png

 

docker images

jenkins14.png

 

 Now i am creating a docker container from jenkins image as below

jenkins15.png

 

You can see that i have exposed the container to be accesible from the localhost ip from host port

8080. Open the browser and try to access the jenkins container with port 8080.

 

jenkins16.webp

 

So guys we discussed how to install jenkins on centos in three different ways. Hope more articles

related to jenkins on future.

 

Linuxfinal

Published in GNU/Linux Rules!
Tagged under