Wednesday, February 19, 2020

HP DL380 G5 Server - Cannot Install Latest Ubuntu / Linux - Solution

Update all firmware on HP DL380 G5 server
The firmware for that server is located on HP's website:

Solved the problem cannot find the disk to install latest version ubuntu :)

Ref: https://serverfault.com/questions/793011/update-all-firmware-on-hp-dl380-g5-server

Tuesday, February 18, 2020

Trying to upgrade mysql 56 to 80


1. Manage to upgrade mysql 56 to 57
a. Stop MySQL: service mysql-server stop
b. Add to /etc/rc.conf:
Code:
mysql_args="--explicit_defaults_for_timestamp=true --skip-grant-tables --skip-slave-start --thread_stack=256K"
These are needed, it prevents the slave process from starting, skips grant tables (so you always have access), the thread stack seems to be required, I ran out of it a couple of times

c. Install MySQL 5.7: pkg install mysql57-server
d. Start it: service mysql-server start
e. Note, this starts MySQL with the arguments we added above.
f. Run the upgrade script: mysql_upgrade (But For number (f) - > mysql_upgrade -u root –p )
g. Stop MySQL server: service mysql-server stop
h. Remove the mysql_args line from /etc/rc.conf
i. Start MySQL server service mysql-server start
j. Done


2. Failed upgrade mysql57 to mysql 80

a) Pre-requisite using this blog -> https://dinfratechsource.com/2019/06/12/upgrade-from-mysql-5-7-to-mysql-8-0/

b) but mine mysql version is 8.0.19, have problem with uppercase characters.

c) https://dev.mysql.com/doc/refman/8.0/en/upgrade-binary-package.html

i)SET GLOBAL innodb_fast_shutdown = 1; -- fast shutdown

ii)Shut down the old MySQL server. For example: mysqladmin -u root -p shutdown

iii) Upgrade the MySQL binaries or packages. If upgrading a binary installation, unpack the new MySQL binary distribution package. See Obtain and Unpack the Distribution. For package-based installations, install the new packages. (pkg install mysql80-server)

iv)Start the MySQL 8.0 server, using the existing data directory. For example: mysqld_safe --user=mysql --datadir=/path/to/existing-datadir &


Failed: with error uppercase characters.

i) lower_case_table_names=1, change in /usr/local/etc/mysql/my.cnf

  • error uppercase

ii) lower_case_table_names=1,change in /usr/local/etc/mysql/my.cnf

  • 2020-02-17T06:04:32.646839Z 2 [ERROR] [MY-013140] [Server] BLOB/TEXT column 'FileSystem' used in key specification without a key length
  •   2020-02-17T06:04:50.345066Z 0 [ERROR] [MY-010022] [Server] Failed to Populate DD tables.
  • 2020-02-17T06:04:50.346251Z 0 [ERROR] [MY-010119] [Server] Aborting
  • 2020-02-17T06:04:53.342583Z 0 [System] [MY-010910] [Server] /usr/local/libexec/mysqld: Shutdown complete (mysqld 8.0.19) Source distribution.

Wednesday, January 15, 2020

Upgrade Mysql 5.5 to Mysql 5.6

1.     Stop MySQL: service mysql-server stop
2.     Add to /etc/rc.conf:
  • Code:
  • mysql_args="--explicit_defaults_for_timestamp=true --skip-grant-tables --skip-slave-start --thread_stack=256K"
These are needed, it prevents the slave process from starting, skips grant tables (so you always have access), the thread stack seems to be required, I ran out of it a couple of times
3.     Remove MySQL 5.5 server: pkg delete mysql55-server
4.     Install MySQL 5.6: pkg install mysql56-server
5.     Start it: service mysql-server start
6.     Note, this starts MySQL with the arguments we added above.
7.     Run the upgrade script: mysql_upgrade (But For number (6) - > mysql_upgrade -u root –p )
8.     Stop MySQL server: service mysql-server stop
9.     Remove the mysql_args line from /etc/rc.conf
10. Start MySQL server service mysql-server start
11. Done

Monday, December 2, 2019

Migrate Worpress from Old OS to New OS


Prepare Ubuntu 18.04 with LAMP (Linux, Apache, MySQL, PHP)

Step 1 — Installing Apache

Install Apache using Ubuntu’s package manager, apt:
sudo apt update
sudo apt install apache2

Step 2 — Installing MySQL

sudo apt install mysql-server
Logon to MySQL server by running the commands below
sudo mysql -u root
Notice no password?
That should get you into the database server. After that, run the commands below to disable plugin authentication for the root user
USE mysql;
UPDATE user SET plugin='mysql_native_password' WHERE User='root';
FLUSH PRIVILEGES;
exit;
Restart and run the commands below to set a new password.
sudo systemctl restart mysql.service
After that, run the commands below to secure MySQL server and create a new root password.
sudo mysql_secure_installation
When prompted, answer the questions below by following the guide.
Enter current password for root (enter for none): Just press Enter
Set root password? [Y/n]: Y
New password: Enter password
Re-enter new password: Repeat password
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]:  Y
Reload privilege tables now? [Y/n]:  Y
You should now be able to logon with password authentication and other applications should now work with the root password authentication.

Step 3 — Installing PHP

apt-get install python-software-properties
add-apt-repository ppa:ondrej/php
apt install php5.6 libapache2-mod-php5.6 php5.6-mysql php5.6-curl php5.6-json php5.6-cgi php5.6-xml php5.6-readline php5.6-common php5.6-cgi php5.6-cli
systemctl restart apache2

