Testing 4 Techno
Hello World, just test Techno :D
Technorati Profile
Technorati Profile
How To Install Drupal 5.6 On Debian Etch With ISPConfig - Page 3
Part B) Multisite Installation
We will use the program core installed on /www/web1/web/.
7. Assumptions And Preparations For Multisite Install:
7.1 System And Software:
Perfect Debian Etch setup with ISPConfig (see Falko's How-To). Thank you Falco.
Drupal core installation according to this How-To, page 1 and page 2.
Note: this set-up should work on all other Linux distros as long as your web directories are stored under /www/web2/web/ or as long as you change relevant commands according to the settings on your server.
7.2 In This How-To I Will Use The Following Names:
Your Drupal multi-website: www.multiexample.tld
Website administrator: admin
MySQL superuser: root
(Note: MySQL root user account was created when you installed MySQL on your server)
MySQL superuser's password: rootpassword
Multisite MySQL database: web2_db1
Multisite MySQL user: web2_u1
Multisite MySQL password: web2password
We will install Drupal 5.6.
8. Create New Multi-Website
First we need to create in ISPConfig a new website www.multiexample.tld, set up its administrator user admin and create its multisite MySQL database.
Go to ISPConfig and create new website: Click ISP Manager=>New site. Fill in all relevant information, for hostname use www and for the domain name multiexample.tld. Enable PHP scripts and MySQL. PHP Safe Mode must not be selected. Do not click save yet as we need to create new user and grant him administrators rights. To do so click: User and Email=>New and set up new user with the name admin. Add an email address and grant to this user administrator rights. Click on Save. We are back on the Basic tab in the window ISP Site. To create a database click on Options=>Database New.
ISPConfig will show you:
Database name: web2_db1
Database user: web2_u1
Create password and click on Save. Once again we are back on the Basic tab in the window ISP Site. Now it is time to save the new website's configuration so click on Save at the bottom.
9. Configure MySQL
Now we need to grant specific privileges to the multisite MySQL user web2_u1.
!!!Important!!!
For administering your Multisite MySQL database use MySQL superuser root and the password rootpassword. Do not use the newly created multisite MySQL user web2_u1! You will need to have enough rights to grant privileges to user web2_u1.
9.1 How To Grant User Privileges Using The Command Line:
mysql -u root -p
You will be prompted for a password. Enter rootpassword.
Now you should see following:
mysql>
Insert:
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON web2_db1.* TO 'web2_u1'@'localhost' IDENTIFIED BY 'web2password';
If successful, MySQL will reply with:
Query OK, 0 rows affected
To activate the new permissions, enter the following command:
FLUSH PRIVILEGES;
Privileges granted. To exit mysql mode press ctrl+z.
10. Install Drupal Multisite
Now you can log out of your ISPConfig. We will get busy on the command line:
10.1 Set Drupal Files
First go to your multi-website root directory:
cd /www/web2/web/
Create symlinks to your Drupal core installation:
ln -s /www/web1/web/includes
ln -s /www/web1/web/misc
ln -s /www/web1/web/modules
ln -s /www/web1/web/profiles
ln -s /www/web1/web/scripts
ln -s /www/web1/web/sites
ln -s /www/web1/web/themes
Next copy files from the Drupal core installation:
cp /www/web1/web/CHANGELOG.txt /www/web2/web/
cp /www/web1/web/cron.php /www/web2/web/
cp /www/web1/web/index.php /www/web2/web/
cp /www/web1/web/INSTALL.mysql.txt /www/web2/web/
cp /www/web1/web/INSTALL.pgsql.txt /www/web2/web/
cp /www/web1/web/install.php /www/web2/web/
cp /www/web1/web/INSTALL.txt /www/web2/web/
cp /www/web1/web/LICENSE.txt /www/web2/web/
cp /www/web1/web/MAINTAINERS.txt /www/web2/web/
cp /www/web1/web/robots.txt /www/web2/web/
cp /www/web1/web/update.php /www/web2/web/
cp /www/web1/web/UPGRADE.txt /www/web2/web/
cp /www/web1/web/xmlrpc.php /www/web2/web/
Next in the Drupal core installation (web1) in the folder /www/web1/web/sites/ create a new folder with name of your domain (without www.):
mkdir /www/web1/web/sites/multiexample.tld
For multi-website (multiexample.tld) we will need its own settings.php file. Without it we will not be able to change the appearance of (multiexamle.tld) independently of the Drupal core website (example.tld). To set settings.php we have to copy our back-up settings.php.multi (remember page 1?) to a new directory. After copying settings.php.multi we will change permissions for it.
cp /www/web1/web/sites/default/settings.php.multi /www/web1/web/sites/multiexample.tld/settings.php
chmod 777 /www/web1/web/sites/multiexample.tld/settings.php
In the multi-website root directory /www/web2/web/ there is ISPConfig's default web page index.html. As Drupal uses index.php we need to rename index.html (alternatively you can delete index.html, but I like to have it ready just 'in case' :-) ):
mv index.html index.html.old
10.2 Set Drupal's MySQL Database
Now we will abandon the shell for a while but do not worry, we will be back. Open your browser and go to your new Drupal website on www.multiexample.tld. If all went right you should see a MySQL Database set-up page. Please insert your details (in our example it is: Multisite MySQL Database Name = web2_db1, Multisite MySQL User Name = web2_u1, Multisite MySQL Password = web2password).
Click Save configuration and if you did it right you will be awarded with a security warning reminding us that we have to change the writing permissions for settings.php back to 644:
10.3 Clean Up
So go back to the shell. You should be in the /www/web2/web/ directory, but if you are not, first you have to go there:
cd /www/web2/web/
And rewrite permissions for settings.php in the multiexample.tld directory:
chmod 644 sites/multiexample.tld/settings.php
Now we will need to create a writeable folder named files for... well, files of the website.
mkdir files
chmod 777 files
Now you can log out of the shell and go back to your browser.
11. Configure New Website
In the browser click on the link your new site (or alternatively write to address bar www.multiexample.tld). You will be awarded with a new page where you will have to create the root user for your new website. After submitting your data you will get a generated password but you will be able to change it for some more memorable. Drupal will automatically send an email with the generated password to your new root user, however Drupal will not send a changed password. So if you change the password make sure that you will remember it. When you finish, on the next page click on the link administration section.
You will see a red banner announcing that some problem with your Drupal installation was detected. Click on the status report link.
If all went right, on the next page you will see just one fault Cron did not run yet. Just click on run cron manually to get rid of the message. But remember, you will have to configure Cron later. (Consult Drupal documentation about this small task.)
12. More Information
And that is it. You have now a fully working Drupal multi-website installation on Debian Etch with ISPConfig. Next you can start to add new content and to customize the look of your new websites. For more info visit Drupal.org and review their documentation.
Previous
How To Install Drupal 5.6 On Debian Etch With ISPConfig - Page 2
4. Install Drupal 5.6
Now you can log out of your ISPConfig. Start up your shell (if you have not started it for MySQL already) as we will get busy on the command line:
4.1 Basic Installation
First go to your web root directory:
cd /www/web1/web/
Download Drupal 5.6
wget http://ftp.drupal.org/files/projects/drupal-5.6.tar.gz
Unpack the tarball:
tar -zxvf drupal-5.6.tar.gz
Move all files from the drupal-5.6 folder to the web root and delete the empty folder drupal-5.6 and the drupal tarball:
cd drupal-5.6
mv * ../
cd ../
rmdir drupal-5.6
rm drupal-5.6.tar.gz
For the installation we need settings.php to be writeable but in the future you may need an unchanged copy of settings.php (if you will ever want to install Drupal multisite). So first we will prepare a copy of the default settings.php file. (Please do it even if you do not want to install Drupal multisite right now. It is not too much work and it will save you lot of hassle in the future, when you decide that you want to have more than one Drupal powered website). After copying settings.php we will change the permissions for the original settings.php:
cd sites/default/
cp settings.php settings.php.multi
chown 1080 settings.php.multi
chgrp 1080 settings.php.multi
chmod 777 settings.php
In the web root directory there is ISPConfig's default web page index.html. As Drupal uses index.php we need to rename index.html (alternatively you can delete index.html, but I like to have it ready just 'in case' :-) ):
cd ../../
mv index.html index.html.old
4.2 Set Drupal's MySQL Database
Now we will abandon the shell for a while but do not worry, we will be back. Open your browser and go to your new Drupal website on www.example.tld. If all went right you should see the MySQL Database set-up page. Please insert your details (in our example it is: New MySQL Database Name = web1_db1, New MySQL User Name = web1_u1, New MySQL Password = web1password).
Click Save configuration and if you did it right you will be awarded with a security warning reminding us that we have to change the writing permissions for settings.php back to 644:
5. Configure A New Website
In the browser click on the link your new site (or alternatively write in the address bar www.example.tld). You will be awarded with a new page where you will have to create the root user for your new website. After submitting your data you will get a generated password but you will be able to change it for some more memorable. Drupal will automatically send an email with the generated password to your new root user, however Drupal will not send changed passwords. So if you change a password make sure that you will remember it. When you finish, on the next page click on the link administration section.
You will see a red banner announcing that some problem with your Drupal installation was detected. Click on the status report link.
If all went right, on the next page you will see just one fault Cron did not run yet. Just click on run cron manually to get rid of the message. But remember, you will have to configure Cron later. (Consult the Drupal documentation about this small task.)
6. Multisite Installation Teaser
And that is it. You have now a fully working Drupal installation on Debian Etch with ISPConfig. And you are ready to start the multisite installation with the same core. The Drupal multisite installation will be the next part of this How-To.
How To Install Drupal 5.6 On Debian Etch With ISPConfig
How To Install Drupal 5.6 On Debian Etch With ISPConfig
Drupal is a PHP based CMS (Content Management System) with great community support and a huge amount of modules. For more info visit Drupal.org.
Drupal can be installed as a single site or it can be installed as a multisite.
Single Site Installation
is a common installation of the program core.
Multisite Installation
use the program core installed on the first website to serve for more websites. This way you can save space on your hard drive because you do not need to install the full Drupal core for each website. Instead you have only one Drupal core installation and you create symlinks from other websites directories to the Drupal core folders.
This How-To
will describe how I installed Drupal on my Debian Etch server with ISPConfig. I am sure that there are other ways how to achieve this goal and probably some are not so tedious as is mine. But this is how I did it and if anybody will point me out to a better route I will take it. Disclaimer: I started with Linux only last October and with Drupal just 5 days ago. I think that from this statement it is clear, that I can not guarantee that this How-To will work for you and neither can I guarantee that it is safe to install Drupal this way.
The first part of this How-To will show you how to install the Drupal core (aka Drupal single site installation).
1. Assumptions And Preparations:
1.1 System And Software:
Perfect Debian Etch setup with ISPConfig (see Falko's How-To). Thank you Falko.
Note: this set-up should work on all other Linux distros as long as your web directories are stored under /www/web1/web/ or as long as you change relevant commands according to the settings on your server.
1.2 In This How-To I Will Use The Following Names:
Your Drupal website: www.example.ltd
website administrator: admin
MySQL superuser: root
(Note: MySQL root user account was created when you installed MySQL on your server)
MySQL superuser's password: rootpassword
New MySQL database: web1_db1
New MySQL user: web1_u1
New MySQL password: web1password
We will install Drupal 5.6
2. Create A New Website
First we need to create in ISPConfig new websitewww.examle.tld, set up its administrator user admin and create its MySQL database.
Go to ISPConfig and create new website: Click ISP Manager=>New site. Fill in all relevant information, for hostname use www and for the domain name example.tld. Enable PHP scripts and MySQL. PHP Safe Mode must not be selected. Do not click save yet as we need to create a new user and grant him administrators rights. To do so click: User and Email=>New and set up a new user with the name admin. Add an email address and grant to this user administrator rights. Click on Save. We are back in the window ISP Site opened on tab Basic. To create a database click on Options=>Database New.
ISPConfig will show you:
Database name: web1_db1
Database user: web1_u1
Create a password and click on Save. Once again we are back in the window ISP Site opened on the tab Basic. Now it is time to save the new website's configuration so click on Save on the bottom.
3. Configure MySQL
Now we need to grant specific privileges to the new MySQL user web1_u1 . We can do it on the shell command line.
!!!Important!!!
Log in to mysql as the MySQL superuser root and with the password rootpassword. Do not use the newly created MySQL user web1_u1! You will need to have enough rights to grant privileges to the user web1_u1.
mysql -u root -p
You will be prompted for a password. Enter rootpassword.
Now you should see the following:
mysql>
Insert:
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON web1_db1.* TO 'web1_u1'@'localhost' IDENTIFIED BY 'web1password';
If successful, MySQL will reply with:
Query OK, 0 rows affected
To activate the new permissions, enter the following command:
FLUSH PRIVILEGES;
Privileges granted. To exit mysql mode press ctrl+z
In the next part we will start the installation
Next
Howto: Connect MySQL server using C program API under Linux or UNIX
How do I write a C program to connect MySQL database server?
MySQL database does support C program API just like PHP or perl.
The C API code is distributed with MySQL. It is included in the mysqlclient library and allows C programs to access a database.
Many of the clients in the MySQL source distribution are written in C. If you are looking for examples that demonstrate how to use the C API, take a look at these clients. You can find these in the clients directory in the MySQL source distribution.
Requirements
Make sure you have development environment installed such as gcc, mysql development package etc. Following is the list summarize the list of packages to compile program:
- mysql: MySQL client programs and shared library
- mysqlclient: Backlevel MySQL shared libraries (old libs)
- mysql-devel: Files for development of MySQL applications (a must have)
- mysql-server: Mysql server itself
- gcc, make and other development libs: GNU C compiler
Sample C Program
Following instructions should work on any Linux distro or UNIX computer. Here is the small program that connects to mysql server and list tables from mysql database.(download link):
/* Simple C program that connects to MySQL Database server*/
#include
#include
main() {
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char *server = “localhost”;
char *user = “root”;
char *password = “PASSWORD”; /* set me first */
char *database = “mysql”;
conn = mysql_init(NULL);
/* Connect to database */
if (!mysql_real_connect(conn, server,
user, password, database, 0, NULL, 0)) {
fprintf(stderr, “%s\n“, mysql_error(conn));
exit(1);
}
/* send SQL query */
if (mysql_query(conn, “show tables”)) {
fprintf(stderr, “%s\n“, mysql_error(conn));
exit(1);
}
res = mysql_use_result(conn);
/* output table name */
printf(“MySQL Tables in mysql database:\n“);
while ((row = mysql_fetch_row(res)) != NULL)
printf(“%s \n“, row[0]);
/* close connection */
mysql_free_result(res);
mysql_close(conn);
}
How do I compile and link program against MySQL libs?
MySQL comes with a special script called mysql_config. It provides you with useful information for compiling your MySQL client and connecting it to MySQL database server. You need to use following two options.
Pass –libs option - Libraries and options required to link with the MySQL client library.
$ mysql_config --libs
Output:
-L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib64 -lssl -lcrypto
Pass –cflags option - Compiler flags to find include files and critical compiler flags and defines used when compiling the libmysqlclient library.$ mysql_config --cflags
Output:
-I/usr/include/mysql -g -pipe -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing
You need to pass above option to GNU C compiler i.e. gcc. So to compile above program, enter:$ gcc -o output-file $(mysql_config –cflags) mysql-c-api.c $(mysql_config –libs)
Now execute program:$ ./output-file
Output:
MySQL Tables in mysql database:
columns_priv
db
func
help_category
help_keyword
help_relation
help_topic
host
tables_priv
time_zone
time_zone_leap_second
time_zone_name
time_zone_transition
time_zone_transition_type
user
References:
- MySQL C API - A must read - official MySQL C API documentation