DISCLAIMER:
I'm not responsible if You brick Your Onion following this tutorial. I'm Linux newbie so follow this tutorial on Your own reponsibillity
I tested it on 0.0.4 (b220) firmware.
Hi,
in this tutorial I'll show you how to install LAMP, FTP and PhpMyAdmin on your Onion Omega. In this tutorial I'll use nano for editing text (yes I'm newbie who deosen't use vi:) and you can install it with:
opkg update
opkg install nano
Make Your Onion to boot from USB storage
Apache as other packages requires a lot of space so first thing You will have to do is to extend your storage. I did this by following this tutorial. To do that you will have to format your USB storage into ext4 filesystem. You can do this by following commands:
opkg update
opkg install e2fsprogs
mkfs.ext4 /dev/<your partition>
(your partition is the same You got from fdisk command in the tutorial above)
Install SFTP
To install sftp use opkg install openssh-sftp-server
command.
Install Apache server
opkg update
opkg install apache
Then edit httpd.conf
:
nano /etc/apache/httpd.conf
Find Listen part in the file and change it into:
Listen <ip You use to connect to Your console>:<port number other than 80>
Also find ServerName and change it into:
ServerName <name for Your server>:<same port as in Listen>
Then you should find:
LogLevel debug
and change it into
LogLevel error
To start Apache server You hould execute:
apachectl start
Address of Your Apache server is : <Onion Console IP adress>:<Your chosen port>
Install PHP
Since I had some problems with PhpMyAdmin I installed all this packages for php (all of them are not required but those were that I installed)
opkg install php5 php5-cgi php5-fastcgi php5-mod-json php5-mod-session php5-mod-zip libsqlite3 zoneinfo-core php5-mod-pdo php5-mod-pdo-sqlite php5-mod-ctype php5-mod-mbstring php5-mod-gd sqlite3-cli php5-mod-sqlite3 php5-mod-curl curl php5-mod-xml php5-mod-simplexml php5-mod-hash php5-mod-dom php5-mod-iconv
Type:
ln -s /usr/bin/php-cgi /usr/share/cgi-bin/
and then add folowing lines into httpd.conf:
<Directory "/usr/share/cgi-bin">
AllowOverride None
Options FollowSymLinks
Order allow,deny
Allow from all
</Directory>
<Directory "/usr/bin">
AllowOverride None
Options none
Order allow,deny
Allow from all
</Directory>
Find ScriptAlias /cgi-bin/ "/usr/share/cgi-bin"
and affter that line add ScriptAlias /php/ "/usr/bin"
so you should have:
ScriptAlias /cgi-bin/ "/usr/share/cgi-bin"
ScriptAlias /php/ "/usr/bin"
Find <IfModule mime_module>
section and add AddType application/x-httpd-php .php
and Action application/x-httpd-php "/php/php-cgi"'
into that section (before </IfModule>
)so you should have:
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi"
</IfModule>
To change Directory Index, change DirectoryIndex index.html
to DirectoryIndex index.php index.html
.
Open php.ini:
nano /etc/php.ini
And uncomment (remove ; ) on lines:
extension = gd.so
extension = mbstring.so
extension = pdo-mysql.so
extension = pdo_sqlite.so
extension = socket.so
Also do not specify doc_root
so change doc_root
into doc_root =
After that restart apache server: apachectl restart
Install mysql
opkg install mysql-server
Create two folders:
mkdir /mnt/data/mysql
mkdir /mnt/data/tmp
Use command:
mysql_install_db --force
Ok, nex step is to create root user (when I installed mysql, table with users was empty, if that's also Your case use this steps). Execute:
/usr/bin/mysqld --skip-grant-tables --skip-networking &
mysql -u root
use mysql;
FLUSH PRIVILEGES;
INSERT into user (Host, User,Password) values ('localhost','root',' ');
UPDATE user SET Password=PASSWORD('password you want') WHERE User='root';
update user set Select_priv='Y',Insert_priv='Y',Update_priv='Y',Delete_priv='Y',Create_priv='Y',Drop_priv='Y',Reload_priv='Y',Shutdown_priv='Y',Process_priv='Y',File_priv='Y',Grant_priv='Y',References_priv='Y',Index_priv='Y',Alter_priv='Y',Show_db_priv='Y',Super_priv='Y',Create_tmp_table_priv='Y',Lock_tables_priv='Y',Execute_priv='Y',Repl_slave_priv='Y',Repl_client_priv='Y',Create_view_priv='Y',Show_view_priv='Y',Create_routine_priv='Y',Alter_routine_priv='Y',Create_user_priv='Y' where user='root';
FLUSH PRIVILEGES;
To start mysql server you should type:
/etc/init.d/mysqld start
Install PhpMyAdmin
To install PhpMyAdmin you should download it from link and extract it to /usr/share/htdocs (Apache server root) and rename root folder of PhpMyAdmin (PhpMyAdmin-4..-allLanguages) to phpmyadmin
.
You should copy the content of config.sample.inc.php to config.inc.php and edit it:
cp usr/share/htdocs/phpmyadmin/config.sample.inc.php usr/share/htdocs/phpmyadmin/config.inc.php
nano usr/share/htdocs/phpmyadmin/config.inc.php
Change Authentication type and Servers parameters into:
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
After that open /usr/share/htdocs/phpmyadmin/libraries/common.inc.php
with nano (or whatever You use) and comment following part:
#if (PMA_MYSQL_INT_VERSION < $cfg['MysqlMinVersion']['internal'] {
# PMA_fatalError(
# __('You should upgrade to %s %s or later.'),
# array('MySQL', $cfg['MysqlMinVersion']['human'])
# );
#}
And that's it:)
You can access PhpMyAdmin on <Onion Console IP adress>:<Your chosen port>/phpmyadmin
UPDATE (ty to @Chris-MacKay)
If you get some permission errors change ScriptAlias /php/ "/usr/bin"
to ScriptAlias /php/ "/usr/bin/"
in httpd.conf .