12.17. Linux flavours¶
12.17.1. Common administrative commands¶
Ubuntu |
CentOS 6.5 |
|
---|---|---|
System |
||
Heritage |
Debian |
Red Hat Enterprise Linux |
Package management |
|
|
General system update |
|
|
Package type |
|
|
Extra security |
Nothing complex by default |
SELinux; file permissions must be set with |
Autostarting daemons at boot |
Usually happens automatically |
Usually need to configure with |
Which OS version am I running? |
lsb_release -a uname -a |
cat /etc/centos-release uname -a |
Python |
||
Default Python versions (CamCOPS requires 3.4) |
2.7, 3.4 |
2.6 |
Apache |
||
Apache main configuration file |
Usually |
Usually |
Apache SSL configuration file |
Usually |
Usually |
Granting access in Apache config file |
Apache 2.4:
Require all granted |
Apache 2.2:
Order allow,deny Allow from all |
Default Apache system user |
|
|
Default SSL certificate location |
|
|
Default Apache log directory |
|
|
Restarting Apache |
|
|
supervisord |
||
supervisord configuration file |
Usually |
Usually |
Restarting supervisord |
|
|
MySQL |
||
Default MySQL configuration file |
|
|
Restarting MySQL |
|
|
Default MySQL log |
|
|
CamCOPS packages |
||
Installation |
|
|
Removal |
|
|
12.17.2. Installing CamCOPS prerequisites under CentOS 6.5¶
Ensure additional repositories are in use:
# RPMForge: see http://www.tecmint.com/install-and-enable-rpmforge-repository-in-rhel-centos-6-5-4/
# Use "cat /etc/centos-release" to see CentOS version; use "uname -a" to detect 32-bit/64-bit version.
# For example, for 64-bit CentOS 6.5:
sudo rpm -Uvh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
# EPEL: see http://fedoraproject.org/wiki/EPEL
# For example:
sudo rpm -Uvh https://anorien.csc.warwick.ac.uk/mirrors/epel/6/i386/epel-release-6-8.noarch.rpm
# Something providing Python 3 in package form (see http://stackoverflow.com/questions/8087184):
sudo yum install https://centos6.iuscommunity.org/ius-release.rpm
# We need MySQL 5.5 or higher: http://www.webtatic.com/packages/mysql55/
sudo rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
Potential prerequisites for what follows:
sudo yum install blas-devel lapack-devel libffi-devel libpng-devel links nano openssl-devel python-devel
Install Python 3 (which comes with pip and setuptools). Note: CentOS 6.5 (December 2013) provides Python 2.6 (2009). You can’t just replace it, because its system scripts need Python 2.6. CentOS is based on Red Hat Enterprise Linux. Fedora 14 (another Red Hat derivative) moved to Python 2.7 in 2010. CamCOPS needs Python 3 (e.g. 3.4).
# For Python 3.4L
sudo yum install python34u
# For Python 3.5 (with some other helpful things):
sudo yum install python35u python35u-pip libxml2-devel libxslt-devel python35u-devel gcc
# Test:
python3 --version
pip3 --version
Install MySQL:
sudo yum install mysql55 mysql55-server mysql-devel
Install Apache:
sudo yum install httpd httpd-devel mod_ssl
Ensure you have Supervisor:
On CentOS, the default version (via yum installation) is of supervisord==2.1 (as reported by pip freeze), which is too old for the [include] directive (which came in with version 3.0). To upgrade:
pip install requests[security] # because Python 2.6 doesn't have SSL otherwise pip install supervisor==3.2.0 # Don't copy the next line blindly. Do you have an old /etc/supervisord.conf that you want to keep? echo_supervisord_conf > /etc/supervisord.conf # make a new blank config
Then add these lines to /etc/supervisord.conf:
[include] files = /etc/supervisor/conf.d/*.conf
Then ensure supervisord restarts on boot. On Ubuntu, this is automatic. On CentOS, run
sudo chkconfig --add supervisord sudo chkconfig supervisord on # default runlevels (--level 2345) are fine
12.17.3. Setting up MySQL under Linux¶
Under Ubuntu, if you are happy to leave the data files at their default location, skip this step. Check/edit the MySQL configuration (see table above for filenames). See Getting Started with MySQL. In particular:
datadir should point to your database files (default often /var/lib/mysql, but /srv/mysql is one alternative).
Other options are explained here.
If you create a blank directory (such as /srv/mysql), you will need to use the mysql_install_db tool; see Postinstallation Setup and Testing; an example command is
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/srv/mysql
Manual start: sudo /usr/bin/mysqld_safe –user=mysql &. Manual stop: sudo mysqladmin shutdown.
Service start/stop: see table above.
If it starts manually but not as a service (in a manner that depends on your data directory), you have a challenging problem; an option is to return to the default data directory!
To log in prior to securing the database: mysql.
See also the CentOS MySQL installation guide.
Default logfile: /var/log/mysqld.log or /var/log/mysql/…
Secure your MySQL installation by running mysql_secure_installation.
Login after securing: mysql -u root -p.
Similar username/password requirements now apply to manual shutdowns.
Ensure that the max_allowed_packet parameter is large enough.
This parameter needs to be set large enough that the largest binary large objects (BLOBs) can be uploaded. CamCOPS BLOBs are mostly photographs from tablets. A high-end tablet in 2014 might have an 8 megapixel (MP) camera, with each pixel taking 3 bytes, i.e. 24 Mb. Furthermore, the transfer takes more space thanks to somewhat inefficient encoding. The MySQL server default value is just 1 Mb 1.
You must set this parameter for the server, and for the mysqldump tool.
A suggested value is 32 Mb. Edit my.cnf to include max_allowed_packet values in the [mysqld] and [mysqldump] sections (creating them if necessary).
Similar editing of the [client] section of my.cnf is unnecessary, firstly because some other MySQL clients may not recognize the option and might choke on it, and secondly because CamCOPS uses MySQLdb (MySQL-Python), which uses the MySQL C API, which has a default limit of 1 Gb 2.
Set some other MySQL parameters for TEXT-heavy tables; see Troubleshooting: Row size too large.
Thus, edit my.cnf to include the following:
[mysqld] max_allowed_packet = 32M innodb_strict_mode = 1 innodb_file_per_table = 1 innodb_file_format = Barracuda # Only for MySQL prior to 5.7.5 (http://dev.mysql.com/doc/relnotes/mysql/5.6/en/news-5-6-20.html): # innodb_log_file_size = 512M [mysqldump] max_allowed_packet = 32M
Ensure MySQL is running as a service (as above).
Create the CamCOPS database. See create a database.
Footnotes