Web Development

Install Oracle Database 19c on CentOS 8 in VirtualBox

** Please use the root user to edit the files and execute the commands unless further notice. **

Prerequisite

  1. Install the latest VirtualBox Platform Package and the VirtualBox Extension Pack (Oracle_VM_VirtualBox_Extension_Pack-VERSION.vbox-extpack).
  2. Download the latest VirtualBox Guest Additions (VBoxGuestAdditions_VERSION.iso).
  3. Download the latest CentOS Stream 8.
  4. Create a new virtual machine and install the CentOS to the virtual machine. During the CentOS installation, select Workstation as Base Environment, select Container ManagementDevelopment Tools and Graphical Administration Tools as Additional software for Selected Environment. Use http://mirror.centos.org/centos/8/BaseOS/x86_64/os/ as the installation source.
  5. After installing the CentOS, execute the following commands to get the required libraries to create applications for handling compiled objects.
dnf update
dnf -y install elfutils-libelf-devel
  1. Insert the ISO of VirtualBox Guest Additions to the virtual machine, and then install it.

Download Packages and Software

Hostname and Host File

  1. Open the file /etc/hostname, change the content to update the hostname.
ol8-19.localdomain
  1. Open the file /etc/hosts, add your IP address and hostname.
192.168.122.1 ol8-19.localdomain

Install Required Packages

  1. Perform a dnf update to update every currently installed package.
dnf update
  1. Add execute permission to the downloaded rpm files.
chmod u+x *.rpm
  1. Install the libcapl library for getting and setting POSIX.1e (formerly POSIX 6) draft 15 capabilities.
dnf localinstall -y compat-libcap1-1.10-7.el7.x86_64.rpm
  1. Inatll the libstdc++ package which contains compatibility standard C++ library from GCC 3.3.4.
dnf localinstall -y compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
  1. Install the below required packages.
dnf install -y bc binutils elfutils-libelf elfutils-libelf-devel fontconfig-devel \
    gcc gcc-c++ glibc glibc-devel ksh ksh libaio libaio-devel libgcc libnsl libnsl.i686 \
    libnsl2 libnsl2.i686 librdmacm-devel libstdc++ libstdc++-devel libX11 libXau libxcb \
    libXi libXrender libXrender-devel libXtst make net-tools nfs-utils smartmontools \
    sysstat targetcli unixODBC;

Install Oracle Installation Prerequisites

  1. Install the Oracle Installation Prerequisites (OIP) package.
dnf localinstall -y oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
  1. Open the /etc/group file, update the GID of the below items.
oinstall:x:64890:oracle
dba:x:64891:oracle
oper:x:64892:oracle
backupdba:x:64893:oracle
dgdba:x:64894:oracle
kmdba:x:64895:oracle
racdba:x:64896:oracle
  1. Open the /etc/passwd file, update both the UID and GID of account oracle.
oracle:x:64890:64890::/home/oracle:/bin/bash
  1. Update the password of account oracle.
passwd oracle
  1. Set secure Linux to permissive by editing the /etc/selinux/config file.
SELINUX=permissive
  1. Set the secure Linux change right now.
setenforce Permissive
  1. Disable the firewall.
systemctl stop firewalld
systemctl disable firewalld

Setup Oracle User Profile

  1. Create Oracle directories.
mkdir -p /u01/app/oracle/product/19.3.0/dbhome_1
mkdir -p /u02/oradata
chown -R oracle:oinstall /u01 /u02
chmod -R 775 /u01 /u02
  1. Create a new directory for Oracle user.
mkdir -p /home/oracle/scripts
chown -R oracle:oinstall /home/oracle
  1. Create an environment setting file.
cat > /home/oracle/scripts/setEnv.sh <<EOF
# Oracle Settings
export TMP=/tmp
export TMPDIR=\$TMP

export ORACLE_HOSTNAME=$HOSTNAME
export ORACLE_UNQNAME=cdb1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/19.3.0/dbhome_1
export ORA_INVENTORY=/u01/app/oraInventory
export ORACLE_SID=cdb1
export PDB_NAME=pdb1
export DATA_DIR=/u02/oradata

