Ubuntu 13.10 x64 with emoncms

Install Ubuntu 13.10 x64 Server version with default settings and try to follow Emoncms docs. Didn't work that well, right? Well why don't you follow these instructions instead.



# Login and switch to root with sudo
sudo su -

# Allow root logins
passwd root

# Fix silly default sudo config
sed -i.bak -e's|ALL=(ALL:ALL) ALL|ALL=(ALL:ALL) NOPASSWD:ALL|g' /etc/sudoers

# Install OpenSSH, MySQL, Apache, PHP etc.
apt-get update
apt-get -y install openssh-server mysql-server apache2 apache2-mpm-prefork libapache2-mod-php5 \
                   php5 php5-json php5-mysql php5-curl git build-essential \
                   open-vm-tools joe curl wget lftp screen

# Update system and reboot
apt-get -y dist-upgrade
reboot


# Login as root after boot

# Install timestore, it's something way faster than mysql for storing our readings
# There's currently no packaged version available so we need to compile and install
# it ourselves. Of course install script places files in weird places but so what.
mkdir -p /opt
cd /opt
git clone https://github.com/TrystanLea/timestore
cd timestore
sh install


# Enable Apache mod_rewrite
a2enmod rewrite

# Next is my favorite from emoncms install doc. Whoever wrote that blindly assumes
# that every Linux install with Apache has .htaccess override control on line 7
# of 000-default. It doesn't even tell what this change does, just to edit line 7.
#
# If you do this step incorrectly you end up with weird problems far later in
# setup process. Googling those symptoms shows there's several people that suffer
# from this goof and not even devs themselves seem to know how to help. Whee...
#
# What you really should do is append this to /etc/apache2/apache2.conf
#<directory /var/www/emoncms/>
#        Options Indexes FollowSymLinks
#        AllowOverride All
#        Require all granted
#</directory>

# And here's how to do it
cat <<'_EOF_'>>/etc/apache2/apache2.conf
<directory /var/www/emoncms/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</directory>
_EOF_

# Prevent indexing of server
cat <<'_EOF_'>>/var/www/robots.txt
User-agent: *
Disallow: /
_EOF_

# Switch to blank front page
rm -f /var/www/index.html
touch /var/www/index.html

# Set timezone to prevent pointless timezone warnings from php
sed -i /etc/php5/apache2/php.ini \
    -e 's|^.*date.timezone =.*|date.timezone = Europe/Helsinki;|g'

# Restart apache2
/etc/init.d/apache2 restart


# Finally we can install emoncms
cd /var/www
git clone https://github.com/emoncms/emoncms.git

# Next we create MySQL database, this part of documentation is broken as well
# since it completely omits part of granting apache process access to database.
mysql -u root -e"CREATE DATABASE emoncms;GRANT ALL PRIVILEGES on emoncms.* TO 'emoncms'@'localhost' identified by 'mypassword';"

# Config DB connection settings for emoncms
cp default.settings.php settings.php
sed -i settings.php \
    -e 's|$username.*|$username = "emoncms";|g' \
    -e 's|$password.*|$password = "mypassword";|g' \
    -e 's|$database.*|$database = "emoncms";|g' \
    -e 's|$timestore_adminkey.*|$timestore_adminkey = "'$(cat /var/lib/timestore/adminkey.txt)'";|g'

# Fix .htaccess
sed -i .htaccess \
    -e 's|<ifmodule mod_rewrite.c>|#<ifmodule mod_rewrite.c>|g' \
    -e 's|</ifmodule>|#</ifmodule>|g' \
    -e 's|/home/trystan/error.log|/tmp/emoncms-php-error.log|g'

# Fix bug of applying password length checks against username
sed -i Modules/user/user_model.php \
    -e 's|if (strlen($username) < 4|if (strlen($username) < 1|g'

# Next login over web http://serverip/emoncms/ and register new account
# First account created will be granted admin rights

# Prevent registration of additional accounts
sed -i settings.php \
    -e 's|$allowusersregister.*|$allowusersregister = FALSE;|g'

Now you can continue setting emoncms like you would when using emoncms.org service instead of own install

Comments

  1. This was incredible useful, thought I was the only using 64 bit version of Ubuntu 13.10 and an idiot since I could not figure out why my permalinks were not working. Then there was actually locating the option to turn it on. Thanks man you rock!

    -Chad Buie-

    ReplyDelete
  2. Hi . I'm having issues in this part : git clone https://github.com/TrystanLea/timestore i'm getting this error :Cloning into 'timestore'...
    error: Couldn't resolve host 'github.com' while accessing http://github.com/TrystanLea/timestore/info/refs
    fatal: HTTP request failed .
    I'm not linux expert , can you help me pls

    ReplyDelete

Post a Comment

Got something to say?!