Local development in a Macbook (part 2)

I had a number of issues regarding my local development VirtualBox loaded ubuntu that I installed a few years back. Using a VirtualBox installed Ubuntu for development

Getting frustrated of trying to fix the problem (which I couldent really identify) I upgraded and updated and changed loads of stuff in the Ubuntu installation. Nothing worked.

As all my actual work is in my Dropbox, I opted for removing the Development box in the VirtualBox, and look for another solution.

http://mallinson.ca/osx-web-development/
Has a nice guide for installing Homebrew, MySQL, and use the apache2.4 and PHP delivered by OSX (yosemite)
Im just running my sites off the subdirectories in the Dropbox folder, so I skipped the dnsmasq part of that guide.

This is a LOCAL development machine, so I dont have many security conserns, this allows me to skip some fears and modify where I need.
To be able to use the Dropbox folder in apache on the Mac, I had to change the user and group for the http deamon, to my mac user:

sudo vi /etc/apache2/httpd.conf
default is _www for both user and group, but I changed it to emil/staff

Also, creating a “username.conf” in the directory:
cd /private/etc/apache2/users
sudo vi emil.conf

inserting

Thirdly, changing
sudo vi /private/etc/apache2/httpd.conf

From

To

and remember to restart the apache server to effectuate changes:
sudo apachectl restart

While trying to setup the dropbox folder as the source for my local development, I already described the solutions above, however I did run into some permission issues, and threads like these helped me get it right:
No permission to access / on this server
– And including your username as the webserver deamon executer No permission to access /~username/

Skriv kommentar

Din e-mailadresse vil ikke blive publiceret. Krævede felter er markeret med *

WordPress brutefore login forsøg

Jeg har et par servere, hvorpå jeg får emails med advarsel om at nu er der xx antal forsøg på login.
Det plugin jeg benytter hedder “Login Security Solution” som sætter en tidsbegrænser op for hvor ofte et login kan prøves.

Nu bruger jeg så hverken “admin” eller “administrator” brugernavnene, som er dem der indtil videre er kørt “bruteforce” forsøg med, så nu vil jeg i stedet hygge mig med at logge de passwords de forsøger sig med.

Dertil har jeg lavet nedenstående filter til WordPress login funktion, og indsat i mit temas functions.php fil:

add_filter('authenticate', 'log_bruteforce_login', 100, 3);
function log_bruteforce_login($user, $username, $password)
{
$upload_dir = wp_upload_dir();
$unamearray = array('admin','administrator');
$date = date("Y-d-m H:i");

if ( in_array($username, $unamearray) )
{
$stringToAppend = $date .' '. $username .' '. $password .PHP_EOL;
file_put_contents( $upload_dir['basedir'].'/brugeforce.log', $stringToAppend, FILE_APPEND);
}
return $user;
}

og ja det er bare for sjov, jeg kunne jo også lave andre drengestreger med folk som forsøger at logge på med brugernavne som slet ikke eksistere på serveren. fx ved at smidde dem over på en anden server eller til et radom adsence click?

Skriv kommentar

Din e-mailadresse vil ikke blive publiceret. Krævede felter er markeret med *

Add your googleplus profile image to search results for your wordpress

You can use this method to include your google+ profile image to search results on your WordPress blog.

All it takes are a few new lines of code to your functions.php file in your theme folder.
You need to allow the users to add their google+ profile link on their wordpress user profile page.
And you need to add the google+ profile author link to the header.php via the filter included in the functions.php

Then you have to make a relation between the Google+ profile and your website.

Now you need to add your website to your Google+ profile:
https://plus.google.com/u/1/user-id/about/edit/co
This will make the link between your google+ profile and your website, and it works as a kind of authentication.

Test that it is working by entering a page or a post that you authored via:
http://www.google.com/webmasters/tools/richsnippets

Skriv kommentar

Din e-mailadresse vil ikke blive publiceret. Krævede felter er markeret med *