export PATH=/usr/sbin:/usr/local/bin:\$PATH
export PATH=\$ORACLE_HOME/bin:\$PATH

export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib
EOF
  1. Create a startup shell script.
cat > /home/oracle/scripts/start_all.sh <<EOF
#!/bin/bash
. /home/oracle/scripts/setEnv.sh

export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES

dbstart \$ORACLE_HOME
EOF
  1. Create a stop shell script.
cat > /home/oracle/scripts/stop_all.sh <<EOF
#!/bin/bash
. /home/oracle/scripts/setEnv.sh

export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES

dbshut \$ORACLE_HOME
EOF
  1. Update the owner and permission of the shell scripts and its parent directory.
chown -R oracle:oinstall /home/oracle
chmod u+x /home/oracle/scripts/*.sh
  1. Set the environment when the Bash runs whenever it is started interactively.
cat > /home/oracle/.bashrc <<EOF
#.bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
  . /etc/bashrc
fi

. /home/oracle/scripts/setEnv.sh >> /home/oracle/.bashrc
EOF

chown oracle:oinstall /home/oracle/.bashrc

Create and Add New Swap File

  1. Run the following command, with oracle user, to create and apply new swap file.
dd if=/dev/zero of=/tmp/additional-swap bs=1048576 count=4096
chmod 600 /tmp/additional-swap
mkswap /tmp/additional-swap
  1. Apply the swap by executing the following command with root user.
swapon /tmp/additional-swap

Install Oracle Database

  1. Set the DISPLAY variable with oracle user.
DISPLAY=$HOSTNAME:0.0; export DISPLAY
  1. Unzip the archive with oracle user.
cd $ORACLE_HOME
unzip -oq /path/to/software/LINUX.X64_193000_db_home.zip
  1. “Cheat” the installer about the distribution with oracle user.
export CV_ASSUME_DISTID=RHEL7.6
  1. Run the installer, with oracle user, to install Oracle database.
cd $ORACLE_HOME
./runInstaller -ignorePrereq -waitforcompletion -silent                        \
    -responseFile ${ORACLE_HOME}/install/response/db_install.rsp               \
    oracle.install.option=INSTALL_DB_SWONLY                                    \
    ORACLE_HOSTNAME=${ORACLE_HOSTNAME}                                         \
    UNIX_GROUP_NAME=oinstall                                                   \
    INVENTORY_LOCATION=${ORA_INVENTORY}                                        \
    SELECTED_LANGUAGES=en,en_GB                                                \
    ORACLE_HOME=${ORACLE_HOME}                                                 \
    ORACLE_BASE=${ORACLE_BASE}                                                 \
    oracle.install.db.InstallEdition=EE                                        \
    oracle.install.db.OSDBA_GROUP=dba                                          \
    oracle.install.db.OSBACKUPDBA_GROUP=dba                                    \
    oracle.install.db.OSDGDBA_GROUP=dba                                        \
    oracle.install.db.OSKMDBA_GROUP=dba                                        \
    oracle.install.db.OSRACDBA_GROUP=dba                                       \
    SECURITY_UPDATES_VIA_MYORACLESUPPORT=false                                 \
    DECLINE_SECURITY_UPDATES=true
  1. If the setup is success, the following message should be printed on screen.
Successfully Setup Software.
  1. Execute the below scripts, with root user, to update the permission of Oracle directories and set the environment variables.
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/19.3.0/dbhome_1/root.sh

Database Creation

  1. Start the listener with oracle user.
lsnrctl start
  1. Create a database with oracle user.
dbca -silent -createDatabase                                                   \
     -templateName General_Purpose.dbc                                         \
     -gdbname ${ORACLE_SID} -sid  ${ORACLE_SID} -responseFile NO_VALUE         \
     -characterSet AL32UTF8                                                    \
     -sysPassword SysPassword1                                                 \
     -systemPassword SysPassword1                                              \
     -createAsContainerDatabase true                                           \
     -numberOfPDBs 1                                                           \
     -pdbName ${PDB_NAME}                                                      \
     -pdbAdminPassword PdbPassword1                                            \
     -databaseType MULTIPURPOSE                                                \
     -automaticMemoryManagement false                                          \
     -totalMemory 1000                                                         \
     -storageType FS                                                           \
     -datafileDestination "${DATA_DIR}"                                        \
     -redoLogFileSize 50                                                       \
     -emConfiguration NONE                                                     \
     -ignorePreReqs

Listener Update

  1. Replace or edit the listener.ora file, with oracle user, to set the correct hostname, port number and SID name.
cat > /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora <<EOF
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(PORT = 1539))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = ${ORACLE_SID})
    )
  )

EOF
  1. Reload the Oracle Listener.
lsnrctl reload

Post Installation

  1. Edit the /etc/oratab file, with root user, to update the restart flag from ‘N‘ to ‘Y‘.
orcl:/u01/app/oracle/product/19.3.0/dbhome_1:Y
  1. Configure the Database instance “orcl” with auto startup.
cd $ORACLE_HOME/dbs
ln -s spfilecdb1.ora initorcl.ora
  1. Enable Oracle Managed Files (OMF) and make sure the PDB starts when the instance starts.
sqlplus / as sysdba <<EOF
alter system set db_create_file_dest='${DATA_DIR}';
alter pluggable database ${PDB_NAME} save state;
exit;
EOF
  1. Execute the following commands, with root user, to start the Oracle Listener automatically.
cat > /home/oracle/scripts/cron.sh <<EOF1
#!/bin/bash

. /home/oracle/scripts/setEnv.sh

echo "\`date\`" > /home/oracle/scripts/last.log

lsnrctl start

sleep 3

lsnrctl reload

sleep 3

sqlplus /nolog <
conn / as sysdba
startup
EOF

EOF1

chown oracle:oinstall /home/oracle/scripts/cron.sh
chmod 744 /home/oracle/scripts/cron.sh
  1. Use the following command, with oracle user, to edit the crontab file.
crontab -e
  1. Put the following cron job in the first line of crontab file, then press the keys :wq to save and exit.
@reboot /home/oracle/scripts/cron.sh

Healthcheck

  1. Login as oracle user and then execute the following commands one-by-one.
sqlplus /nolog
conn / as sysdba;
select * from v$version;
show pdbs;

Create New User and Tablespace

  1. Login as Sysdba with SqlPlus.
sqlplus / as sysdba
  1. Update the seesion setting _ORACLE_SCRIPT to true to allow common user comes without c## as prefix.
ALTER SESSION SET "_ORACLE_SCRIPT"=true;
  1. Create a new tablespace with an automatic extensible size 100MB, maximum 10G in size.
-- DROP TABLESPACE my_tablespace INCLUDING CONTENTS AND DATAFILES;
-- Location of the dat file: /u01/app/oracle/product/19.3.0/dbhome_1/dbs/my_tablespace.dat
-- SELECT tablespace_name, block_size, max_size, status FROM DBA_TABLESPACES;
CREATE TABLESPACE my_tablespace
  DATAFILE 'my_tablespace.dat'
    SIZE 100M
    AUTOEXTEND ON
    NEXT 32M MAXSIZE 10G
    EXTENT MANAGEMENT LOCAL
    SEGMENT SPACE MANAGEMENT AUTO
;

SELECT FILE_ID, FILE_NAME, TABLESPACE_NAME, AUTOEXTENSIBLE, INCREMENT_BY 
FROM DBA_DATA_FILES ORDER BY FILE_ID DESC;
  1. [Optional] Update the password life time from 180 days (default) to unlimited.
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
  1. Create a new user.
-- ALTER SESSION SET "_ORACLE_SCRIPT"=true;
-- DROP USER newuser CASCADE;
CREATE USER newuser IDENTIFIED BY "P@ssw0rd" DEFAULT TABLESPACE my_tablespace;
  1. Grant permissions to the new user.
-- REVOKE CREATE SESSION FROM newuser;
-- REVOKE CREATE TABLE FROM newuser;
-- REVOKE CREATE VIEW FROM newuser;
-- REVOKE CREATE ANY TRIGGER FROM newuser;
-- REVOKE CREATE ANY PROCEDURE FROM newuser;
-- REVOKE CREATE SEQUENCE FROM newuser;
-- REVOKE CREATE SYNONYM FROM newuser;
GRANT CREATE SESSION TO newuser;
GRANT CREATE TABLE TO newuser;
GRANT CREATE VIEW TO newuser;
GRANT CREATE ANY TRIGGER TO newuser;
GRANT CREATE ANY PROCEDURE TO newuser;
GRANT CREATE SEQUENCE TO newuser;
GRANT CREATE SYNONYM TO newuser;

ALTER USER newuser QUOTA UNLIMITED ON my_tablespace;
  1. [Optional] Grant DBA to the new user.
-- REVOKE DBA FROM newuser;
GRANT DBA TO newuser;

References

CodeIgniter htaccess File

RewriteEngine On
RewriteBase /ci301/

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Docker Basic Commands

# Command Description Remarks
1 docker ps Lists all the running containers
2 docker ps -a Lists all the running containers with specific details
3 docker pull (id or name of image) Pull image from Docker hub Registry
4 docker pull (id or name of image) Pull image from Docker hub Registry
5 docker pull (id or name of image) Pull image from Docker hub Registry
6 docker pull (id or name of image) Pull image from Docker hub Registry
7 docker pull (id or name of image) Pull image from Docker hub Registry
8 docker pull (id or name of image) Pull image from Docker hub Registry
9 docker pull (id or name of image) Pull image from Docker hub Registry
10 docker pull (id or name of image) Pull image from Docker hub Registry

How to Install Webmin on CentOS 8

Webmin is a free, open-source and web-based system configuration and management tool for Unix-like operating systems. You can set up Apache web server, Samba, DNS, Mail, FTP, Database, File system and package management with Webmin web-based interface. Webmin is very similar to cPanel and provides an easy way to manage Linux systems through a web browser.

Prerequisites

  • A server running CentOS 8.
  • A root password is configured on your server.

Getting Started

By default, SELinux is enabled in CentOS 8 server. So you will need to disable it first.

You can do this by editing /etc/selinux/config file:

nano /etc/selinux/config

Make the following changes:

SELINUX=disabled

Save and close the file. Then, restart your server to apply the changes.

Install Webmin with RPM

First, you will need to install the required dependencies by running the following command:

dnf install perl perl-Net-SSLeay openssl perl-Encode-Detect

Once all the dependencies are installed, download the Webmin RPM package from the Sourceforge download page with the following command:

wget https://prdownloads.sourceforge.net/webadmin/webmin-1.930-1.noarch.rpm

Once downloaded, run the following command to install Webmin:

rpm -ivh webmin-1.930-1.noarch.rpm

You should see the following output:

warning: webmin-1.930-1.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 11f63c51: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Operating system is CentOS Linux
Updating / installing...
   1:webmin-1.930-1                   ################################# [100%]

Webmin install complete. You can now login to https://centos8:10000/
as root with your root password.

By default, Webmin runs on port 10000. You can check whether Webmin is running or not with the following command:

netstat -ant | grep 10000

You should see the following output:

tcp        0      0 0.0.0.0:10000           0.0.0.0:*               LISTEN  

You can also check the Webmin process with the following command:

ps -ef | grep webmin

You should see the following output:

root      2131     1  0 12:29 ?        00:00:00 /usr/bin/perl /usr/libexec/webmin/miniserv.pl /etc/webmin/miniserv.conf
root      2225  6290  0 12:30 pts/0    00:00:00 grep --color=auto webmin

Install Webmin with Yum Repository

You can also install the Webmin from CentOS Yum repository. First, create a Webmin repository with the following command:

nano /etc/yum.repos.d/webmin.repo

Add the following lines:

[Webmin]
name=Webmin Distribution Neutral
mirrorlist=https://download.webmin.com/download/yum/mirrorlist
enabled=1

Save and close the file. Then, download and add the repository signing key with the following command:

wget http://www.webmin.com/jcameron-key.asc
 rpm --import jcameron-key.asc

Next, install the Webmin by running the following command:

dnf install webmin

Once the installation is completed, you should see the following output:

Installing       : webmin-1.930-1.noarch                                                       2/2 
Running scriptlet: webmin-1.930-1.noarch                                                       2/2 
Webmin install complete. You can now login to https://centos8:10000/
as root with your root password.

Access Webmin in Browser

By default, Webmin listens on port 10000. So you will need to open the Webmin port in firewalld. You can do it with the following command:

firewall-cmd --zone=public --add-port=10000/tcp --permanent
 firewall-cmd --reload

Now, open your web browser and type the URL https://your-server-ip:10000. You will be redirected to the following page:

Provide your root user, password and click on the Sign in button. You should see the Webmin dashboard in the following page:

From here, you can configure and manage your CentOS 8 server easily.Advertisements

Conclusion

Congratulations! you have successfully installed Webmin on CentOS 8 server. You can now easily install LAMP/LEMP server, FTP server and hosting your website easily through the Webmin web interface.

How to connect Codeigniter with MSSQL (SQL Server)

$active_group = ‘my_mssql’;
$active_record = TRUE;

$db[‘my_mssql’][‘hostname’] = ‘Driver={SQL Server Native Client 11.0};Server=Host\Instance;Database=queue_sys;’;
$db[‘my_mssql’][‘username’] = ‘wow_queue’;
$db[‘my_mssql’][‘password’] = ‘wow12345’;
$db[‘my_mssql’][‘database’] = ”;
$db[‘my_mssql’][‘dbdriver’] = ‘odbc’;
$db[‘my_mssql’][‘dbprefix’] = ”;
$db[‘my_mssql’][‘pconnect’] = FALSE;
$db[‘my_mssql’][‘db_debug’] = TRUE;
$db[‘my_mssql’][‘cache_on’] = FALSE;
$db[‘my_mssql’][‘cachedir’] = ”;
$db[‘my_mssql’][‘char_set’] = ‘utf8’;
$db[‘my_mssql’][‘dbcollat’] = ‘utf8_general_ci’;
$db[‘my_mssql’][‘swap_pre’] = ”;
$db[‘my_mssql’][‘autoinit’] = TRUE;
$db[‘my_mssql’][‘stricton’] = FALSE;

Note:
SQL Server Native Client 11.0 or SQL Server Native Client 10.0, just play with both settings.
Server=xx.xx.xx.x usually is in the format Server=Host\Instance

 

A Simple Template for Post Formats



>
’;
echo the_title();
echo ‘

’;
echo the_content();
}
elseif ( has_post_format( ‘gallery’ )) {
echo ‘

’;
echo the_title();
echo ‘

’;
echo the_content();
}

elseif ( has_post_format( ‘image’ )) {
echo ‘

’; echo the_title(); echo ‘

’; echo the_post_thumbnail(‘image-format’); echo the_content();}
elseif ( has_post_format( ‘link’ )) {
echo ‘

’; echo the_title(); echo ‘

’; echo the_content();}
elseif ( has_post_format( ‘quote’ )) {
echo the_content();}
elseif ( has_post_format( ‘status’ )) {
echo the_content();}
elseif ( has_post_format( ‘video’ )) {
echo ‘

’; echo the_title(); echo ‘

’; echo the_content();}
elseif ( has_post_format( ‘audio’ )) {
echo ‘

’; echo the_title(); echo ‘

’; echo the_content();}
else {
echo ‘

’; echo the_title(); echo ‘

’; echo the_content();}
?>




.htaccess File

# invoke rewrite engine
RewriteEngine On
RewriteBase /

Options -Indexes

Options -MultiViews

# Redirect to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# Prevent scraping from archive for free demo
RewriteCond %{HTTP_USER_AGENT} (ia_archiver) [NC]
RewriteRule . – [F,L]

# redirect all extension to html
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.shtml$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.phtml$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.htm$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.php$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.aspx$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.asp$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.jsp$ $1.html [L,NC,R=301]

# Add a trailing slash (/) to a URL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.[A-Za-z0-9]*$
RewriteRule .*[^/]$ %{REQUEST_URI}/ [L,R=301]

# Create pretty URLs
RewriteRule ^([^/]+)/$ $1.html
RewriteRule ^([^/]+)/([^/]+)/$ $1/$2.html
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3.html
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4.html
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4/$5.html
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4/$5/$6.html
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ $1/$2/$3/$4/$5/$6/$7.html

RewriteRule ^index.html$ / [L,R=301]

Free Web Hosting