Jenkins installation on ubuntu OS

Use following command for jenkins installtion

  • sudo apt update
  • sudo apt install openjdk-8-jdk
  • apt install openjdk-8-jdk -y
  • wget -q -O – https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add –
  • sudo sh -c ‘echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list’
  • apt-get update
  • -sudo apt-get install jenkins -y
  • systemctl status jenkins
  • sudo ufw allow 8080
  • give sudo permisssion to jenkins user < /br> vi /etc/sudoers and add below entry jenkins ALL=(ALL) NOPASSWD: ALL and save the file

If you are getting this error

https://pkg.jenkins.io/debian-stable binary/ Release Certificate verification failed:

Then run following command

sudo su

apt update

apt-get install jenkins -y

Solved Error executing DDL “alter table events drop foreign key

While running spring boot application I got following error

2021-10-22 13:38:59.732  WARN 700 --- [ restartedMain] o.h.t.s.i.ExceptionHandlerLoggedImpl  : GenerationTarget encountered exception accepting command : Error executing DDL "alter table users_roles add constraint FKt4v0rrweyk393bdgt107vdx0x foreign key (role_id) references role (id)" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table users_roles add constraint FKt4v0rrweyk393bdgt107vdx0x foreign key (role_id) references role (id)" via JDBC Statement

Changed spring.jpa.hibernate.ddl-auto = create-drop to update. And changed table name user to users and role to roles.

Then problem has been solved

Spring and Gradle – adding to the project WebJars Bootstrap

If you wanted to add bootstrap UI CSS and JS files in thymeleaf then you can use following code:

<link th:href="@{/webjars/bootstrap/5.0.0/css/bootstrap.min.css}"
rel="stylesheet" media="screen" />
<script th:src="@{/webjars/bootstrap/5.0.0/js/bootstrap.min.js}"></script>

If those styles are still not loading then refresh project and if you are using spring security then you need to add following code in your extended class of

WebSecurityConfigurerAdapter
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/home","/webjars/**", "/resources/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}

It will solve your issue

auto renew letsencrypt ssl apache on linux

For auto renew SSL certificate I added following code in crontab.

0 0 */10 * * certbot renew >> /logs/certbot-cron.log 2>&1

Log of certbot renew command.

[root@vps147238 ep]# certbot renew

Saving debug log to /var/log/letsencrypt/letsencrypt.log Processing /etc/letsencrypt/renewal/purabtech.com.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cert not yet due for renewal - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The following certificates are not due for renewal yet: /etc/letsencrypt/live/purabtech.com/fullchain.pem expires on 2022-01-17 (skipped) (skipped) No renewals were attempted.

how to get free ssl certificate from letsencrypt

For getting a free SSL certificate you need SSH access to your server where you installed your application code.

Then follow commands and articles which will guide you to install the necessary application.

https://certbot.eff.org/lets-encrypt/centosrhel7-apache

After installing certbot to your machine. you need to run following command to generate SSL certificate.

certbot --apache certonly --cert-name purabtech.com -d purabtech.in

Open 443 and 80 port on linux VM

If your apache or Nginx or tomcat server is configured properly still your site is not opening then check firewall and port is opened on the internet.

Check the status of your firewall. use this command

firewall-cmd --state

running

Check which zones are active

[root@vps147238 purab]# firewall-cmd –get-active-zones
public
interfaces: eth0

Open port 80 and port 443 port.

firewall-cmd –zone=public --add-service=http

firewall-cmd --zone=public --add-service=https

firewall-cmd --zone=public --permanent --add-service=http

firewall-cmd --zone=public --permanent --add-service=https

firewall-cmd --reload

Now check port 80 and 443 opened

firewall-cmd --list-all

public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: dhcpv6-client ssh https
ports: 80/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:

Solved: letsencrypt certbot KeyError: ‘Directory field not found’

While running certbot command I got following error:

[root@vps147238 letsencrypt]# certbot --apache certonly --cert-name purabtech.com -d purabtech.in
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): purab@test.in
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
An unexpected error occurred:
KeyError: 'Directory field not found'
Please see the logfiles in /var/log/letsencrypt for more details.

I am using centos 7.

Solution for this is run following command:

yum install python-certbot-apache -t stretch-backports

It solved my issue.

[root@vps147238 letsencrypt]# certbot --apache certonly --cert-name purabtech.com -d purabtech.in
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
Requesting a certificate for purabtech.in
Performing the following challenges:
http-01 challenge for purabtech.in
Waiting for verification…
Cleaning up challenges

CentOS Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org An unexpected error occurred:

While running certonly command I got following error:
[root@vps147238 letsencrypt]# certbot --apache certonly --cert-name purabtech.com -d purabtech.in
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org
An unexpected error occurred:
ConnectionError: (‘Connection aborted.’, gaierror(-2, ‘Name or service not known’))
Please see the logfiles in /var/log/letsencrypt for more details.

I solved this issue by doing following:

$vi /etc/letsencrypt/cli.ini

Put following code in that
server = https://acme-v02.api.letsencrypt.org/directory

It solved my problem…