Step 4 — Setting Up Virtual Hosts

/etc/apache2/sites-available/your_domain.conf
    ServerAdmin webmaster@localhost
    ServerName your_domain
    ServerAlias www.your_domain
    DocumentRoot /var/www/your_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Enable site:
sudo a2ensite your_domain.conf
Disable site:
sudo a2dissite 000-default.conf
Test for configuration errors:
sudo apache2ctl configtest
Restart Apache: 
sudo systemctl restart apache2


Ubuntu 18.04 Chronicles: removing cloud-init

1.       dpkg-reconfigure cloud-init
·         Then deselect all the options except None
2.       sudo apt-get purge cloud-init
3.       sudo mv /etc/cloud/ ~/; sudo mv /var/lib/cloud/ ~/cloud-lib
·         I prefer to move, rather than delete, in case something goes wrong and you wish to restore the files.
When you remove cloud-init following those steps, your machine stops booting and there is apparently a service that is waiting for network to be up. This would normally be just an inconvenience, but the boot hangs indefinitely waiting for said network. Odd choice of configuration out of the box, but anyway, you can fix this by:
  1. List the services which depend on network being online.
o    sudo systemctl show -p WantedBy network-online.target
  1. This will list the culprits as some iscsi services that you probably don’t need.
  2. Disable the services
o    systemctl disable

Copy Configuration and Files into New Server


1.       Copy wp-config.php
2.       Copy all files using rsync (be careful with rsync, you can use option -anv as dry run script)
a.       rsync –option
                                                   i.      Server Old: xxx.xxx.xxx.xxx
                                                 ii.      Run rsync from new server:
                                               iii.      rsync -av aminah@xxx.xxx.xxx.xxx:/data/wordpress   /datanewlocation/
3.       a2enmod dir
4.       a2enmod cgi
5.       a2enmod rewrite
6.       Backup Database: mysqldump -uiradio_root -p --default-character-set=utf8 --databases iwpress_db > 191128iwpress_db.sql
7.       Restore Database: mysql -uroot -p --default-character-set=utf8 <191128iwpress_db .sql="" span="">
8.       Grant privileges: grant all privileges on namadb.* to 'namadb_admin'@'localhost' identified by 'password';


After iwpress.contoso.com available, you can access wp-admin and update the wordpress, plugin and themes. After get the latest version of Wordpress (version 5.3 – on date 29/11/2019), then you can upgrade the php5.6 to php7.3

Upgrade PHP 5.6 to PHP 7.3


Use the following set of command to add PPA for PHP 7.3 in your Ubuntu system and install PHP 7.3.
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

Install PHP 7.3

apt-get install libapache2-mod-php7.3 php7.3-cgi php7.3-cli  php7.3-common php7.3-curl php7.3-json php7.3-mysql php7.3-opcache php7.3-readline php7.3-xml
Disable mod php apache
a2dismod php5.6
Enable mod php apache
a2enmod php7.3

Remove PHP 5.6

apt-get remove     libapache2-mod-php5.6 php5.6-cgi php5.6-cli  php5.6-common php5.6-curl php5.6-json php5.6-mysql php5.6-opcache php5.6-readline php5.6-xml
Listing any package with php
dpkg --get-selections | grep php
Restart Apache Services
service apache2 restart

 

Hardening Wordpress Sites

Change WordPress Database Prefix

By default, WordPress uses wp_ as the prefix for all tables in your WordPress database. If your WordPress site is using the default database prefix, then it makes it easier for hackers to guess what your table name is. This is why we recommend changing it. You can change your database prefix by following our step by step tutorial on how to change WordPress database prefix to improve security.
Note: This can break your site if it’s not done properly. Only proceed, if you feel comfortable with your coding skills.

Security.conf

Edit /etc/apache2/conf-enabled/security.conf to send only minimal information about the server:
ServerTokens Prod
ServerSignature Off
TraceEnable Off
mod_headers to be enabled
a2enmod headers
Add the following to your Apache configuration file /etc/apache2/conf-enabled/security.conf:
# Prevent MSIE from interpreting files as something else than declared by the content type in the HTTP headers.
# Requires mod_headers to be enabled.
Header set X-Content-Type-Options: "nosniff"
 # Prevent other sites from embedding pages from this site as frames. This defends against clickjacking attacks.
# Requires mod_headers to be enabled.
Header set X-Frame-Options: "sameorigin"
 # Block pages from loading when they detect reflected XSS attacks
# Requires mod_headers to be enabled.
Header set X-XSS-Protection: "1; mode=block"
Restart Apache:
sudo service apache2 restart

Wednesday, May 22, 2019

OCS Inventory

Here some references:


  1. http://www.hoelzle.net/ocs-inventory-ng-unter-ubuntu-16-04-installieren/
  2. http://www.juanluramirez.com/instalar-ocs-inventory-server-ubuntu-16-04/
  3. http://ask.ocsinventory-ng.org/8583/tutorial-ocs-2-4-on-ubuntu-16-04
  4. https://github.com/OCSInventory-NG/OCSInventory-ocsreports/blob/master/ipdiscover-util.pl
  5. https://github.com/OCSInventory-NG/Wiki/blob/master/english/05.Network-Discovery-with-OCS-Inventory-NG/Using-IP-discovery-feature.md
  6. http://www.miloszengel.com/ocs-ng-2-2-server-complete-install-guide-on-debian-jessie-8-4/