Friday, August 17, 2018

centOS rebuild




***************************************************
if home page is only web directory,  it is WHM upgrade, you have to log into and accept user term to start again

set /cleargov1 as default home page.

Now set /cleargov1 as index top priority on apache.

whm --- search --- apache 

click apache configuration( under service configuration)

click Directory/index priority

add new /cleargov1

click move up, move it to top

click button restart apache


*********************************************





run node:

cd /home/hoogw2000/public_html/arcgis_viewer/
pm2 start npm -- start



kill node:
http://pm2.keymetrics.io

pm2 delete 0

pm2 stop 0

pm2 list

//  //    nohup nodemon --exec npm start






************* user (hoogw) cd /../.../ permission denied   ***********************


putty login (only as hoogw, it is server account) NOT hoogw2000, it is cpannel account,use to login to cpannel

whoami  [show currently what user]

ls, permission denied, try sudo ls

switch user to hoogw2000:
sudo su - hoogw2000

if get permission denied, try run as root(super user mode):
sudo su
        cd /.../......

if run as hoogw2000, you should be able to :
cd /home/hoogw2000/public_html/arcgis_viewer/
pm2 start npm -- start


========================================================

Install nodejs, npm, pm2 globally 


Step 1 – Add Node.js Yum Repository
First of all, You need to enable node.js yum repository in your system provided by the Node.js official website. You also need development tools to build native add-ons to be installed on your system.

For Latest Release:-

yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_11.x | sudo -E bash -



For Stable Release:-

yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_8.x | sudo -E bash -


Step 2 – Install Node.js and NPM
After adding yum repository in your system lets install Node.js package. NPM will also be installed with node.js. This command will also install many other dependent packages on your system.

yum install nodejs
Don’t Miss => Yarn Installation ( A Node Modules Manager)

       Install Yarn using NPM
Yarn package is available to install with NPM. You can simply run the following command to install Yarn globally. Also, remove -g option to install for current project only.

sudo npm install yarn -g



Step 3 – Check Node.js and NPM Version
After installing node.js verify and check the installed version. You can find more details about current version on node.js official website.

node -v 

v11.0.0
Also, check the version of npm.

npm -v 

6.4.1




                  --------------------------
Install PM2 globally:

1)run as root(super user mode):      
  sudo su

2) npm i -g pm2


or if user is sudo-er

sudo npm i -g pm2
and then go back to user (or stay in root if it was created by root user) and run it:

pm2 start server.js




*******  End ****** user (hoogw) cd /../.../ permission denied   ***********************

================================================

after rebuild, 


godaddy server page:

at cpanel tab:


click ----  create whm sites,


at WHM web site:




1) avoid automatically disconnect logout, first set

   search 'tweek'
 Tweak Settings, you will want to go to the “Security” tab. There, you can find the Cookie IP Validation segment

  default is strict, this cause you problem.

  set it as 'disabled'





2) create a cpanel account:

search --- "create"    

click ---------- create a new account 
(cpanel, account, can NOT be same as hoogw(server account), must be something different )


hoogw2000
A1a1#8113



======================================

wait for a few minutes, now godaddy server page, cpanel tab, you should see, manager server(whm)  and cpanel link






******* welcome page **********

click manage server(whm)
you should see:  welcome page
      feature showcase......

Enable all ... click save setting



***********  create mysql database: ********************

Must first create db with prefixed user name, then rename db to remove user prefix

cpanel, ------ database section ------- mysql database ( NOT phpmyadmin)

1)    create a new database 

2)    add   hoogw200_root user to the newly created DB  ( must DO)


 You you do not want use user prefix as database name, you could do

3) whm, ---------- search sql  ---------- under sql service section -----------  click  manage databaseclick action for the db, you want to rename, then rename it to without user prefix

click submit. 




**********  create mysql user ********************

hoogw200_root
medyhzl8113


************ add user to database ******************
add hoogw200_root to all 3 db


************ 
PHP config file update mysql user name, password, etc. for cleargov1, glassgov1, arcgis_viewer.

********************





*********upload db by phpmyadmin **********




cpanel, ------ database section ----- phpmyadmin 

click each db leftside panel, ----- click import tab -----
click choose file, you can use .gz directly
click GO




############## upload file public_html ###############

cpanel ---- file manager -----
upload all zip file to public_html folder, 

extract all zip here

php config file need to rename by config_centOS to config (cleargov1, glassgov1)

 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
missing mbstring extention ( glassgov1, carbon forum required)

=====================================

Install the mbstring PHP Extension with EasyApache


php -m | grep mbstring  [if nothing, means missing mbstring]



whm cpanel ----- search for apache,

open easy apache 4

customize currently installed packages,

click "customize" on top first line

leftside: php extensions -----
search mbstring,  
Enable 5.6, 5.6, 5.7 version mbstring.

click next, next, .... privision. done


php -m | grep mbstring  [should see mbstring]



RESTART apache and PHP to effect


glassgov1 not working need to fix!!!!!!!!

"Status": 0,
"ErrorCode": 403, "ErrorMessage": "Forbidden"







^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


install node.js


putty login 104.238.125.233

cd ~


wget https://nodejs.org/dist/v10.7.0/node-v10.7.0-linux-x64.tar.xz


tar xvf node-v10.7.0-linux-x64.tar.xz

mv node-v10.7.0-linux-x64 nodejs


mkdir ~/bin


cp nodejs/bin/node ~/bin

