Hosting Server Related

CHANGE TIME ZONE

    1.
    Edit php.ini file (/Applications/XAMPP/xamppfiles/etc/php.ini if you use XAMPP in MacOS)
Change:
1
date.timezone=Europe/Berlin
Copied!
to:
1
date.timezone=America/Chicago
Copied!
2. Restart server

SETTING UP HTTPS (SECURED HTTP) FOR OE (RECOMMENDED)

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:
1
sudo vi /etc/httpd/conf.d/oe.conf
Copied!
Add the content below:
1
NameVirtualHost *:80
2
<VirtualHost *:80>
3
ServerName your_url.net
4
DocumentRoot /var/www/html/oe
5
Redirect permanent / https://your_url.net
6
</VirtualHost>
7
8
NameVirtualHost *:443
9
<VirtualHost *:443>
10
SSLEngine on
11
SSLCertificateFile /etc/pki/tls/certs/ca.crt
12
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
13
<Directory /var/www/html/oe>
14
AllowOverride All
15
</Directory>
16
DocumentRoot /var/www/html/oe
17
ServerName your_url.net
18
</VirtualHost>
Copied!
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:
1
sudo systemctl restart httpd.service
Copied!

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:
1
crontab –e
Copied!
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
1
#This is to back up the Romo's OE database into home/khoi/OEbackup, every day at 00:05 am
2
5 0 * * * mysqldump -u root –pyour-password romo > /home/khoi/OEbackup/romo-backup-`date +"%Y%m%d"`.sql
3
4
#This is to back up the user table in mysql in order to save users' password, every day at 00:10 am
5
10 0 * * * mysqldump -u root -pyour-password mysql user > /home/khoi/OEbackup/romo-backup-user`date +"%Y%m%d"`.sql
6
7
#This is to copy the back up file to External harddrive, every day at 00:15 am
8
15 0 * * * sshpass -p your-password rsync -ave ssh --ignore-existing /home/khoi/OEbackup/ [email protected]:/Users/daniel/Documents/OEbackup/
9
10
#This is to delete the file every month
11
0 0 * * */4 rm -r /home/khoi/OEbackup/romo-backup-*.sql
Copied!
5. More example of crontab can be read here:
Linux Crontab: 15 Awesome Cron Job Examples
The Geek Stuff
Crontab in Linux with 20 Useful Examples to Schedule Jobs
TecAdmin

OPTIMIZING CENTOS 7 PERFORMANCE

Apache2 and php fpm performance optimization — Step-by-step guide
Medium
How to optimize Apache performance on CentOS 7
VPSCheap.NET Blog

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

    2.
    Specifically, ssh into the server and then log in as root user
    3.
    Use following command:
1
cat /var/log/httpd/access_log | awk '{print $1}' | sort -n | uniq -c | sort -nr | head -20
Copied!
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.

Finding info about the network list

    2.
    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:
1
firewall-cmd --permanent --get-ipsets
Copied!
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
1
firewall-cmd --permanent --info-ipset=test
Copied!
Or:
To see the extended entries list of the IP set, use the following command as root:
1
firewall-cmd --permanent --ipset=test --get-entries
Copied!

To block IP from a whole country

    1.
    Follow this guide:
[TOP TIP] firewalld and ipset (country blacklist) | Linode Questions
Linode Cloud Hosting

FREEING DISK SPACE IN CENTOS 7

See these references:
Freeing disk space on your Linux server
How do I clear space on my main system drive on a Linux CentOS system?
Stack Overflow
How to free up space on centos server
Stack Overflow

ADVANCE FILE AND FOLDER PERMISSION/OWNERSHIP SETTING IN CENTOS 7

See the following resources:
Last modified 1yr ago