Category: Website developer

 

How to install apache-tomcat,InforMEA OData provider on Windows 10

How to install apache-tomcat, InforMEA OData provider on Windows 10

Prerequisites:
Java 1.7 (not tested with 1.8)
Apache Tomcat 7.x
Hardware requirements: The minimum hardware requirements are specific to Java & Apache Tomcat hosting the toolkit, in terms of RAM allocated to the Java VM we recommend 512 MB but that depends on the dataset size and might need tweaking.
Sofware requirements: No specific requirements, we recommend CentOS Linux. Please consult the Java requirements above.

1- Install Tomcat – The current version at date of 08/10/2020 is the version 9.0 and it will install on

C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
\webapps –> is the directory use as documentroot

Is better to change on windows services to “Apache Tomcat 9.0.38 Server” to run manually that will help to stop/restart it when you are installing the API..
Apache Tomcat 9.0.38 Server

2- Download the last release version Informea API on Github(version used is informea-2.4.5.war)
And this WAR file and copy it to Tomcat webapps, and restart the Tomcat, and it should it the informea api

To check it

http://localhost:8090 is tomcat is working( in our case, installed informea)

2.1 Configuration of Mysql and database:
You will to change:


C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\informea245\WEB-INF\classes\META-INF

http://localhost:8090/informa245 — My installation

InforMEA OData toolkit

Defender WordPress Security, Malware Detection, and Firewall to block access to wp-includes: Internal error

Defender WordPress Security, Malware Detection, and Firewall to block access to wp-includes to avoid an internal error 500.

After installed a WP plugin called Defender and configured, we found out that it provoking access denied to wp-includes:


The script from “https://yourdomain.com/wp-includes/js/thickbox/thickbox.js?ver=3.1-20121105” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
plugins.php
The script from “https://yourdomain.com/wp-includes/js/dist/a11y.min.js?ver=2.5.1” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
plugins.php
The script from “https://yourdomain.com/wp-includes/js/wp-sanitize.min.js?ver=5.3.2” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
plugins.php
The script from “https://yourdomain.com/wp-includes/js/wp-auth-check.min.js?ver=5.3.2” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
plugins.php
The script from “https://yourdomain.com/wp-includes/js/jquery/ui/widget.min.js?ver=1.11.4” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
plugins.php
The script from “https://yourdomain.com/wp-includes/js/heartbeat.min.js?ver=5.3.2” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
plugins.php
The script from “https://yourdomain.com/wp-includes/js/jquery/ui/mouse.min.js?ver=1.11.4” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
plugins.php
The script from “https://yourdomain.com/wp-includes/js/jquery/ui/core.min.js?ver=1.11.4” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
plugins.php
The script from “https://yourdomain.com/wp-includes/js/jquery/ui/draggable.min.js?ver=1.11.4” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
plugins.php
The script from “https://yourdomain.com/wp-includes/js/jquery/ui/slider.min.js?ver=1.11.4” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
plugins.php
The script from “https://yourdomain.com/wp-includes/js/jquery/jquery.ui.touch-punch.js?ver=0.2.2” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
plugins.php
The script from “https://yourdomain.com/wp-includes/js/backbone.min.js?ver=1.4.0” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
plugins.php
The script from “https://yourdomain.com/wp-includes/js/dist/vendor/wp-polyfill.min.js?ver=7.4.4” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.

1- Solution check inside the folder wp-includes for .htaccess file that is added by WP defender, you delete this file and try configure again o modify this file here is an example:


deny from allallow from allallow from all
## WP Defender - Protect PHP Executed ##

Order allow,deny
Deny from all


Allow from all


Allow from all

## WP Defender - End ##

Disable, reset or remove from mysql the 2 factor authentication wpmudev, Defender

Disable, reset or remove mysql 2 factor authentication wpmudev, Defender the plugin installed on WordPress

After active this option: “You are required to setup two-factor authentication to use this site.”

Follow the procedure
1. Install the Verification app
2. Scan the barcode
3. Enter passcode
Enter the 6 digit passcode that is shown on your device into the input field below and hit “Verify”.
But for any reason it was working to verify the code.
The option you are
1- Delete the plugin via ftp or file manger, but unfortunately that will not solve the issue because the configuration will remain on the database.
2- This option is best solution, access to your database search the wp_options(it depends the extension of your, but name should end _options) search for wd_2auth_setting:

