Posts Tagged ‘(mt) Media Temple’

(mt) MediaTemple migrated my Server and broke my LEMP stack. (Part 2)

If you’re joining me from part 1thank you. If you are just joining you may want to check out part 1.

    When I last left you I had just installed MySql and setup a root user with a strong password. Now I need to get all the domain web files and MySql Databases to my new server,  perserving permissions and ownership, hopefully. Before I accomplish any of this I need to create users and all their directories that hold the public web files for each domain. I am then going to create all the same databases and import all the database dumps. Lastly, I want to start Nginx and test all my old configuration files before activating them all.

I created new users first using useradd.

$useradd jabo

I then rsync’d each users files one at a time to try and preserve permissions. Notice I said “try” I later had to chmod each users web directory so they could have the correct ownership. The more advanced Linux users will know why, the UID # of each user didn’t match the UID on the old server but that is another post. So Rsync is awesome. I mirrored all my web files and sent them via ssh to my new server. In verbose mode of course.

$ rsync -r -a -v -e "ssh -l root" --delete /old/Server/path/

MySql is not my favorite from the command line but since this is a new server and I was in a rush I didn’t have time to install and setup PHPAdmin. Now this did not work for me as root. I had to make a dump using each database users username and password. That also meant I had to go rooting around in some of my users WordPress installs. not to tough.

$ /usr/bin/mysqldump -u root -p --opt >/web/root/alldatabases.sql

After a quick rsync of all the database files. I logged into MySQL from the command prompt then created new databases with the same passwords and usernames. Lastly, I restored each database with their respective user.

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 162
Server version: 5.1.41-3ubuntu12.6 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database testdb;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on testdb.* to 'dbuser1' identified by 'db_user_pw';
Query OK, 0 rows affected (0.00 sec)
mysql> quit

Restore each database with the appropriate username and password.

$/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql

With all that said and done I was finally ready to test if this all worked. I checked my Ngnix configuration files visually to make sure they made sense. I almost rubber ducked them but it was 3 am at the time, so the prospect of my girlfriend waking up to me talking to myself in front of a dim lit monitor was not appealing. I ran Nginx with the -t option and everything worked out. I then started Nginx and BEHOLD I have CONQUERED!

Now it didn’t work all gravy right out of the box. I was spawning like 100 PHP processes and my VPS Memory was zooming! With some help from Google and the Nginx Wiki I was able to trim Nginx to pre-migration levels. I still have lots of tweaking to do to make it run leaner and allowing MySQL to run for a few weeks before I tune. After all that I still stayed with MediaTemple. I really didn’t want to go through all that again with another hosts control panel I am not familiar with or worse C-panel.


Funny thing but two weeks later Media Temple decided to migrate the “new” VPS they gave me. Luckily, I got some attention from support, the next migration went well, and had no issues this time around. I know now what went wrong and I know how to prevent it in the future.

(mt) MediaTemple migrated my Server and broke my LEMP stack. (Part 1)


First I have to  start by saying this is mostly my fault. (mt) MediaTemple has been good to me. They even emailed me to tell me that they where going to migrate my server to newer hardware. I should have taken the time to do it myself, but I am lazy. They also sent me an email telling me I had to do nothing. Luckily, support is very understanding and they lent me a free (VE) for 30 days to configure and migrate my configuration myself.


The Nitty Gritty

 After (mt) MediaTemple migrated my server I found all the web roots for the domains I managed changed. Blogs and php files would not load able to load properly. I also discovered that Apache was installed and Nginx was not started, although installed. I did try stopping Apache but there were still so many things going wrong I decided to start fresh. Plus it would give me a chance to upgrade my LEMP Stack to a more current version. I had two failed tries, the caveat being you had to load the stack in order. Installing Mysql before Nginx causes apt-get to install Apache. Before starting I had to secure my server by changing the /tmp directory and updating my root password. You should consider securing your server further.

I choose to break this up into two post because it would have been very long. Not to mention I took a nap in between.