Ubuntu as a virtual web server using VirtualBox on MacBook Air

“Less is more” – I want to install only the absolutely necessary programs on my new MacBook Air. I believe keeping things simple is more productive. As a web developer I create a lot of projects in my web directory. I do projects for customers, some as a sourced resource, and then projects for my self. This article by Dan Adams inspired me to setup a local web server using Ubuntu on VirtualBox sparing my MBA from cluttering up – and leaving my DropBox directory as an easily sharable holder for web projects.

Download VirtualBox here and the Ubuntu LTS server here.

VirtualBox configuration

Create a Host-only bridge network and attach as adaptor 2 on the Virtual machine:
Virtualbox Preferences
Select “Network” tab
click the small “add host only network” icon
insert IPv4 address: 192.168.56.1
insert IPv4 Network mask: 255.255.255.0
At the DHCP tab, UNTICK the “enable server”

Create new Virtual Machine
On the “Network” tab, Enable Adapter 2
Select “Host only adapter”
The Adaptor name should be auto-populated with “vboxnet01”.
On the “Storage” tab, select the Ubuntu iso to be mounted in the cd-rom.
I selected 1 GB memory for this server – should be enough for OS, database, web server and APC.
Start the virtual machine, and begin Ubuntu installation.

Installing Ubuntu

Select installation language
Select to install
Select locale (language) for installed system
Select primary network eth0 (eth1 is the bridged-host, we configure this later)
Choose a hostname for your server (here we use “testhost”)
enter your full name
enter login name
enter a password x 2
select no to encrypt your home directory (you are not really going to use it)
verify the time zone
choose “guided – entire disk”
select the disk that are presented
verify the disk selection

You do not need a external http proxy
Select Install security updates automatically
Select OpenSSH server and LAMP Server
Enter a password for root/MySQL user

accept GRUB boot loader on the drive
installation is complete (press continue)

Configure the server

login using your login name and password
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install dkms build-essential linux-headers-generic module-assistant
sudo m-a prepare
sudo apt-get install uml-utilities bridge-utils
sudo modprobe tun
sudo apt-get install xserver-xorg xserver-xorg-core
sudo apt-get install virtualbox-ose-guest-x11

Installing the VirtualBox Guest Addon


This will allow sharing files between your host (mac osx) and the guest (ubuntu).
For virtualbox reference / how to setup reference.
Now on the VirtualBox window, select the icon for the cd, if the ubuntu iso is mounted, remove it. Then via the VirtualBox administration menu, select “devices -> install guest addons” – this only mounts the guest addon iso in the virtual cd-rom (it does not install it!).
In the terminal logged into the guest, enter the command
sudo mount /dev/cdrom /media/cdrom
cd /mount/cdrom
sudo sh ./VBoxLinuxAdditions.run
yes continue to overwrite some other installation (the virtualbox-ose-guest-x11)

Configure network

(using this as a reference: http://christophermaier.name/blog/2010/09/01/host-only-networking-with-virtualbox)
sudo vi /etc/hosts
insert 192.168.56.102 testhost (or whatever your hostname is)
sudo ifconfig eth1 192.168.56.102 netmask 255.255.255.0 up
sudo vi /etc/network/interfaces
insert below the others
# my testhost interface
auto eth1
iface eth1 inet static
address 192.168.56.102
netmask 255.255.255.0
network 192.168.56.0
broadcast 192.168.56.255

You also need to make sure the eth1 interface is started automatically when server restarts:
sudo vi /etc/init.d/rc
insert this at last line but ABOVE the “exit 0” line! (press G to go to last line)
ifup eth1
In your Mac terminal (the host system also needs to know the IP-address)
sudo vi /etc/hosts
and insert
192.168.56.102 testhost

Use MAC Terminal to administer your server

Now you can connect to your server via SSH, so open your mac terminal and enter
ssh testhost
accept the RSA key
enter your username and password
Now you can use copy paste which makes administration a little easier.

Removing MySQL

We do not want to use MySQL so we remove it and install MariaDB instead – its a complete substitution and everything will be working as expected, just faster :)

