Install Parallels Plesk Over SSH

CentOS 6.5 64-bit, Parallels Plesk 12.0.18

I recently had to install Parallels’ Plesk control panel via SSH, and I found it hard getting to a single reference for this process, so here’s my notes for other Googlers.

CentOS

I’m using a default installation of CentOS 6.5 64-bit, from the minimal ISO. I’ve installed CentOS in the quick and dirty fashion, and allowed it to specify the partitions. Here’s my structure;

1
2
3
4
5
6
$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg00-lv_root
                       26G  2.6G   21G  10% /
tmpfs                 939M  8.0K  939M   1% /dev/shm
/dev/sda1             485M   54M  407M  12% /boot

As you can see, I haven’t manipulated the volumes or partitions at all for this process. Note that your system will need at least 1.2GB of disk space for Plesk version 12.0.18. I would recommend that you have at least 2GB free space.

Plesk Installer

We’ll download the Plesk Installer using wget. You will need that first if you haven’t installed it yet (it’s not installed on the minimal CentOS distro).

1
$ sudo yum install wget

Once wget in installed, switch to the /tmp directory and grab the Plesk Installer.

1
2
$ cd /tmp
$ sudo wget http://autoinstall.plesk.com/plesk-installer

Once the download has completed, you will want to make the installer executable.

1
$ sudo chmod +x plesk-installer

Installation

You are ready to go with the installer. It’s up you whether to use the web interface or not. Personally, I prefer working from the terminal, but it’s your choice. If you are working on a local server, it makes more sense to use the web interface, otherwise, I wouldn’t bother.

If you do go with the web interface, ensure that you can reach your server via the IP address or a qualified domain name. Otherwise, stick to the terminal.

Via the terminal (raw):

1
$ sudo ./plesk-installer

Using the web interface (gui):

1
$ sudo ./plesk-installer --web-interface

Follow the numerous on-screen prompts for your preference and the installer will do the rest.

read more

Add A WordPress User Manually To The Database

WordPress 4.0, Direct Access To The MySQL Database

Recently I needed to gain access to a hacked WordPress installation. I didn’t have any usernames or passwords for the dashboard. Here’s a manual way that I used to create a user account, which sysadmins may find useful. Hang on; if you’re a hacker, stop reading, go have a shower (and a shave) and start a real relationship with an actual person; you might like it.

WP Users Table

Let’s begin by getting into the MySQL command line.

1
2
3
4
5
6
7
8
9
10
11
$ ssh me@1.2.3.4
...
$ mysql -u me -p
Enter password:
...
mysql> use wordpress;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql>

First, we need to add a user record to the wp_users table. By default, WordPress encodes the password so that they are safely stored away from prying eyes. The method that does that is in the WordPress core, and we could access and run our password through it, but that’s a lot of work, and I’m feeling lazy.

Instead, we’re going to rely on WordPress’ legacy support, and create an md5’ed password. WordPress will automatically scramble it up for us after login – yay! Using any PHP terminal, or an online editor, echo your password as an md5’ed string.

1
2
echo md5('password');
0fd23718b64688a8f4e6c0576ce1f551 // <-- your password string

Make a note of the password you used! Now that you have your password string, we’ll add the row to the database table, wp_users. The values you need are as follows (I’m adding a user named support, with administrator privileges).

1
2
3
4
INSERT INTO wp_users
    (user_login,user_pass,user_email,user_registered,display_name,user_nicename)
VALUES
    ('support','0fd23718b64688a8f4e6c0576ce1f551','me@myserver.com','01-01-2014 00:00:01','support','support');

For the uninitiated, that query looks like this in the terminal.

1
2
mysql> INSERT INTO wp_users (user_login,user_pass,user_email,user_registered,display_name,user_nicename) VALUES ('support','0fd23718b64688a8f4e6c0576ce1f551','me@myserver.com','01-01-2014 00:00:01','support','suport');
Query OK, 1 row affected (0.00 sec)

That creates the user record.

