Tag centos

Changing default SSH port

Tags: , ,

By default, the SSH port is set to 22.
Locate the following line in the file /etc/ssh/sshd_config:
#Port 22

Remove # and change 22 to your desired port number. Though make sure you do not use the ports which are used by other systems ( i.e. 465,993 which are mail ports etc).

Save the changes and close the file. Press Ctrl + O to save. Type Ctrl + X to exit.

To apply the settings, the SSH service needs to be restarted. If you are logged in as a techuser (or your custom created one to replace root), you will need to use the sudo command to perform this action.

sudo systemctl restart sshd

MariaDB/mySQL Increase limits

Tags: , , , , ,

The default open files limit is 1024. This is fine for a few websites, but if you are hosting many websites this should be increased.

1. Login as root via SSH

2. Type : pico /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf

3. Change the lines to:
LimitNOFILE=100000
LimitMEMLOCK=100000

4. Execute :
systemctl daemon-reload
systemctl restart mysql

5. Type: pico /etc/security/limits.conf

Add/Modify the lines so they read:

* soft nofile 1024000
* hard nofile 1024000
* soft nproc 10240
* hard nproc 10240

Save: CTRL O

Quit: CTRL X

6. Type: pico /etc/security/limits.d/90-nproc.conf

Add/Modify the lines so they read:

* soft nofile 1024000
* hard nofile 1024000
* soft nproc 10240
* hard nproc 10240
root soft nproc unlimited

Save: CTRL O

Quit: CTRL X

7. Type: ulimit -Hn 1024000

8. Type: pico /etc/my.cnf

Insert the following:

open_files_limit = 1024000

If you have sections [mysqld] and [mysqld_safe] put the line under both headings.

Save: CTRL O

Quit: CTRL X

9. Type: service mysql restart