SELECT * FROM `wp_options` WHERE `option_name` LIKE ‘%wd_2auth_settings%’

Configuration of wd_2auth_settings:


a:12:{s:7:"enabled";s:1:"1";s:9:"lostPhone";b:1;s:9:"forceAuth";b:0;s:13:"forceAuthMess";s:69:"You are required to setup two-factor authentication to use this site.";s:9:"userRoles";a:0:{}s:14:"forceAuthRoles";a:0:{}s:13:"customGraphic";i:0;s:16:"customGraphicURL";s:94:"https://smarttechno.co.uk/wp-content/plugins/defender-security/assets/img/2factor-disabled.svg";s:10:"isConflict";a:0:{}s:13:"email_subject";s:0:"";s:12:"email_sender";s:0:"";s:10:"email_body";s:0:"";}

Yes delete everything, that will remove 2 factor authentication or you only change s:7:”enabled” by s:7:”disabled”;

Here is modified content:


a:12:{s:7:"disabled";s:1:"1";s:9:"lostPhone";b:1;s:9:"forceAuth";b:0;s:13:"forceAuthMess";s:69:"You are required to setup two-factor authentication to use this site.";s:9:"userRoles";a:0:{}s:14:"forceAuthRoles";a:0:{}s:13:"customGraphic";i:0;s:16:"customGraphicURL";s:94:"https://smarttechno.co.uk/wp-content/plugins/defender-security/assets/img/2factor-disabled.svg";s:10:"isConflict";a:0:{}s:13:"email_subject";s:0:"";s:12:"email_sender";s:0:"";s:10:"email_body";s:0:"";}


When you will update your dashboard, you should now is not active:

ow to reset Two Factor Auth settings using

WP, the date vs get the date in loop

Why the the_date function on WordPress won’t display some dates?

In the loop to display posts on your blog the  function the_date probably won’t display all the dates, but the get_the_date will do.

Why the_date is not working but get_the_date is working?

The_date(), will not display  the same date if another post has the same date, but get_the_date will display, so we recommend to the get_the_date()


 echo get_the_date();

Solution for WP duplicator installation: This site can’t be reached dup-installer/main.installer.php is unreachable.

Solution for WP duplicator installation: This site can’t be reached dup-installer/main.installer.php is unreachable.

Step one: If you have access to CP, navigate to where you are trying to install using the WP Duplicator, dup-installer/error_log: inside the log file:


