Skip to content

Instantly share code, notes, and snippets.

@ronaldcotton
Last active October 17, 2017 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronaldcotton/d57f44fc3757ff8c0d12c9cf93623142 to your computer and use it in GitHub Desktop.
Save ronaldcotton/d57f44fc3757ff8c0d12c9cf93623142 to your computer and use it in GitHub Desktop.
Turnkey LAMP with Booked Scheduler

Turnkey LAMP with Booked Scheduler

https://www.turnkeylinux.org/lampstack http://www.bookedscheduler.com/

About Turnkey

TurnKey LAMP offers VMDK, ISO, OpenStack, Xen, Docker, or an easy to use Amazon EC2 install.

LAMP stack is a popular open source web platform commonly used to run dynamic web sites and servers. It includes Linux, Apache, MySQL, and PHP/Python/Perl and is considered by many the platform of choice for development and deployment of high performance web applications which require a solid and reliable foundation.

LAMP stack includes all the standard features in TurnKey Core_, and on top of that:

  • SSL support out of the box.

  • PHP, Python and Perl support for Apache2 and MySQL.

  • PHP development helpers

    • phpsh_: interactive shell
    • php5-xdebug_: debugging and profiling
    • php-pear_: php extension and application repository
    • php5-cli: command-line interpreter
  • Adminer_ administration frontend for MySQL (listening on port 12322 - uses SSL).

  • Postfix_ MTA (bound to localhost) to allow sending of email from web applications (e.g., password recovery).

  • Webmin modules for configuring Apache2, PHP, MySQL and Postfix.

Note: TurnKey Linux makes many different configurations based on netinstall of Debian.

Step 1: Install Turnkey

Setup server root, MySql root, and admin email address. Update Debian (depending on your connection, may take 1+ hour), reboot. If additional services required from such as TurnKey Backup Migration and TurnKey DDNS, setup and install those features as well.

Step 2: On Reboot, the LAMP Applicance Services via ip:port is displayed

     Web:   http://xxx.xxx.xxx.xxx
            https://xxx.xxx.xxx.xxx
Web shell:  http://xxx.xxx.xxx.xxx:12320
Adminer:    https://xxx.xxx.xxx.xxx:12321
SSH/SFTP:   https://xxx.xxx.xxx.xxx (port 22)

Note: Browser will complain about not secured, SSL is not setup with a Security Certificate by default. Click on the advanced Tab for more settings.

Step 3: Securing MySQL Installation

ssh as root and run the following command:

root@lamp ~# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
      
In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n
 ... skipping.

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n (in my case)
 ... skipping.

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Step 4: Create Bookedscheduler User

root@lamp ~# mysql -u root -p
Enter password: <enter MySql password here>
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 43
Server version: 5.5.57-0+deb8u1 (Debian)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE bookedscheduler;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON `bookedscheduler`.* TO 'bookedscheduler'@'localhost' IDENTIFIED BY '<secret-password-here>';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> \q
Bye

Step 5: Install Booker Scheduler

Again, as root:

# downloads the latest code and saves it to /tmp/booked.zip
curl -L -o /tmp/booked.zip https://sourceforge.net/projects/phpscheduleit/files/latest/download
# places it within the web directory
unzip /tmp/booked.zip -d /var/www
# updates the permissions so apache owns the site
chown www-data:www-data -R /var/www/booked

Step 6: Update Permissions

chmod -R 0755 /var/www/booked/tpl_c
chmod -R 0755 /var/www/booked/tpl
chmod -R 0755 /var/www/booked/uploads

Step 7: Configure Booker Scheduler

cd /var/www/booked/config
cp config.dist.php config.php

Step 8: Follow Symbolic Links

Add these lines after <VirtualHost *:80> and <VirtualHost *.:443> tags

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

Step 9: Install Database

mysql -u bookedscheduler -p bookedscheduler < database_schema/create-schema.sql
Enter Password: <bookedscheduler MySQL Password>
mysql -u bookedscheduler -p bookedscheduler < database_schema/create-data.sql
Enter Password: <bookedscheduler MySQL Password>

Step 10: Edit Config File

Edit /var/www/booked/config/config.php with your favorite editor

// ...
$conf['settings']['script.url'] = 'http:' // autofind
// ...
$conf['settings']['admin.email'] = 'admin@example.com';
// ...
/**
 * Database configuration
 */
$conf['settings']['database']['type'] = 'mysql';
$conf['settings']['database']['user'] = 'bookedscheduler'; 
$conf['settings']['database']['password'] = '<bookedscheduler MySQL Password>';
$conf['settings']['database']['hostspec'] = '127.0.0.1';
$conf['settings']['database']['name'] = 'bookedscheduler';
//...
$conf['settings']['registration.captcha.enabled'] = 'false'; // if false, turn on recaptcha for production

Step 11: Start the Apache and MySQL Server

/etc/init.d/apache2 restart
/etc/init.d/mysql start
curl -I http://127.0.0.1

Top line should read: HTTP/1.1 200 OK

Step 12: Create New Account

Visit: http://xxx.xxx.xxx.xxx/booker/Web/register.php Use the same email address entered on

Notes

  • Insecure settings, not everything is defined, needs more work
  • Advanced settings were not added
  • Email settings were not added or tested
  • Firewall allowances for port 80 By using curl with http://127.0.0.1 we are testing the server does work. If it is not working in the browser, you may need to open ports 80 and 443.
  • Does not cover HTTPS and adding SSL

References

Alternatives to TurnKey

The Bitnami Application Catalog contains a growing list of 140+ trusted, pre-packaged applications and development runtimes ready-to-run anywhere.

Test Downloads

Download README: https://docs.google.com/document/d/1YkMEZLgWFgW0ODcTUvaI9QOFZUL5AQPwCnp0492SFKU/edit?usp=sharing

Download OVA: https://drive.google.com/file/d/0B_xJRwB5U2QiTHNIT3l2ZlZrUGs/view?usp=sharing

File > Import Appliance from VirtualBox or Double Click .ova file.

After running, open browser to http://xxx.xxx.xxx.xxx/booker/Web/register.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment