If you were looking for a new wallpaper, you’ve come to the right place. As you may know, several scenes of the new Star Trek “Into Darkness” movie were shot in the NIF… (National Ignition Facility).
The movie itself plays a twist over the original Star Trek Series, since… in the previous movie, we’ve seen an alteration in the flow of events, which led to a way different outcome.
If you haven’t gone to the cinema yet, i suggest you check it out. Seriously speaking!
Equivalent to SVN Externals, GIT offers a nice feature called “Modules”. Long short story, you get to link an external project, inside your own project.
What do you make out of this?. Well, suppose you’re using a 3rd party library. You can update everything with just a command line pull. No need to download and merge, by hand.
Sounds nice, right?. It’s done this way:
git submodule add git://github.com/some-framework/some-framework.git Frameworks/SomeFramework
Afterwards, we need to recursively update the submodules. Which will, in turn, clone the ‘some-framework’ repository:
git submodule update –init –recursive
This humble wordpress blog is running on an AWS micro instance. We’ve got somewhere around 1k visitors each month, which is pretty awesome. But… to my surprise, the whole system is using over 14 million I/O operations.
I suspected there was something wrong with this… so i proceeded to do a small research.
By means of the application ‘iotop’, i managed to spot the I/O hog: apache!.
Specifically, i ran iotop with the following parameters:
[cc lang=”bash”]sudo iotop -a -P[/cc]
I ran a quick search on google, and found this post. (Thank you George, for sharing your solution!).
Long short story, Apache’s APC plugin was using a memory mapped file, and it was writing… almost all the time.
The solution?. Edit your /etc/php.d/apc.ini file, and make sure that the mmap_file_mask parameter is se to use Shared Memory, as follows:
That should fix it!
I’ve recently lantean.co to AWS EC2. Amazon offers a free EC2 instance for a year…. so i decided to give it a shot.
The main reason i had to migrate to a self managed hosting is simple. Shared Hostings don’t allow you to fine tune several settings, such as the PHP Memory, and you might event not be able to login using ssh. What did i need to do?. It’s simple… let’s see…
Setting up the Environment
- Signup at Amazon Web Services. You’ll need a credit card.
- Create a new EC2 instance. Select ‘Micro’ as the type.
- Select the Amazon AMI. (I don’t trust 3rd party images!).
- Follow the wizard, and generate the SSH private / public keys.
- Setup the firewall, so only IP’s in your C class can connect through SSH, and everyone can hit the port 80.
- Connect to your box![cc lang=”bash”]ssh -i certificate.pem ec2-user@[elastic-ip][/cc]
- Setup a password for your root user[cc lang=”bash”]su passwd[/cc]
- Install Apache[cc lang=”bash”]yum install httpd
service httpd start
chkconfig httpd on[/cc]
- Install PHP[cc lang=”bash”]yum instlal php php-mysql[/cc]
- Install mySQL[cc lang=”bash”]yum install mysql-server
service mysqld start
chkconfig mysqld on[/cc]
- Secure mySQL[cc lang=”bash”]mysql_secure_installation[/cc]
- Install APC[cc lang=”bash”]yum install php-pecl-alc[/cc]
Setting up Apache
Assuming we’re not gonna host just a single website, but a couple of them… we’re gonna need to setup Virtual Hosts. With VirtualHosts you can serve as many domains as you need, using a single apache installation. Steps!
- Log into your instance and type… (replace domain.com with your own domain):
mkdir -p /var/www/domain.com/public_html
Add the following lines:
CustomLog /var/www/domain.com/requests.log combined
- Enable htaccess in your virtual hosts:
[cc lang=”bash”]nano /etc/httpd/conf/httpd.conf
- Enable logrotate:
Add the following lines:
/sbin/service httpd reload > /dev/null 2>/dev/null || true
Setting up mySQL
At last!. Let’s see how to create a mySQL database, add a new user, and how to import your mySQL dump, using nothing but bash.
- Create a new database and a new user
mysql -u root -p << You will be asked for your mySQL root-password!
create database wordpress;
create user 'wordpress'@'localhost' identified by 'password';
grant all privileges on wordpress.* to wordpress@localhost;
- Import a database dump
mysql -p -u wordpress wordpress < database_dump.sql
I hope you found this short guide helpful!
If you’re using WordPress SSH SFTP Updater plugin, and you got the error “Private Key is Incorrect for use”… even when the keys are correct, check the following:
[cc lang=”bash”]nano /etc/ssh/sshd_config[/cc]
If there is a “ForceCommand internal-sftp” directive, somewhere, in sshd’s config, try disabling it. That was what was causing me issues:
I had an sftp-only user, and the WP plugin doesn’t support that!.