Skip to content

Commit

Permalink
setup guide: remove dio,. install php extensions correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
glynhudson committed Jan 18, 2018
1 parent 6ebae58 commit a90107e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 36 deletions.
49 changes: 22 additions & 27 deletions docs/LinuxInstall.md
Expand Up @@ -11,7 +11,7 @@ You may need to start by updating the system repositories
on 14.04:

sudo apt-get install apache2 mysql-server mysql-client php5 libapache2-mod-php5 php5-mysql php5-curl php-pear php5-dev php5-mcrypt php5-json git-core redis-server build-essential ufw ntp

on 16.04:

`sudo apt-get install apache2 mysql-server mysql-client php libapache2-mod-php php-mysql php-curl php-pear php-dev php-mcrypt php-json git-core redis-server build-essential ufw ntp`
Expand All @@ -21,26 +21,22 @@ on 16.04:
*Not essential, required for mail sending e.g. password recovery*

sudo pear channel-discover pear.swiftmailer.org
sudo pecl install swift/swift dio-0.0.9 redis
sudo pecl install swift/swift redis

**If running PHP5:** Add pecl modules to php5 config

sudo sh -c 'echo "extension=dio.so" > /etc/php5/apache2/conf.d/20-dio.ini'
sudo sh -c 'echo "extension=dio.so" > /etc/php5/cli/conf.d/20-dio.ini'
sudo sh -c 'echo "extension=redis.so" > /etc/php5/apache2/conf.d/20-redis.ini'
sudo sh -c 'echo "extension=redis.so" > /etc/php5/cli/conf.d/20-redis.ini'


printf "extension=redis.so" | sudo tee /etc/php5/mods-available/redis.ini 1>&2
sudo php5enmod redis

**If running PHP7:** Add pecl modules to php7 config

sudo sh -c 'echo "extension=dio.so" > /etc/php/7.0/apache2/conf.d/20-dio.ini'
sudo sh -c 'echo "extension=dio.so" > /etc/php/7.0/cli/conf.d/20-dio.ini'
sudo sh -c 'echo "extension=redis.so" > /etc/php/7.0/apache2/conf.d/20-redis.ini'
sudo sh -c 'echo "extension=redis.so" > /etc/php/7.0/cli/conf.d/20-redis.ini'

printf "extension=redis.so" | sudo tee /etc/php/7.0/mods-available/redis.ini 1>&2
sudo phpenmod redis

### Configure Apache

Emoncms uses a front controller to route requests, modrewrite needs to be configured:

```
sudo a2enmod rewrite
sudo sh -c "echo '<Directory /var/www/html/emoncms>' >> /etc/apache2/sites-available/emoncms.conf"
Expand All @@ -54,7 +50,7 @@ Emoncms uses a front controller to route requests, modrewrite needs to be config
sudo a2ensite emoncms
sudo service apache2 reload
```

## Install Emoncms