[21-Nov-2019 20:38:52 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function json_encode() in .../public_html/dup-installer/classes/utilities/class.u.notices.manager.php:86

From this error, Json is not installed or activate on you CP. If you have access to CP or ask the hosting’s company to activate Json on the PHP configuration:

On Json will be activate try to install again:

Note: On the log error you should find the reason why the installation of duplicator is not working.

Solution of Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided.

Solution of Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided.
On Angular with node:


(index):1 Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://js.stripe.com') does not match the recipient window's origin ('https://justseats.org').

Solution on Error [WDS] Disconnected! angular

Solution on Error [WDS] Disconnected! angular
By ng serve —disable-host-check worked for me…


client?bf7e:146 [WDS] Disconnected!
close @ client?bf7e:146
sock.onclose @ socket.js:15
webpackJsonp.../../../../sockjs-client/lib/event/eventtarget.js.EventTarget.dispatchEvent @ eventtarget.js:51
(anonymous) @ main.js:356
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:425
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask @ zone.js:192
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask @ zone.js:499
ZoneTask.invoke @ zone.js:488
timer @ zone.js:2040
setTimeout (async)
scheduleTask @ zone.js:2056
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:411
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.scheduleTask @ zone.js:236
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.scheduleMacroTask @ zone.js:259
----

Solution
1- Configure Nginx….

on Ubuntu, add the next code on default.conf
/etc/nginx/conf.g/default.conf


 location /sockjs-node/ {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        rewrite ^/(.*)$  /$1  break;
        proxy_set_header Host localhost;
        proxy_pass http://localhost:1355/;
    }

2- And to server ng add the option –public-host=httpfake://0.0.0.0/

sudo forever start node_modules/@angular/cli/bin/ng serve -w –port 1355 –live-reload 1356 –aot –env=prod –public-host=httpfake://0.0.0.0/


How to keep ng serve, angular running on production server on ubuntu using nginx as website server

How to keep ng serve, angular running on production server on ubuntu using nginx as website server

Solution 1

$ sh -c ng serve -w –port 1355 –live-reload 1356 –aot –env=prod “/home/ubuntu/project/ukgoodbye/”

Solution 2

$ forever start node_modules/@angular/cli/bin/ng serve -w –port 1355 –live-reload 1356 –aot –env=prod “/home/ubuntu/project/ukgoodbye/”


sudo forever start node_modules/@angular/cli/bin/ng serve -w --port 1355 --live-reload 1356 --aot --env=prod 
warn:    --minUptime not set. Defaulting to: 1000ms
warn:    --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info:    Forever processing file: node_modules/@angular/cli/bin/ng

Check the log:
$ nano -v /home/ubuntu/.forever/dfyn.log

sudo forever start –watch app.js that will run sails lift

How to run mongodb on linux,ubuntu as process

How to run mongodb on linux,ubuntu as process

Supposed that mongodb is installed and configured, and now you want to Start mongod as a Daemon:


ubuntu@ip-127-0-0-1:/var/lib/mongodb$ sudo mongod --fork --logpath /var/log/mongodb.log --dbpath /var/lib/mongodb
about to fork child process, waiting until server is ready for connections.
forked process: 21293
child process started successfully, parent exiting
ubuntu@ip-127-0-0-1:/var/lib/mongodb$ 

Now, how to test if mongodb has started really as daemon;


ubuntu@ip-127-0-0-1:/var/lib/mongodb$ mongo
MongoDB shell version v3.4.9
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.9
Server has startup warnings: 
2019-10-19T07:49:38.302+0000 I STORAGE  [initandlisten] 
2019-10-19T07:49:38.303+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-10-19T07:49:38.303+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] 
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] 
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] 
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] 
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] 
> show dbs
admin      0.000GB
UKgoodbye  0.002GB
local      0.000GB
> 

Mongodb is ready!

Nginx configuration location on AWS ubuntu, /etc/nginx/nginx.conf

Nginx configuration location on AWS ubuntu, /etc/nginx/nginx.conf

Here an example of nginx.conf


user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
          ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

         gzip_vary on;
          gzip_proxied any;
         gzip_comp_level 9;
         gzip_buffers 16 8k;
         gzip_http_version 1.1;
         gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text$

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

It says that it include sites-enabled/*. cd /etc/nginx/sites-enabled/ to find out, www.ukgoodbye.co.uk

Content of the enabled site:


....
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
        # listen 80 default_server;
        # listen [::]:80 default_server;

        # SSL configuration
        #
        listen 443;
        listen [::]:443;

        ssl on;
        ssl_certificate /etc/nginx/ssl/ssl_bundle.crt;
        ssl_certificate_key /etc/nginx/ssl/ukgoodbye_com.key;

        ssl_dhparam /etc/nginx/ssl/dhparam.pem;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

        #
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name www.ukgoodbye.co.uk;


        location / {
                #rewrite ^/ukgoodbye(.*) $1 break;
                #add_header "Access-Control-Allow-Origin" "*, *";
                proxy_pass http://127.0.0.1:1355;
        }
        location /ukgoodbye-services/ {
                rewrite ^/ukgoodbye-services(.*) $1 break;
                #add_header "Access-Control-Allow-Origin" "*, *";
                proxy_pass http://127.0.0.1:1337;
        }

#       location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
#               try_files $uri $uri/ =404;
#       }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #       include snippets/fastcgi-php.conf;
        #
        #       # With php7.0-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
        #       # With php7.0-fpm:
        #       fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
server {
        listen 80;
        listen [::]:80;
        # Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
        return 301 https://$host$request_uri;
        server_name www.ukgoodbye.co.uk;

#       root /var/www/example.com;
#       index index.html;
#
#       location / {
#               try_files $uri $uri/ =404;
#       }
}