Sunday, August 26, 2018

Build a webserver with CentOS 7, MySQL, PHP7.2 and use a existing wildcard SSL Certificate from Windows Server

Build a webserver with CentOS 7, MySQL, PHP7.2 and use a existing wildcard SSL Certificate from Windows Server
A.   Build a CentOS Linux server with minimum setup with developer options. After installed the CentOs, run yum -y update to upate the server to most update version
B.   Install Apache
Install Apache by yum yum install httpd
Start the httpd service systemctl start httpd.service
Let the httpd service start with the system systemctl enable httpd.service
C.   Configure the firewall
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
D.   Install MySQL
Install mysql by yum yum install mariadb-server mariadb
Start the httpd service systemctl start mariadb
Let the httpd service start with the system systemctl enable mariadb.service
Configure the MYSQL sudo mysql_secure_installation

The new password for the “root” of MySQL
E.   Install PHP7.2
     yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm  
yum install yum-utils
yum-config-manager --enable remi-php72
yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
     systemctl restart httpd.service
F.    Install phpMyAdmin
yum -y install phpmyadmin
vi /etc/httpd/conf.d/phpMyAdmin.conf to add the ip or ip range to allow access the phpMyAdmin, following example is added the subnet 192.168.3.0/24 and 192.168.168.0/24

G.  Copy website to following directory in Linux cd /var/www/html by using ftp (install ftp before use the ftp yum install -y ftp)
H.  Import tables to MySQL by using phpMyAdmin
l Launch the phpMyAdmin



l Create the database as the program required, here is “cfweb”

l Click on the “Import” tab to begin import the tables





 

I. Run following command openssl version, if the openssl was installed, the output should like OpenSSL 1.0.2k-fips  26 Jan 2017
J.    Install mod_ssl
Before configure the SSL, run following command to install the SSL module
yum -y install mod_ssl
K.   Export the PFX file from Windows Server
l Click Start, Run, then type “mmc” and hit enter.

l In the leftmost menu, choose “Add/Remove Snap In” under “File”.

l Click “Certificates”, then click “Add”, then OK.



l When the wizard starts, choose “Computer Account”, “Local Computer” and finish out the wizard.




l Once you’re finished, go back to the MMC and expand the “Certificates” node, then the “Personal” node.


l Click on the “Certificates” node under “Personal” and find your certificate in the right pane.




l Right click on the certificate and choose “All Tasks”, then “Export”.

l When the wizard starts, choose “Yes” for exporting the private key, you will also need to set a password and specify a file name and location for the PFX file, e.g. “ssl.pfx” and in c:\temp










l Once the PFX file has been saved, close out the MMC (don’t save the snap-in if it asks).
L.    Enable SSL in CentOS
l Copy the PFX to a directory (e.g. /ssl) under root directory of the Linux server, e.g. use ftp
l In Linux server, change to the directory ssl cd /ssl
l In /ssl directory, run openssl pkcs12 -in ssl.pfx -out ssl.pem
l Copy the ssl.pem to 2 files cp ./ssl.pem ./ssl.crt and cp ./ssl.pem ./ssl.key
l    In ssl.crt file, clear the content out of following
-----BEGIN CERTIFICATE-----  and  -----END CERTIFICATE-----
l    In ssl.key file, clear the content out of following
-----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY-----
l cp ./ssl.crt /etc/pki/tls/certs/ssl.crt
l cp ./ssl.key /etc/pki/tls/private/ssl.key
l vi /etc/httpd/conf.d/ssl.conf
l edit the two line in ssl.conf like this
  SSLCertificateFile /etc/pki/tls/certs/ssl.crt
  SSLCertificateKeyFile /etc/pki/tls/private/ssl.key
l systemctl restart httpd





Friday, May 4, 2018

Solve "all com.android.support libraries must use the exact same version specification"

Add following code to app build.gradle:

configurations.all{
     resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.android.support'){
                   if (!requested.name.startsWith("mutlidex")){
                         details.useVersion '25.0.1'
                    }
            }
       }
}

Tuesday, January 9, 2018

Wordpress SMTP plugin Permission denied

If you see an error like SMTP -> ERROR: Failed to connect to server: Permission denied (13), you may be running into SELinux preventing PHP or the web server from sending email. This is particularly likely on RedHat / Fedora / Centos. Using the getsebool command we can check if the httpd daemon is allowed to make a connection over the network and send an email:
getsebool httpd_can_sendmail
getsebool httpd_can_network_connect
This command will return a boolean on or off. If it's off, we can turn it on:

sudo setsebool -P httpd_can_sendmail 1
sudo setsebool -P httpd_can_network_connect 1

Sunday, December 31, 2017

