Full VPS Setup on CentOS
11-08-2015, 02:56 AM
(This post was last modified: 11-08-2015, 04:03 AM by pinguy.)
This isn't as detailed as my Ubuntu Guide, but will you get you up and running with CentOS and will get you familiar with the OS and how it works.
To start with install CentOS 6/7. Once it's installed use this to login. Replacing "IP" with the server IP.
then enter your password. To change the password run:
Next thing to do is install Sentora.
The script is pretty straightforward. Just make sure you pick Phoenix/Arizona/Mountain Standard Time so you don't have issues with daylight saving.
When it asks for "Enter the sub-domain you want to access Sentora panel"
Enter: Sub.YourDomain.com
Ideally the sub should be setup before you run the script, but can be done afterwards. The sub will be the address used to enter Sentora panel.
Once the script finishes do not reboot (but make note of the passwords and save them).
Next run this:
This will install XCache that will speed up page load times, htop an interactive process viewer and nano a text editor.
The next part is to edit the php.ini.
Change these values to what you want them. If you are going to use phpMyAdmin to upload a database make sure upload_max_filesize is larger than your database:
memory_limit should be about quarter of your total memory. So if your server has 1GB give it 256M, for 512M give it 128M.
F3 will save the file and Ctrl+X will exit nano.
Next we need to edit Apache.
Look for ServerName http://www.example.com:80
And enter your web address. If it has # at the beging of it remove it.
Save the file and reboot Apache.
Next modify MySQL so it doesn't use to much memory.
And add this just underneath [mysqld]
Then save the file and reboot MySQL.
To better tune MySQL look here: http://www.joe0.com/2013/09/05/how-to-tu...tosredhat/
To update/repair all the MySQL tables run:
Daily backups is broken in Sentora. Running it makes multiple backups filling up the disc very quickly.
To avoid having any issues with this remove all the backup modules.
To manually backup your sites to a zip for easy transfer run:
To setup a Cron job for a weekly backup run:
And add this to the file:
F3 will save the file and Ctrl+X will exit nano.
Next set permissions and make it executable.
You could also add your databases to the weekly backup by adding this to the backup cron:
For cron to work you will need to edit crontab.
To do this run:
Crontab – Quick Reference
To setup the server to do automatic updates run:
Add this to the file:
This will pervent MySQL and the kernel from updating.
Next add your email to:
look for MAILTO=
Next start the service:
Lastly do some clean up
Now just reboot the server. Once rebooted log into sentora by entering the server IP into a web browser. You should of copied the login details earlier when the sentora script finished running.
To see if you are getting the speeds your VPS providers advertise run:
This will tell you what connection you have.
You can run these command to install Speedtest.net. Doing this isn't an accurate test. There's too many variables in play for it to be accurate. But it will give you a rough idea of what speeds you are getting.
To upgrade to PHP version 5.5 run:
Doing this will break suhosin and XCache.
To repair run:
Suhosin:
XCache:
Then add this to php.ini
To start with install CentOS 6/7. Once it's installed use this to login. Replacing "IP" with the server IP.
Code:
ssh -l root "IP"then enter your password. To change the password run:
Code:
passwdNext thing to do is install Sentora.
The script is pretty straightforward. Just make sure you pick Phoenix/Arizona/Mountain Standard Time so you don't have issues with daylight saving.
When it asks for "Enter the sub-domain you want to access Sentora panel"
Enter: Sub.YourDomain.com
Ideally the sub should be setup before you run the script, but can be done afterwards. The sub will be the address used to enter Sentora panel.
Code:
bash <(curl -L -Ss http://sentora.org/install)Once the script finishes do not reboot (but make note of the passwords and save them).
Next run this:
Code:
yum install nano htop php-xcache xcache-adminThis will install XCache that will speed up page load times, htop an interactive process viewer and nano a text editor.
The next part is to edit the php.ini.
Code:
nano /etc/php.iniChange these values to what you want them. If you are going to use phpMyAdmin to upload a database make sure upload_max_filesize is larger than your database:
Code:
post_max_size = 8M
upload_max_filesize = 2M
memory_limit = 64Mmemory_limit should be about quarter of your total memory. So if your server has 1GB give it 256M, for 512M give it 128M.
F3 will save the file and Ctrl+X will exit nano.
Next we need to edit Apache.
Code:
nano /etc/httpd/conf/httpd.confLook for ServerName http://www.example.com:80
And enter your web address. If it has # at the beging of it remove it.
Save the file and reboot Apache.
Code:
service httpd restartNext modify MySQL so it doesn't use to much memory.
Code:
nano /etc/my.cnfAnd add this just underneath [mysqld]
Code:
#MyISAM
key_buffer_size = 16M #May need to be higher. Higher number more Memory usage
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 2M
myisam_sort_buffer_size = 2M
join_buffer_size = 2M
max_connections = 60 #If you have issues with simultaneous connections increase this value
query_cache_type = 1
query_cache_size = 16M #May need to be higher.
query_cache_limit = 8M
thread_stack = 128K
thread_cache_size = 16M
table_definition_cache = 400
table_open_cache = 2000
table_cache = 2000
max_heap_table_size = 16M #May need to be higher
tmp_table_size = 16M #Keep equal to max_heap_table_size
connect-timeout = 20
low_priority_updates = 1
concurrent_insert = ALWAYSThen save the file and reboot MySQL.
To better tune MySQL look here: http://www.joe0.com/2013/09/05/how-to-tu...tosredhat/
Code:
service mysqld restartTo update/repair all the MySQL tables run:
Code:
mysqlcheck -o --all-databases --user=root --password=*MySQL Password*Daily backups is broken in Sentora. Running it makes multiple backups filling up the disc very quickly.
To avoid having any issues with this remove all the backup modules.
Code:
rm -rf /etc/sentora/panel/modules/backup_admin/hooks/*To manually backup your sites to a zip for easy transfer run:
Code:
zip -r /var/sentora/hostdata/zadmin/backup.zip /var/sentora/hostdata/zadmin/public_htmlTo setup a Cron job for a weekly backup run:
Code:
nano /etc/cron.weekly/backupAnd add this to the file:
Code:
#!/bin/sh
rm /var/sentora/hostdata/zadmin/backup.zip
zip -r /var/sentora/hostdata/zadmin/backup.zip /var/sentora/hostdata/zadmin/public_html
exitF3 will save the file and Ctrl+X will exit nano.
Next set permissions and make it executable.
Code:
sudo chmod +x /etc/cron.weekly/backup
sudo chmod 755 /etc/cron.weekly/backupYou could also add your databases to the weekly backup by adding this to the backup cron:
Code:
mysqldump -u [username] –p[password with no space, so it will start with -p] [database_name] > /folder/to/save/[dump_file.sql]For cron to work you will need to edit crontab.
To do this run:
Code:
nano /etc/crontabCode:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
15 4 * * * root run-parts /etc/cron.daily
30 8 * * 0 root run-parts /etc/cron.weekly
45 12 1 * * root run-parts /etc/cron.monthlyCrontab – Quick Reference
Code:
sudo chmod +x /etc/crontab
sudo chmod 755 /etc/crontabCode:
service crond restartCode:
chkconfig crond onTo setup the server to do automatic updates run:
Code:
yum -y install yum-cronCode:
nano /etc/yum.confAdd this to the file:
Code:
exclude=kernel* mysql*This will pervent MySQL and the kernel from updating.
Next add your email to:
Code:
nano /etc/sysconfig/yum-cronlook for MAILTO=
Next start the service:
Code:
chkconfig yum-cron on
service yum-cron startLastly do some clean up
Code:
yum clean allNow just reboot the server. Once rebooted log into sentora by entering the server IP into a web browser. You should of copied the login details earlier when the sentora script finished running.
To see if you are getting the speeds your VPS providers advertise run:
Code:
ethtool eth0 | grep -i speedThis will tell you what connection you have.
You can run these command to install Speedtest.net. Doing this isn't an accurate test. There's too many variables in play for it to be accurate. But it will give you a rough idea of what speeds you are getting.
Code:
wget -O speedtest-cli.py https://github.com/sivel/speedtest-cli/raw/master/speedtest_cli.py
chmod a+rx speedtest-cli.py
sudo mv speedtest-cli.py /usr/local/bin/speedtest
sudo chown root:root /usr/local/bin/speedtest
speedtestTo upgrade to PHP version 5.5 run:
Code:
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpmCode:
yum install yum-plugin-replace
yum replace php-common --replace-with=php55w-commonDoing this will break suhosin and XCache.
To repair run:
Suhosin:
Code:
wget https://github.com/stefanesser/suhosin/archive/master.zip
unzip master.zip
cd suhosin-master
phpize
./configure
make
make install
echo 'extension=suhosin.so' > /etc/php.d/suhosin.ini
echo 'suhosin.executor.include.whitelist = upload://' > /etc/php.d/suhosin.iniXCache:
Code:
wget http://xcache.lighttpd.net/pub/Releases/3.1.0/xcache-3.1.0.tar.gz
tar xvfz xcache-3.1.0.tar.gz
cd xcache-3.1.0
phpize
./configure --enable-xcache
make
make installThen add this to php.ini
Code:
nano /etc/php.iniCode:
[xcache-common]
zend_extension = /usr/lib64/php/modules/xcache.so
extension=xcache.so
[xcache]
; Change xcache.size to tune the size of the opcode cache
xcache.size = 24M
xcache.shm_scheme = "mmap"
xcache.count = 2
xcache.slots = 8K
xcache.ttl = 0
xcache.gc_interval = 0
; Change xcache.var_size to adjust the size of variable cache
xcache.var_size = 8M
xcache.var_count = 1
xcache.var_slots = 8K
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300
xcache.test = Off
xcache.readonly_protection = On
xcache.mmap_path = "/tmp/xcache"
xcache.coredump_directory = ""
xcache.cacher = On
xcache.stat = On
xcache.optimizer = Off
[xcache.coverager]
xcache.coverager = On
xcache.coveragedump_directory = ""Code:
service httpd restart