Privileges

Next we need to create some permissions, or we can’t do anything. We’ll need to add two entries to the wp_usermeta table. However, before we do that, we need to know the ID of the user we just created.

1
2
3
4
5
6
7
8
mysql> SELECT ID, user_login FROM wp_users;
+----+------------+
| ID | user_login |
+----+------------+
|  1 | admin      |
|  2 | support    |
+----+------------+
2 rows in set (0.00 sec)

So, our new user has the ID of 2. Now we can do the privileges.

1
2
3
4
5
6
mysql> INSERT INTO wp_usermeta (user_id,meta_key,meta_value) VALUES ('2','wp_user_level','10');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO wp_usermeta (user_id,meta_key,meta_value) VALUES ('2','wp_capabilities','a:1:{s:13:"administrator";b:1;}');
Query OK, 1 row affected (0.00 sec)

mysql> exit

That is the permissions bit complete.

Login

You’re all done, and you can proceed to login to WordPress as usual.

If anything, this little trick really highlights the need for good database security. If an attacker gains access to the database directly, you can kiss the site goodbye! Happy erm, hacking.

read more

Add Custom Product Tab In Magento 1.9 CE

Magento 1.9 CE

Very often we want to add additional tabs to Magento’s product page(s). The Additional Information tab only goes so far! We begin by creating a new attribute in Magento. We’ll utilise a CMS block that gives us control over the content from Magento’s admin interface in a familiar way.

Magento First

Navigate to Catalog > Attributes > Manage Attributes and click on Add New Attribute. Enter an attribute code and be sure to specify Text Field for the Catalog Input Type… option. Fill in the remaining details to your preference.

Next, assign the attribute to an attribute set; navigate to Catalog > Attributes > Manage Attribute Sets. Choose a set and drag your new attribute into the Groups list. Save that, re-index the catalog, and proceed to create a CMS block at CMS > Static Blocks > Add New Block. Create a new block, and take note of the block identifier.

Once your block has been created, move to create/edit a product. In the create/edit product view, locate your new attribute and populate it with the identifier of your new CMS block. In my case, sizes_table.

The Code

In your theme’s design path, open the catalog xml file. We’re going to add a custom tab, in my case a size guide table, to appear immediately after the product description tab. First, locate the code for the product description tab, which looks like this:

app/design/frontend/[theme]/default/layout/catalog.xml

1
2
3
4
<block type="catalog/product_view_description" name="product.description" as="description" template="catalog/product/view/description.phtml">
    <action method="addToParentGroup"><group>detailed_info</group></action>
    <action method="setTitle" translate="value"><value>Description</value></action>
</block>

In my theme, it runs from lines 225 through 228. Now add your own “tab” code afterwards:

app/design/frontend/[theme]/default/layout/catalog.xml

1
2
3
4
<block type="catalog/product_view_attributes" name="product.sizes" as="sizes" template="catalog/product/view/sizes.phtml">
    <action method="addToParentGroup"><group>detailed_info</group></action>
    <action method="setTitle" translate="value"><value>Size Guide</value></action>
</block>

Now we need to create the custom view at catalog/product/view/sizes.phtml to perform the logic. You might want to get more creative with your names!

app/design/frontend/[theme]/default/template/catalog/product/view/sizes.phtml

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
$_product = $this->getProduct();
$attribute = $_product->getResource()->getAttribute('sizes_table');
if ( is_object($attribute) ) {
  $identifier = $_product->getData("sizes_table");
}
?>

<?php if ($_sizeBlock = Mage::app()->getLayout()->createBlock('cms/block')->setBlockId($identifier)): ?>
    <div class="std">
        <?php echo $_sizeBlock->toHtml() ?>
    </div>
<?php endif; ?>

Upload those files to the server, and you are done. You can now edit the CMS block with any content you want it to contain. The best part about this approach is that Magento is building the tab in the same way as any other, so the markup is the same. Ideal if you have, or intend to use, a custom theme.

read more