Here were my steps:

    1. Install an OS. I chose Ubuntu 11.04 Natty Narwhal.
      1. I ran into an issue were I received an error updating
        1. perl: warning: Please check that your locale settings ubuntu
          1. perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = “en_US.UTF-8″, LC_ALL = “en_US.UTF-8″, LANG = “en_US.UTF-8″ are supported and installed on your system. perl: warning: Falling back to the standard locale (“C”). locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory
      2. I had to install the English base language pack
        1. apt-get install language-pack-en-base
        2. export LANGUAGE=en_US.UTF-8
      3. Then I had to change to the version of English I was using.
        1. export LANGUAGE=en_US.UTF-8
          export LANG=en_US.UTF-8
          export LC_ALL=en_US.UTF-8
          locale-gen en_US.UTF-8
          dpkg-reconfigure locales
    2. Install Nginx
      1.  apt-get install nginx
    3. Install PHP
      1. You can just install the php5-fpm package, but I am going to do some other stuff later, so I installed more packages.
        1. apt-get install php5-fpm php5-cli php5-common php5-curl php5-gd \
            php5-mcrypt php5-mysql php5-pgsql php5-sqlite php5-tidy php5-xmlrpc \
            php5-xsl php5-intl php5-imagick php5-xdebug php-apc php-pear
        2. Default is fine for now, but my default config caused my server to spawn 50 processes and consume 80% of my memory. I had to tweak it but that will be a different Blog post.
    4. Install MYSQL
      1. apt-get install mysql-server mysql-client
      2. You are required to setup a root password. Choose something Strong.
    5. I then created all my users for managing the multiple domains I have hosted.
      1. adduser myuser
        1. I gave them all the same passwords
        2. Then set sudo privileges
          1. visudo
            1. # User privilege specification
              root      ALL=(ALL) ALL
              users     ALL=(ALL) ALL

I then took a nap because I still had to rsync all the Data from my old/newly migrated server. Like I said I failed the first couple times, Nginx wouldn’t bind one time and PHP wouldn’t load another. The server has to be reset to default, that takes time. Then the OS takes time to reinstall. Factor in having to accomplish this after I got off work that evening, I was pretty exhausted. I also have to mention that it took almost all day for the new (VE) Server to be provisioned when support said it would only take 15 minutes. Please check in for Part 2.

(ve) Project: LNMP (Linux Nginx MySQL PHP-FPM)


As you know, I work for (mt) Media Temple, a great web hosting company. Recently, I procured a (ve) 512 MB server to practice some server administrator tasks. I was looking for a project to really challenge me so I decided to provision a VPS and is as bare-bones as a VPS gets. My server came as a completely raw system with nothing installed but the operating system. No users except the root user, making it somewhat of a true VPS, for me to make whatever I want of it.

So for my challenge I decided to install a LNMP stack: Linux, Nginx, MySql, and PHP-FPM. At the time, I chose PHP-FPM over PHP. I wanted to do something I had very little knowledge about. I started using a few guides from several websites and Wiki’s. So I was able to limp this project along over the span of a few days and frustrations. I had seen a video from WordPress WordCamp 2011 where a co-worker held a presentation about Nginx(engine-X) as a web server, as apposed to a resource intensive Apache configuration. I only had a 512MB server, therefore, I didn’t want any rolling memory binges.

Having not that much knowledge of the differences between Apache and Nginx, I read that Nginx is significantly stripped down, in comparison to Apache. Nginx, which is asynchronous, keeps a low and steady memory-footprint — regardless of traffic . I was able to find plenty of articles, documentation, forums, and Wiki’s to assist me. I have a basic understanding of Linux, and I can use the command line. Nano/vim are my preferred command-line text editors, and I know how to SSH to a bash shell from a remote system using the Terminal application, on my MacBook Pro. I decided not to setup mail on my server, as it’s a hassle and can suck resources. Instead I’m going to setup Google Apps to handle my mail. (Post on that to follow later.)

