Difference between revisions of "Amahi 7 Create Manual Web App"
Line 50: | Line 50: | ||
**Ensure you replace appname accordingly and the date can be changed providing you follow the format. If you changed the .conf file name, ensure it matches as well. | **Ensure you replace appname accordingly and the date can be changed providing you follow the format. If you changed the .conf file name, ensure it matches as well. | ||
**To do a quick check, you can do the following for each table: | **To do a quick check, you can do the following for each table: | ||
− | <blockquote>{{code|echo "select max(id) from dns_aliases" <nowiki>|</nowiki> mysql -uroot -phda hda_production | + | <blockquote>{{code|echo "select max(id) from `dns_aliases`" <nowiki>|</nowiki> mysql -uroot -phda hda_production |
− | echo "select max(id) from webapps" <nowiki>|</nowiki> mysql -uroot -phda hda_production}}</blockquote> | + | echo "select max(id) from `webapps`" <nowiki>|</nowiki> mysql -uroot -phda hda_production}}</blockquote> |
:Once you have chosen the id number, execute the following | :Once you have chosen the id number, execute the following | ||
<blockquote>{{code|echo "INSERT INTO `dns_aliases` (`id`, `name`, `address`) VALUES(99, 'appname', '')" <nowiki>|</nowiki> mysql -uroot -phda hda_production | <blockquote>{{code|echo "INSERT INTO `dns_aliases` (`id`, `name`, `address`) VALUES(99, 'appname', '')" <nowiki>|</nowiki> mysql -uroot -phda hda_production |
Revision as of 18:53, 20 November 2013
WARNING | |
---|---|
This is recommended for advanced users only, please proceed with caution. |
To accommodate those users who need the manual web app feature currently not available in Amahi 7, the following guidance is provided. This has been tested and no issues were noted. Please note this is ONLY a work around until the manual web app feature is implemented in Amahi 7.
Terminal scripts of this tutorial:
Choose a name for your app. It should be short, lowercase, and do not use spaces. For example, head_phones or headphones are acceptable names. (remember to replace all occurrences of appname below with your desired name).
NOTE: There is no guarantee this will work for you or not cause problems with your Amahi 7 install. Please proceed with caution as carelessness could render your HDA inoperable.
Create Manual Web App
As root user, perform the following steps:
- Build directory structure
bash code mkdir -p /var/hda/web-apps/appname mkdir -p /var/hda/web-apps/appname/html mkdir -p /var/hda/web-apps/appname/logs chown -R apache:users /var/hda/web-apps/appname touch /var/hda/web-apps/appname/logs/access_log touch /var/hda/web-apps/appname/logs/error_log chown root:root /var/hda/web-apps/appname/logs/access_log chown root:root /var/hda/web-apps/appname/logs/error_log
- Create Apache configuration file (9999 can be changed to any number, but recommend keep it above 2000 to be safe)
bash code vi /etc/httpd/conf.d/9999-appname.conf
- Insert the text below (remember to change all occurrences of appname accordingly and the domain name amahi.net to match yours if needed)
Text <VirtualHost *:80> ServerName appname ServerAlias appname.amahi.net DocumentRoot /var/hda/web-apps/appname/html <Directory "/var/hda/web-apps/appname/html"> Options Indexes FollowSymLinks MultiViews AllowOverride AuthConfig Require all granted </Directory> ErrorLog /var/hda/web-apps/appname/logs/error_log CustomLog /var/hda/web-apps/appname/logs/access_log combined env=!dontlog </VirtualHost>
- Change permissions and restart Apache
bash code chown apache:users /etc/httpd/conf.d/9999-appname.conf service httpd restart
- Update Amahi 7 database settings
- The id field is set to 99 for this example. It can be any number not currently used by Amahi. Recommend you keep it at 99 or greater to be safe.
- Ensure you replace appname accordingly and the date can be changed providing you follow the format. If you changed the .conf file name, ensure it matches as well.
- To do a quick check, you can do the following for each table:
- The id field is set to 99 for this example. It can be any number not currently used by Amahi. Recommend you keep it at 99 or greater to be safe.
bash code echo "select max(id) from `dns_aliases`" | mysql -uroot -phda hda_production echo "select max(id) from `webapps`" | mysql -uroot -phda hda_production
- Once you have chosen the id number, execute the following
bash code echo "INSERT INTO `dns_aliases` (`id`, `name`, `address`) VALUES(99, 'appname', '')" | mysql -uroot -phda hda_production echo "INSERT INTO `webapps` (`id`, `name`, `path`, `kind`, `aliases`, `fname`, `deletable`, `login_required`, `dns_alias_id`, `custom_options`, `created_at`, `updated_at`) VALUES(99, 'appname', '/var/hda/web-apps/appname', '', '', '9999-appname.conf', 0, 0, 99, NULL, '2013-11-17 12:00:00', '2013-11-17 12:00:00')" | mysql -uroot -phda hda_production
- Create a test file
bash code vi /var/hda/web-apps/appname/html/index.html
- Insert the text below
Text <!DOCTYPE html> <html> <body> <h1>Web App TEST Page</h1> <p>It works!</p> </body> </html>
- Set the correct permissions on the file
bash code chown apache:users /var/hda/web-apps/appname/html/index.html
- Test your new web app by entering http://appname in your browser. If all goes well, you should see the test page. If you have problems, retrace your steps. Ensure you replaced all occurrences of appname accordingly and the id field in both tables match.
Delete Manual Web App
The process to remove a web app created using the procedure above is a little shorter as you might expect. The steps below will remove it completely from your Amahi 7 instance.
NOTE: Please ensure you remove the correct files or you may break an existing web application.
As root user, perform the following steps:
- Remove the Apache configuration file
bash code rm -rf /etc/httpd/conf.d/9999-appname.conf
- Delete the web app directory
bash code rm -rf /var/hda/web-apps/appname
- Restart Apache
bash code service httpd restart
- Update Amahi 7 database settings
bash code echo "DELETE FROM `dns_aliases` where id=99" | mysql -uroot -phda hda_production echo "DELETE FROM `webapps` where id=99" | mysql -uroot -phda hda_production
- Once complete, the web app should now be completely removed from your system.
Return to Amahi 7 Installation page.