tiistai 9. kesäkuuta 2015

Testlink for testcase management

To get TestLink to work, do virtualhost file which allows override.

<VirtualHost *:8010>

        ServerAdmin Niki
        ServerName testlink
        ServerAlias testlink
        DocumentRoot /home/shnigi/public_html/testlink/

        <Directory /home/shnigi/public_html/testlink/>
                Options Indexes FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>

</VirtualHost>

maanantai 8. kesäkuuta 2015

Frontend stuff Node.js, NPM, Bower & Gulp

NodeJS


On the latest version of Ubuntu, you can simply:

sudo apt-get install nodejs nodejs-dev npm which will install nodejs and npm to your computer.

Create new folder to play with. CD to that folder

Create file named: "hello_node.js"

insert:

// hello_node.js
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello Node.js\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');

Run the command by typing node hello_node.js in your terminal and leave it open.

Now, if you navigate to http://127.0.0.1:8124/ in your browser, you should see the helloworld message.


Bower init & NPM init


Install bower and gulp globally with command:

npm install -g bower
npm install -g gulp

Now we have bower and gulp globally installed. Make a new folder for your project and go in to that folder. Then do

npm init

Which will launch generator for package.json. When you have set all stuff correctly accept it. Now you can use

npm install command which will install all the required modules. To get more modules do

npm install bower --save-dev which will install bower to your project and --save-dev will put bower to package.json file as dev dependency. You can also use bare --save which will then appear as dependency. 

After you have install bower, run command bower init which will trigger bower.json file to be created. Now you can install bower components by running command bower install bootstrap --save which will install bootstrap under bower components folder. 


Flags --save means that the module is a dependecy for your project. Without that, it can't work. Or may work but not correctly. Setting flag --save-dev means that the module is critical for developer but not necessary in production version.



Gulp


Gulp is meant to automate and enhance you workflow. You can basically set tasks for gulp and it will do all the things for you automatically. First add some dev dependencies for our project.

$ npm install gulp-ruby-sass gulp-autoprefixer gulp-minify-css gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev

Then create empty file named gulpfile.js

And now for the lazy part. Head over here to read about the gulpfile. Very well explained: http://www.sitepoint.com/introduction-gulp-js/

torstai 7. toukokuuta 2015

SSH Git-repository

On ssh-server install git:

$ sudo apt-get install git
Create empty folder for git:
$mkdir gitkansio && cd gitkansio
Initialize git repository
$git --bare init

On local machine:

Create Git folder with Git:
$mkdir gittest && cd gittest
$sudo apt-get install git
$git init
Create some files
$ echo "lol" >> test.txt
Commit to Git
$git add .
$git commit -m "testing git"
Add remote repository
$git remote add origin ssh://username@server.com:1234/home/user/gitkansio
Push to remote
$git push origin master
$ git branch --set-upstream master origin/master

Clone the repository:
$ git clone ssh://gitmies@www.nikiahlskog.com:4242/home/gitmies/gitkansio

to remove: $ git remote rm origin

Check remotes with command: git remote -v 
Set new remote: git remote set-url origin ssh://gitman@365rent.fi:2222/home/gitman/365rentrepo

keskiviikko 6. toukokuuta 2015

Development mode on with LAMP

I was wondering how to setup development mode on with LAMP.

What you have to do is to set in /etc/apache2/ports.con this: Listen 127.0.0.1:80
That means, only localhost can access apache and no one else can see it.

Second thing, setup php development mode on by editing file /etc/php5/apache2/php.ini and set display_errors = On from Off value.

Create apache benchmark logs

ab -n 100 -c 20 http://localhost/ > benchmarklog-$(date +\%d\%m\%y).txt

ab -n 100 -c 20 http://localhost/ > /home/shnigi/public_html/ablogs/log-$(date +\%d\%m\%y).txt

tiistai 28. huhtikuuta 2015

Backup Wordpress Database

This should get a full backup of your database including users.
mysqldump --routines --flush-privileges --databases DBNAME > /home/USERNAME/dump-$(date +\%d\%m\%y).sql -u root -pPASSWORD


Then just add the database to your new server and remember to get wp-config.php file also. 

Update Wordpress and file permissions under Linux

To update Wordpress without FTP, install plugins and upload media do the following:

Insert to Wordpress config.php file this line: define('FS_METHOD','direct');

Then set under wp-content folder plugins and uploads folder to user www-data

chown www-data plugins
chown www-data uploads



The left one in permissions list is user and on the right group.

TO UPDATE you need to give www-data access for a short time. So do sudo chown www-data wordpress/ -R then update, and after that give access back to your user.


Setting the folder upgrade for www-data should allow upgrading, but unfortunately I couldn't test this. Using chomd 777 -R for the whole wordpress folder allows updating, but that is not a good idea.

Wordpress defaults are 755 for folders, and 644 for files. To set things back use chmod 755 -R and then find:

To recursively give directories read&execute privileges:
find /path/to/base/dir -type d -exec chmod 755 {} +
To recursively give files read privileges:
find /path/to/base/dir -type f -exec chmod 644 {} +

Or, if there are many objects to process:
chmod 755 $(find /path/to/base/dir -type d)
chmod 644 $(find /path/to/base/dir -type f)

Or, to reduce chmod spawning:
find /path/to/base/dir -type d -print0 | xargs -0 chmod 755 
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644