Hosting Server Related

CHANGE TIME ZONE

  1. Edit php.ini file (/Applications/XAMPP/xamppfiles/etc/php.ini if you use XAMPP in MacOS)

Change:

date.timezone=Europe/Berlin

to:

date.timezone=America/Chicago

2. Restart server

This is optional but recommend for any site that requires user login

This specifically apply to:

  • CentOS 7

  1. Follow the instruction in this website to install and enable ssl: http://wiki.centos.org/HowTos/Https#head-35299da4f7078eeba5f5f62b0222acc8c5f2db5f

Ignore Step 3 in the tutorial above

2. Create /etc/httpd/conf.d/oe.conf (same name as the folder contain Open Enventory, in this case /var/www/html/oe)

In Terminal, type:

sudo vi /etc/httpd/conf.d/oe.conf

Add the content below:

NameVirtualHost *:80
<VirtualHost *:80>
    ServerName your_url.net
    DocumentRoot /var/www/html/oe
    Redirect permanent / https://your_url.net
</VirtualHost>

NameVirtualHost *:443
<VirtualHost *:443>
    SSLEngine on
    SSLCertificateFile /etc/pki/tls/certs/ca.crt
    SSLCertificateKeyFile /etc/pki/tls/private/ca.key
    <Directory /var/www/html/oe>
        AllowOverride All
    </Directory>
    DocumentRoot /var/www/html/oe
    ServerName your_url.net
</VirtualHost>

All of these below info (highlighted in red can be change to match specific ip address as well as document location:

  • ServerName your_url.net

  • DocumentRoot /var/www/html/oe

  • Redirect permanent / https://romo.ddns.net/

2. Restart apache service, in Terminal:

sudo systemctl restart httpd.service

SETTING UP CRONTAB TO AUTOMATICALLY BACKUP YOUR DATABASE

This is optional but recommend for auto back up the OE database as well as the user’s info and password

This specifically apply to: CentOS 7 (Apache version: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.5.25 PHP version: 5.5.25 MySQL server version: 5.5.41-MariaDB)

  1. Set up sshpass to automatically pass the password. Note: this is not ultrasafe but it is simple. Check out this link: http://www.server-world.info/en/note?os=CentOS_7&p=ssh&f=7 (only need to follow how to install, step 1)

  2. Go into Terminal in your server and log in as root user (type: “su” and then password at the command line

Note: you can do the rest of the command lines below with prefix “sudo your-command-here” if you don’t want to log in as root

3. At the command line, type:

crontab –e

4. When the file is open, insert the following. Note: everything is red can be changed to match specific details. -$(date +\%Y\%m\%d): is used to set automatic date

#This is to back up the Romo's OE database into home/khoi/OEbackup, every day at 00:05 am
5 0 * * * mysqldump -u root –pyour-password romo > /home/khoi/OEbackup/romo-backup-`date +"%Y%m%d"`.sql

#This is to back up the user table in mysql in order to save users' password, every day at 00:10 am
10 0 * * * mysqldump -u root -pyour-password mysql user > /home/khoi/OEbackup/romo-backup-user`date +"%Y%m%d"`.sql

#This is to copy the back up file to External harddrive, every day at 00:15 am
15 0 * * * sshpass -p your-password rsync -ave ssh --ignore-existing /home/khoi/OEbackup/ daniel@romomacpro.ddns.net:/Users/daniel/Documents/OEbackup/

#This is to delete the file every month
0 0 * * */4 rm -r /home/khoi/OEbackup/romo-backup-*.sql

5. More example of crontab can be read here:

OPTIMIZING CENTOS 7 PERFORMANCE

IP BLOCKING FOR SECURITY ENHANCEMENT ON CENTOS 7 SERVER

This guide to use access_log to find out some high frequent access ip and then check them manually and form a block ip if necessary

Find IP address with the most access

  1. Specifically, ssh into the server and then log in as root user

  2. Use following command:

cat /var/log/httpd/access_log | awk '{print $1}' | sort -n | uniq -c | sort -nr | head -20

change “-20” to “-xx” with “xx” is the number of result. This is sort from most to least access request

4. Google any ip lookup website and check these IPs(e.g: https://whatismyipaddress.com/ip-lookup). If find any suspicious ones, you can add a rule to block those ip network address by the next step

Setting up rule to block ip network.

Follow this guide: https://www.getpagespeed.com/server-setup/security/centos-7-ban-bad-ips-and-networks-with-firewalld

Finding info about the network list

  1. Specifically using this command (after ssh into the server and then log in as root)

To list the IP sets known to firewalld in the permanent environment, use the following command as root:

firewall-cmd --permanent --get-ipsets

3. To get more information about the IP set, use the following command as root: (in the example below, “test” is the name of ipsets you got from the above command

firewall-cmd --permanent --info-ipset=test

Or:

To see the extended entries list of the IP set, use the following command as root:

firewall-cmd --permanent --ipset=test --get-entries

To block IP from a whole country

  1. Follow this guide:

FREEING DISK SPACE IN CENTOS 7

See these references:

ADVANCE FILE AND FOLDER PERMISSION/OWNERSHIP SETTING IN CENTOS 7

See the following resources:

Last updated