Add a USB drive as the datastore of ESXi 6.5

  1. Connect to the ESXi host with SSH
  2. Stop the USB arbitrator service. This service is used to passthrough USB device from an ESX/ESXi host to a virtual machine. (When disabling it, you can no longer passthrough USB devices to VMs)
    ~ # /etc/init.d/usbarbitrator stop
  3. (optional) Use this command to permanently disable the USB arbitrator service after reboot.
    ~ # chkconfig usbarbitrator off
  4. Plug in the USB device to your ESXi host. While connecting the USB device you can either watch /var/log/vmkernel.log to identify the device name or identify it within /dev/disks.
    Devices are either named mpx.vmhbaXX or with an naa.X number.
    ~ # ls /dev/disks/
  5. Write a GPT label to the device (Assuming that the Device ID is naa.5000000000000001)
    ~ # partedUtil mklabel /dev/disks/naa.5000000000000001 gpt
  6. To create a partition you need to know the start sector, end sector, which depends on the device size and the GUID.
    The start sector is always 2048
    The GUID for VMFS is AA31E02A400F11DB9590000C2911D1B8
    The end sector can be calculated with the following formula (Use the numbers from getptbl):
    ~ # partedUtil getptbl /dev/disks/naa.5000000000000001
    gpt
    15566 255 63 250069680
    15566 * 255 * 63 - 1 = 250067789
    You can also calculate the end sector with the following command:
    ~ # eval expr $(partedUtil getptbl /dev/disks/naa.5000000000000001 | tail -1 | awk '{print $1 " \\* " $2 " \\* " $3}') - 1
    250067789
  7. Create the VMFS partition (Replace with your end sector)
    ~ # partedUtil setptbl /dev/disks/naa.5000000000000001 gpt "1 2048 250067789 AA31E02A400F11DB9590000C2911D1B8 0"
  8. Format the partition with VMFS5 or VMFS6
    # VMFS v5
    ~ # vmkfstools -C vmfs5 -S USB-Datastore /dev/disks/naa.5000000000000001:1
    
    # VMFS v6
    ~ # vmkfstools -C vmfs6 -S USB-Datastore /dev/disks/naa.5000000000000001:1
The USB-Datastore should now appear in your datastores view.
vmfs6-usb-datastore-esxi65
This is how your command output should look like:
[root@esx4:~] partedUtil mklabel /dev/disks/naa.5000000000000001 gpt
[root@esx4:~] eval expr $(partedUtil getptbl /dev/disks/naa.5000000000000001 | tail -1 | awk '{print $1 " \\* " $2 " \\* " $3}') - 1
250067789
[root@esx4:~] partedUtil setptbl /dev/disks/naa.5000000000000001 gpt "1 2048 250067789 AA31E02A400F11DB9590000C2911D1B8 0"
gpt
0 0 0 0
1 2048 250067789 AA31E02A400F11DB9590000C2911D1B8 0
[root@esx4:~] vmkfstools -C vmfs6 -S USB-Datastore /dev/disks/naa.5000000000000001:1
create fs deviceName:'/dev/disks/naa.5000000000000001:1', fsShortName:'vmfs6', fsName:'USB-Datastore'
deviceFullPath:/dev/disks/naa.5000000000000001:1 deviceFile:naa.5000000000000001:1
ATS on device /dev/disks/naa.5000000000000001:1: not supported
.
Checking if remote hosts are using this device as a valid file system. This may take a few seconds...
Scanning for VMFS-3/VMFS-5 host activity (512 bytes/HB, 2048 HBs).
Creating vmfs6 file system on "naa.5000000000000001:1" with blockSize 1048576, unmapGranularity 1048576, unmapPriority default and volume label "USB-Datastore".
Successfully created new volume: 583b0efb-33b7ba1e-57e7-001fc69b9659

Migrate Microsoft Edge bookmark from old PC to new PC

A. To Backup Favorites from Microsoft Edge 
1. Open File Explorer, copy and paste the folder location:  %LocalAppData%\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\AC\MicrosoftEdge\User\Default in the address bar of File Explorer, and press Enter. 
2. Copy the DataStore folder below to where you like as your backup. (see screenshot below)
B. To Restore Favorites in Microsoft Edge 
1. Close Microsoft Edge if open.
2. Open File Explorer, copy and paste the folder location: %LocalAppData%\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\AC\MicrosoftEdge\User\Default in the address bar, and press Enter. 
3. Copy the backed up DataStore folder from step 2 into the Default folder below. (see screenshot above)
4. If prompted, click/tap on Replace the files in the destination.








Prevent or Prohibit Server Drives From Being Visible to Users

  To make changes to this policy for one of the seven default values: Start the Microsoft Management Console. On the Console menu, click  Ad...