dpkg –get-selections | grep mysql
Remove all of the packages listed by the above command, it will most likely look like this:
sudo apt-get remove libdbd-mysql-perl libmysqlclient18 mysql-client-5.5 mysql-client-core-5.5 mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php5-mysql

Verify they are all removed, if not – repeat the action on the packages with the “purge” command instead:
dpkg –get-selections | grep mysql
sudo apt-get purge package-name-a package-name-b
If asked, KEEP the mysql databases – do not delete them (you do not have any data right now, but if you did this on a system that had been running for a while you could destroy your work…)

Installing MariaDB, phpMyAdmin and APC

You have to do a few manual steps to enable downloading MariaDB
Visit mariadb/repositories and select ubuntu, precise (ubuntu version 12), 5.5 (mariaDB version, latest)
sudo vi /etc/apt/sources.list.d/mariadb.list
insert the text
# MariaDB repository list – created 2012-07-16 15:10 UTC
# http://downloads.mariadb.org/mariadb/repositories/
deb http://mirror3.layerjet.com/mariadb/repo/5.5/ubuntu precise main
deb-src http://mirror3.layerjet.com/mariadb/repo/5.5/ubuntu precise main

And then get the pgp key from http://kb.askmonty.org/en/installing-mariadb-deb-files/
sudo apt-key adv –recv-keys –keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
sudo apt-get update
sudo apt-get install mariadb-server
enter password for mariadb root x 2

Verify installed packages
dpkg –get-selections | grep maria

Install phpmyadmin
sudo apt-get install phpmyadmin

sudo vi /etc/apache2/conf.d/fqdn
insert
ServerName localhost

Install APC
sudo apt-get install php-apc
sudo /etc/init.d/apache2 restart

Mounting your Host web directory on your Guest web directory

While switching my development computer from a PC to MAC, I moved lots of files to my Dropbox account. While my files are moved to this location, I figure the Dropbox account / local directory can host my files instead of duplicating them to a web directory. (I also backup to TimeMachine, in case something weird happens to the Dropbox account).

Get the ID of your apache2 user/group (its most likely 33 for both)
id www-data

Then mount the web filesystem from your host system on a directory created for the occasion on the guest os (the ubuntu server)
sudo mkdir /mnt/www
sudo mount -t vboxsf -o uid=33,gid=33 web /mnt/www
We want to make sure the filesystem is mounted automatically on system restart
sudo vi /etc/init.d/rc
Insert at the line below “ifup eth1” (and ABOVE the “exit 0” line)
mount -t vboxsf -o uid=33,gid=33 web /mnt/www

The apache2 server defaults to look for websites in /var/www
We want to use the mounted /mnt/www files, this is how:
sudo rm -r /var/www
sudo rmdir /var/www
now link the mounted directory to the apache http directory
sudo ln -s /mnt/www /var/www
sudo /etc/init.d/apache2 restart

Now you can edit your MAC files in the shared directory, and use the Ubuntu web-server to configure and serve websites and host the databases.

Favorite CSS3 buttons and techniques to cut development time

Buttons
These buttons look great in chrome and other native css3 browsers, they work in IE but dont have rounded corners.

papermashup.com
http://papermashup.com/pretty-css3-buttons/

zurb.com
http://www.zurb.com/blog_uploads/0000/0617/buttons-03.html

Some contenders to use, If you dont care about Internet Explorer at all – these buttons dont work at all in IE – however they look outstanding in CSS3 browsers:
http://www.wearepico.com/buttons/

Menu
Crossbrowser CSS dropdown menu
http://www.webdesignerwall.com/demo/css3-dropdown-menu/

– building on this post when i find worthy elements i use.

Skriv kommentar

Din e-mailadresse vil ikke blive publiceret. Krævede felter er markeret med *