cd ~/bin

ln -s ../nodejs/lib/node_modules/npm/bin/npm-cli.js npm

node --version

npm --version



*************************************
===========================================



cpanel- file -manager--public_html --arcgis_viewer folder,

.env file need to switch with centOS.env, 

first set show hidden files by

screen right top corner, click setting, 

check Show Hidden Files (dotfiles)


========================================

******** start node.js app****************


if you want to use nodemon, fist install it, but here, NO need do this
npm install -g nodemon


Installing PM2

 npm install pm2 -g


cd  /home/hoogw2000/public_html/arcgis_viewer/

PM2 now supports npm start:
pm2 start npm -- start

http://pm2.keymetrics.io/

pm2 list

list all process.......

pm2 stop  0
pm2 restart  0
pm2 delete  0






******** End ****start node.js app****************
========================================


Now set /cleargov1 as index top priority on apache.

whm --- search --- apache 

click apache configuration( under service configuration)

click Directory/index priority

add new /cleargov1

click move up, move it to top

click button restart apache
================






SSL---- SSL-----SSL

+++++++++++++++++++++++++


 After rebuild, the private key on server is damaged. You can not just upload certificate and install(with private key). Key not match, instead you must generate a csr, then re-key (copy past csr)

after get email from godaddy, 

download crt file, only upload 1 crt,  install



centOS SSL

godaddy SSL

ON Server

1) cpanel  --------- click SSL/TLS

2) click 

Certificate Signing Requests (CSR)


    click Generate


3) copy first part:  encoded CSR



ON godaddy

my product ------------ SSL certificate ----- click manage button


you should see your ssl certificate, click it.

Re-Key


Top menu, click repository,

3 big button, download, re-key,  xxx.  click re-key

3 plus + sign, click first +,  past your CSR here.


Click Save button

at bottom, click "generate certificate" button.


Wait ..................  hours? days?.........................


You got a email from godaddy,  follow download link to download zip file.

zip file has 2 crt file.


Upload 2 crt file at cpanel.  click SSL/STL

click

Certificates (CRT)


Upload a New Certificate



choose file, 2 crt.

then you upload crt.



at SSL/STL   click

Manage Installed SSL Websites


click

Browse certificate, choose the new one you just uploaded.

then install.

Done






---------------------------------------

node express add SSL



1)
download private key file from cpanel ----- ssl/STL ---- private key---
click edit, copy encoded part into a new file. Save to /bin/www/private.key

2)
download certificate file, from godaddy, my product, SSL,
click download button, choose other type.

Only 1 file xxxx.crt is the one we need, copy to  /bin/www/public.cert



3)
/bin/www  file add https code.

// readFileSync function must use __dirname get current directory


// require use ./ refer to current directory.

-------------------------------------------------------------------------





==================== redirect http://  to https:// ===============================

Because of domain transparentgov.net bind to IP,  by default, user will  get http://transparentgov.net
We must redirect all http://.... to https://..........


Other urls are automatically without this .htaccess file.
http://agv1.transparentgov.net  will forward to https://transparentgov.net:3000 at google domain. 

http://ms1.transparentgov.net will forward to https://transparentgov.net/mapserver1/viewer at google domain

pdfbay.org domain forward to https://transparentgov.net/glassgov1


so only .htaccess under cleargov1 need to update redirect. 




cpanel ----- file manager ------


public_html/cleargov1/  folder,

setting (top right corner) ---- show hidden files


htaccess file must be at the folder you want redirect really happen !
Not public_html ( root ) folder.





update file

.htaccess

add following code, to bottom


RewriteEngine On 
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?transparentgov\.net
RewriteRule ^(.*)$ https://transparentgov.net/$1 [R,L]


cleargove1/.htaccess 

Options -Indexes
DirectoryIndex index.php

RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]

RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?transparentgov\.net
RewriteRule ^(.*)$ https://transparentgov.net/cleargov1/$1 [R,L]



==============End ====== redirect http://  to https:// ===============================






END ------ SSL---- SSL-----SSL








%%%%%%%%%%%%%%%



fix bug


carbon forum(glassgov1)


ERROR
{
 "Status": 0,
 "ErrorCode": 403,
 "ErrorMessage": "Forbidden"
}

mysql db - table - config

AppDomainName :  make empty

if this one have value, cause 403 error

================================



How to Fix Automatic Disconnects from WHM & cPanel

Fix Automatic Disconnects from WHM & cPanel

The fix is simply changing an option in the settings of WHM. To do this, log into WHM and find the “Tweak Settings” option on the left sidebar. If you do not see it, you may type “tweak” in the search bar and it should filter the left bar so you can see it.
Once in Tweak Settings, you will want to go to the “Security” tab. There, you can find the Cookie IP Validation segment. It should look similar to the below.
Under the Security Setting of Tweak setting, select Cookie IP Validation to Disabled.
Tweak Settings

This defaults to strict. You will want to set it to disabled and then scroll down and hit the “Save” button. This will stop the automatic disconnects you are receiving from WHM.

Thursday, August 9, 2018

mysql replace duplicate concat post


add, bing map link record


update world.countrylanguage
set content_bingmap = replace(original_content, 'googlemaps ', 'bingmaps')


update world.countrylanguage
set content = concat(original_content, '
', content_bingmap)







replace /googlemaps/ with /maps1/

update world.countrylanguage
set test = replace(test, 'F', 'FFFFFFFFF')