I went with Ubuntu 10.04 LTS Lucid, as it’s an easy to use Linux distribution, and has a strong community following. LTS has more stable packages, and 10.04 includes the most recent software versions. So I started out with a fresh OS install and a root login. First thing I had to do was secure my server and create an administrator user. I gave my user sudo access, I didn’t disable root access till after I finished my task. I waited until the end of the config, in the small chance that I had to use root for some reason. Good thing, because I did. For security reasons, my (ve) server’s /tmp and /var/tmp directories are mounted as nonexec. However, this causes issues with apt-get/aptitude, as it uses /tmp as a “temporary” directory to pre-install scripts. To resolve this issue, I configured apt to not use /tmp and use /var/local/tmp instead. (I needed root to have permissions to write to the apt configuration directory) I could then update Unbuntu with apt-get. I then began to secure my server.

root@ve:~# adduser jabo
root@ve:~# visudo
jabo@ve:~$ sudo apt-get update
jabo@ve:~$ sudo apt-get -u upgrade

Once done, I installed Nginx using apt-get. Restarted, with no errors. I then checked my IP address and I got the happy Nginx ‘Welcome Page.’ Next, I had to prepare the web directory where my sites would be served from. Then add them to the www-data group, as well as my administrator user. I setup the Virtual Hosting of two more domains in Nginx. I then created a virtual host file for Nginx in the sites-available directory, essentially telling Nginx what ports to server traffic and the location of log files for each domain. Restarted Nginx again, and no errors. On to ‘M,’ for MySQL.

jabo@ve:~$ sudo apt-get install nginx
jabo@ve:~$ sudo /etc/init.d/nginx start
jabo@ve:~$ sudo usermod -a -G www-data user1
jabo@ve:~$ sudo chown -R www-data:www-data /var/www
jabo@ve:~$ sudo chmod -R 775 /var/www

MySQL is easy. With Apt-get of MySQL, all I had to do was configure a root user and password. I also created two database users and two databases for my later install of WordPress. PHP was not so easy.

jabo@ve:/var/www$ sudo apt-get install mysql-server php5-mysql mysql-client

In my subconscious, I understood PHP-FPM to mean that I needed to install PHP first, then the PHP-FPM module. This is wrong. With a scratch install you should just go straight to PHP-FPM. I reinstalled my server three times, and changed operating systems. Luckily, I had made back-ups of all the configuration files, so the reinstall, or reverting my server back to default, was painless. Finally, I got it figured out and got the PHP5-FPM service to restart without any errors!

jabo@ve:/var/www$ sudo aptitude install python-software-properties
jabo@ve:/var/www$ sudo add-apt-repository ppa:brianmercer/php
jabo@ve:/var/www$ sudo aptitude -y update
jabo@ve:/var/www$ sudo aptitude -y install php5-cli php5-common php5-mysql php5-suhosin php5-gd
jabo@ve:/var/www$ sudo aptitude -y install php5-fpm php5-cgi php-pear php5-memcache php-apc
jabo@ve:/var/www$ sudo service php5-fpm start

The last step in the whole process was to install WordPress and configure it to talk with the MySQL databases I had created earlier for my domains. After that I did a little bit of Nginx and MySQL tuning. However, I’m leaving that for a later post because I have had my fill of “geek-speak” for the evening. Please enjoy the new domain I created, .

Update: This Blog and the rest of are running on my (ve) 512MB Server.

Launch Day is here!

I launched my website today. Took a week to edit all the files, establish the portal structure, secure my server, and create a blog. I’m still missing my contact page and Gallery, but those pages can wait. I got the essentials. Plus I ran into an issue with the contact form script and I think I’m going to start over. The Gallery just needs pictures. So, at the moment I’m amassing as many web friendly photographs I can find, edit them, and FTP them to my server. Once done I can create the Gallery with SimpleViewer.

I’m using (mt) Media Temple (dv) Dedicated-Virtual Server to power both my site and Blog. My (dv) Dedicated-Virtual Servers is powered by a Hewlett-Packard Proliant DL-Series machines featuring multi-core Intel Xeon processors and high-performance SCSI/SAS disk drives in a RAID-5 configuration. Currently WordPress CMS software runs my Blog. If your interested in a website, hosting, a blog, drop me a line at

Making ground beef Burritos tonight for dinner. Yum! Seasoned with my special “taco” seasoning.

Please, take a look around. Leave a comment. “Kick the tires and Light the Fires” if you will.


Return top