Git is a source code management and revision control system but at this stage we use it to just download and update the emoncms application.
Expand All @@ -76,12 +72,12 @@ Download emoncms using git:
**You may want to install one of the other branches of emoncms here, perhaps to try out a new feature set not yet available in the master branch. See the branch list and descriptions on the [start page](https://github.com/emoncms/emoncms)**

git clone -b stable https://github.com/emoncms/emoncms.git

Once installed you can pull in updates with:

cd /var/www/html/emoncms
git pull

## Create a MYSQL database

mysql -u root -p
Expand All @@ -90,7 +86,7 @@ Enter the mysql password that you set above.
Then enter the sql to create a database:

mysql> CREATE DATABASE emoncms DEFAULT CHARACTER SET utf8;

Then add a user for emoncms and give it permissions on the new database (think of a nice long password):

mysql> CREATE USER 'emoncms'@'localhost' IDENTIFIED BY 'YOUR_SECURE_PASSWORD_HERE';
Expand All @@ -100,7 +96,7 @@ Then add a user for emoncms and give it permissions on the new database (think o
Exit mysql by:

mysql> exit

### Create data repositories for emoncms feed engine's

sudo mkdir /var/lib/phpfiwa
Expand Down Expand Up @@ -131,17 +127,17 @@ Update your database settings to use your new secure password:
$password = "YOUR_SECURE_PASSWORD_HERE";
$server = "localhost";
$database = "emoncms";

You will also want to modify SMTP settings and the password reset flag further down in the settings file.

Save (Ctrl-X), type Y and exit

### Install add-on emoncms modules (optional)

cd /var/www/html/emoncms/Modules
git clone https://github.com/emoncms/dashboard.git
git clone https://github.com/emoncms/app.git

The 'modules' need to save their configurations in the emoncms database, so in your browser - update your emoncms database:
`Setup > Administration > Update database` (you may need to log out, and log back into emoncms to see the Administration menu).

Expand Down Expand Up @@ -200,17 +196,17 @@ and search for "date.timezone"
edit date.timezone to your appropriate timezone:

date.timezone = "Europe/Amsterdam"

PHP supported timezones are listed here: http://php.net/manual/en/timezones.php

Now save and close and restart your apache.

sudo service apache2 restart

## Install Logger

See: https://github.com/emoncms/emoncms/tree/master/scripts/logger


***

Expand All @@ -223,4 +219,3 @@ Now save and close and restart your apache.
### /user/register.json cannot be found

If the login page loads but a user cannot be created and error `invalid` is displayed and console log shows error `/user/register.json` cannot be found this indicates an problem with apache mod_rewrite.

18 changes: 9 additions & 9 deletions docs/RaspberryPi/MQTT.md
Expand Up @@ -16,13 +16,13 @@ In addition to Mosquitto MQTT server we will need to install [mosquitto-debian-r
sudo apt-get install libmosquitto-dev
sudo pecl install Mosquitto-alpha
(​Hit enter to autodetect libmosquitto location)

If you get the error: "E: Unable to locate package libmosquitto-dev" follow the instructions at the top of the [mosquitto Debian package install guide](http://mosquitto.org/2013/01/mosquitto-debian-repository).

If PHP extension config files `/etc/php5/cli/conf.d/20-mosquitto.ini` and `/etc/php5/apache2/conf.d/20-mosquitto.ini` don't exist then create with:
If you get the error: "E: Unable to locate package libmosquitto-dev" follow the instructions at the top of the [mosquitto Debian package install guide](http://mosquitto.org/2013/01/mosquitto-debian-repository).

sudo sh -c 'echo "extension=mosquitto.so" > /etc/php5/cli/conf.d/20-mosquitto.ini'
sudo sh -c 'echo "extension=mosquitto.so" > /etc/php5/apache2/conf.d/20-mosquitto.ini'
Install PHP Mosquitto extension:

printf "extension=mosquitto.so" | sudo tee /etc/php5/mods-available/mosquitto.ini 1>&2
sudo php5enmod mosquitto


### Enable MQTT in Emoncms
Expand All @@ -45,7 +45,7 @@ The `basetopic` option sets the base MQTT topic to which Emoncms subscribers. Th

### Run Emoncms phpmqtt_input script

Install `phpmqtt_input` systemd unit script and make starts on boot:
Install `phpmqtt_input` systemd unit script and make starts on boot:

```
sudo cp /var/www/emoncms/scripts/mqtt_input.service /etc/systemd/system/mqtt_input.service
Expand All @@ -65,9 +65,9 @@ View status / log snippet with:

`sudo systemctl status mqtt_input -n50`

*Where -nX is the number of log lines to view*
*Where -nX is the number of log lines to view*

Log can be viewed as text and standard text manipulation tools can be applied:
Log can be viewed as text and standard text manipulation tools can be applied:

`sudo journalctl -f -u mqtt_input -o cat | grep emonpi`

Expand All @@ -77,7 +77,7 @@ Or with a datestamp:

There are lots of journalctrl output options: `short, short-iso, short-precise, short-monotonic, verbose,export, json, json-pretty, json-sse, cat`

To view `mqtt_info` in the emoncms log, change emoncms loglevel to `1` (info) in `settings.php` then restart `mqtt_input`.
To view `mqtt_info` in the emoncms log, change emoncms loglevel to `1` (info) in `settings.php` then restart `mqtt_input`.

#### An alternative for systems not running systemd

Expand Down

0 comments on commit a90107e

Please sign in to comment.