Webdesignbureau Gorinchem

Single Core for Concrete on a Plesk webserver

What do you need:
Plesk server with root access
A program like Putty or WinSCP

How to:
I’m going to show/tell you how to make all Concrete sites on your Plesk webserver use one single core. This has many advantages if you need to update them yourself. But since you stumbled across this you are probably looking for something like this.

First off, I am going to assume your Plesk webserver has a default setup, if not you probably going to have to change some of the paths. Most of you are not going to have to change anything. Now for step one.

Step 1: Placing the core
The first thing you need to do is logon to your server with SSH, the most used program is Putty, however with WinSCP it is much easier. I’ll describe how to do it with Putty because with WinSCP it is just clicking.

The domains on your Plesk webserver are probably located in: /var/www/vhosts/DOMAINS
So, I choose to place my core in: /var/www/concrete/.
So, here we go login with your root username and password and type:

cd /var/www/
mkdir concrete
cd concrete

Now you are in your core folder, with WinSCP you can just upload the core here, otherwise you can use wget. The trick is to get the core, make a .zip from the content of the core folder. You can do this with WinRAR or Windows. Upload this somewhere and then type the following.

wget http://www.somewhere.com/concrete-core.zip

Obviously you need to change the URL. After this is done you need to unpack the file, type:

unzip concrete-core.zip

So now you have the core files in the previously created folder. Step one is complete.

Step 2: The vhost.conf file
With the core in place we need to go to a domain where concrete is installed. So, for now we will use the domain test.com, in everything you need to enter you need to change test.com to the actual domain you are using. So now we go to the domain we want to use the core we just placed. Type:

cd /var/www/vhosts/test.com/conf/

There should be a file there called httpd.include, leave it there because we are going create an extra file there called vhost.conf. This is a sort of configuration file for Plesk. Again I strongly advise to use WinSCP because you’ll get WordPad like editor which works a lot easier. But I was going to explain it for Putty so type:

touch vhost.conf
vi vhost.conf

Now you created the file and opened the editor. The following lines need to go in to the file.

<Directory /var/www/vhosts/test.com/httpdocs>
 <IfModule sapi_apache2.c>
   php_admin_flag engine on
   php_admin_flag safe_mode off
   php_admin_value open_basedir "/var/www/concrete:/var/www/vhosts/ test.com /httpdocs:/tmp"
 </IfModule>
 <IfModule mod_php5.c>
   php_admin_flag engine on
   php_admin_flag safe_mode off
   php_admin_value open_basedir "/var/www/concrete:/var/www/vhosts/ test.com /httpdocs:/tmp"
 </IfModule>
</Directory>
Alias /concrete/ /var/www/concrete/

So basically what this does is tell apache the domain is allowed to use the files from you core and telling apache that if /concrete/ is called from a document it should look for the file at /var/www/concrete/. Now, you need to save the file, personally I really hate this editor. If you press the Escape key you will go into the command mode. There you’ll need to type:

:wq

to save and quit. This should not follow the text above but should appear al the way at the bottom of you Putty screen. After you have edited the file and saved your work type:

/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=test.com
service httpd restart

This tells apache to reconfigure for the domain. It adds a line in the httpd.include file which loads our custom created file. After that we restart apache just to be sure it gets changed. So, now we have completed step two.

Step 3: Adjusting index.php and removing concrete folder
So, now we have a central concrete core and we adjusted the configuration of our domain to use it.  Now we need to do a small thing. We need to change the index.php file so it looks to our core. This is actually the only file we need to change for this to work. This can be done with a normal PHP editor like Dreamweaver and uploaded with a FTP client. But again I’ll explain it for Putty. Normally the content of the index.php is:

<?php require('concrete/dispatcher.php');

We are going to change this to:

<?php require('/var/www/concrete/dispatcher.php'); ?>

So in order to do this type:

cd /var/www/vhosts/test.com/httpdocs/
vi index.php

Change the index.php and save it like in step 2, press Escape and type:

:wq

The very last thing you need to do is delete the original core folder. Or if you don’t trust you or my work rename is.

To remove it type:

rm –rf /var/www/vhosts/test.com/httpdocs/concrete

To rename type:

mv /var/www/vhosts/test.com/httpdocs/concrete /var/www/vhosts/test.com/httpdocs/concrete_old

Well, congratulations you did it! Your domain is now using the created core. If you want another domain to user the core, just repeat step 2 and 3 and replace test.com by the other domain. You can do this over and over again.