Okay so I need to have a server with a databse for a smartphone applications I'm working on, and there are a few requirements.
-SQL database
-Returns queries with JSON
So i had this old Raspberry Pi laying around and i wanted to set it up for it. But theres something im uncertain of, and google haven't helped me yet.
I planned on use SQLite on the Pi, and wanted to interact with it in PHP. Then use the PHP to convert into JSON, which would then be retrieved by the smartphone.
The thing is i don't know what service i can use on the PI to make this .PHP file able to be found from another device
You can install nodejs by running:
sudo apt-get install nodejs nodejs-legacy npm
For SQL database you can run
sudo apt-get install mariadb-server mariadb-client
Install your nodejs mysql module by:
sudo npm install -g node-mysql
That should get you started.
Related
I'm writing a webhook to automatically publish a site when I push to GitHub. Part of the process requires that I build the site with
bundle exec middleman build --clean
I'm trying to invoke that with a PHP script, the script called by the GitHub webhook, so the user is www-data. No matter what I try, however, I'm getting an error that bundle cannot be found.
How can I run a bundle command from a PHP script?
I was able to figure this out. First, I installed rvm as a multi-user installation to ensure the www-data account can access it.
$ curl -sSL https://get.rvm.io | sudo bash -s stable
Install the desired ruby version, in my case 2.3.1, then set rvm to use it:
$ rvm install 2.3.1
$ rvm use 2.3.1
Run gem to install any gems that are needed. Because rvm is a multi-user installation, these gems are stored to the system and not your specific user.
$ gem install packagename
I don't know if this is necessary, but I would close the SSH session and reopen it. rvm messes with environment variables, so better safe than sorry.
Run env to print all environment variables. printenv also works if env doesn't for some reason. You'll get a big list of everything set, you only need the ruby-related ones. Do not copy/paste these values, they are examples I pulled from my system. Yours will be different!
PATH=/usr/local/rvm/gems/ruby-2.3.1/bin:/usr/local/rvm/gems/ruby-2.3.1#global/bin:/usr/local/rvm/rubies/ruby-2.3.1/bin:/usr/local/rvm/bin:/home/steven/bin:/home/steven/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
rvm_bin_path=/usr/local/rvm/bin
GEM_HOME=/usr/local/rvm/gems/ruby-2.3.1
IRBRC=/usr/local/rvm/rubies/ruby-2.3.1/.irbrc
MY_RUBY_HOME=/usr/local/rvm/rubies/ruby-2.3.1
rvm_path=/usr/local/rvm
rvm_prefix=/usr/local
rvm_ruby_string=ruby-2.3.1
GEM_PATH=/usr/local/rvm/gems/ruby-2.3.1:/usr/local/rvm/gems/ruby-2.3.1#global
RUBY_VERSION=ruby-2.3.1
Now we need PHP to recognize these variables. You'll need to find the right file on your system, which can be tricky. I don't have a way of knowing which one is correct, I used trial and error.
The file on my system is /etc/php/5.6/fpm/pool.d/www.conf. Add all of the environment variables you previously grabbed into this file with the below format. Note that you DO need PATH in here as well!
env[rvm_path] = /usr/local/rvm
env[rvm_prefix] = /usr/local
Now restart php-fpm. Your service name may be different from mine; I'm using the 5.6 build from ondrej/php.
Ubuntu 15.04 and newer (systemd):
$ sudo systemctl restart php5.6-fpm
Ubuntu 14.10 and newer:
$ sudo service php5.6-fpm restart
Finally, in the script itself you'll need to cd to the directory you're running the bundle command from. My short script is this:
cd /opt/slate
/usr/bin/git reset --hard
/usr/bin/git pull
bundle exec middleman build --clean
cp -R /opt/slate/build/* /var/www/docs
Works for me!
I host a Phabricator instance on a Ubuntu machine.
How do I uninstall Phabricator totally, including all config files and settings.
I already removed all three folders cloned from git, and uninstalled mysql-server using
sudo apt-get purge --auto-remove mysql-server.
However, when I run install_ubuntu.sh to install back again, the old admin account, the log for Daemons logs, and the site settings are still there in website.
How can I remove all configuration and data completely?
The problem most likely is that uninstalling the MySQL server does not delete databases. You have a couple of options.
Probably the best way to delete the data would be to run Phabricator's bin/storage destroy command. This is the best approach, because it does not make any assumptions about how Phabricator stores its data (MySQL, files etc.). Install Phabricator, MySQL and all other dependencies again, and look for bin/storage in Phabricator installation directory.
Another way would be to install mysql-server and mysql-client, launching the mysql command line client and dropping all databases starting with phabricator_.
If you really want to mess with database files directly, you can find them in /var/lib/mysql.
I received a amazon email saying that i have to terminate my instance because of attacks but i worked really hard to install and setup everything on the instance.
I've tried to create a image and on the AMI create a new instance and launch another instance like this. but it not worked.
So how can i create another instance with the stuff that i installed on the current instance?
By the way have some way to copy everything on the instance?
Someone could please spare some hint?
thank's
If the instance security is compromised you should really start from scratch.
But if you need to access data from the older instance you can create a Volume snapshot and then attach it to the new instance.
I know it's annoying to setup everything again, so I keep a shell script to configure everything remotely and I run it each time I create a new instance. If you were trying to setup a LAMP server, you could write an install.sh script with something like:
#!/bin/sh
SERVER_IP= ...
SERVER_ADDR=ec2-user#$SERVER_IP
SERVER_PEM=/../../key.pem
sudo ssh -t -t $SERVER_ADDR -i $SERVER_PEM <<-EOF1
sudo yum update -y
sudo yum install -y httpd24 php56 mysql55-server php56-mysqlnd
EOF1
I am using Lumen (of Laravel) as my backend and using vagrant. I am want to install and use FFmpeg but I got confused how to install it.
Do I need to install it on my localhost or add it to Lumen? or both?
I found this page but I got lost which commands to run.
Update: I installed this repo on Github and run it in vagrant. I think this installed the latest version on my local server, but what should I do next? How can I install and use FFMpeg with Lumen in php?
Go to your Homestead folder, run vagrant ssh. This will get you into your vagrant machine's terminal. Run command sudo apt-get install ffmpeg there and acknowledge the questions you get asked. (Additional libraries for PHP integration might be required.) FFMpeg will be ready to use.
I would like to know if there is a php application able to browse any database supported by PDO. Something like phpmysqladmin but for PDO.
I have tried google and I didnt found any, checked http://alternativeto.net/software/phpmyadmin/ too, and nothing found...
I just want to browse a firebird/odbc database using a webbrowser, and I though that a pdo browser would be the best option for that.
You can install an php administration tool like Firebird Web Admin
sudo apt-get install php5-interbase git-core
sudo /etc/init.d/apache2 restart
git clone git://github.com/mariuz/firebirdwebadmin.git
mv firebirdwebadmin /var/www/firebirdwebadmin
load in the browser
localhost/firebirdwebadmin