Installing a Web and DB servers (CentOS 5.5)
Create records on dns1 (master) for web and database servers:
rnd freeze mydomain.local
Edit /var/named/chroot/etc/named.conf
Add the following records:
web1 A 192.168.1.112
db1 A 192.168.1.113
112 PTR web1
113 PTR db1
www CNAME web1
rndc thaw mydomain.local
rndc reload
Build Web server web1 using the server package with web server only.
Install php with support for MySQL
yum install php php-mysql
Edit web1 configuration for server name and port:
vi /etc/httpd/confd/httpd.conf
Listen 192.168.1.112:80
ServerName www.mydomain.local:80
Set web service to automatic startup:
/sbin/chkconfig –level 35 httpd on
/sbin/chkconfig –list httpd
Create html and php test pages;
touch /var/www/html/index.html
touch /var/www/html/phpinfo.php
Edit html and php pages
vi /var/www/html/index.html
Add the following code:
hello world!
vi /var/www/html/phpinfo.php
hello world!
vi /var/www/html/phpinfo.php
Add the following code:
phpinfo()
Start web service:
/etc/init.d/httpd start
Test web server for static and dynamic pages. Open web browser and visit the following urls.
note: Ensure that php page displays a section for MySQL.
Configure firewall on web1 to allows web access from clients and to connect to db1
system-config-sevuritylevel-tui
Enable Security Level
Set SELinux to Permissive
Set eth0 as trusted devices (customize button)
Note: SELinix must be set to Permissive or access will be denied.
Build DB server db1 using server package with MySQL only.
Configure server to accept remote connections by adding a bind-address directive that points to the IP address of db1 (this is no needed anymore)
vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
# Enabling remote connections
bind-address=192.168.1.113
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
Configure DB service for automatic startup:
/sbin/chkconfig –level 35 mysqld on
/sbin/chkconfig –list mysqld
Start Db service:
/etc/init.d/mysqld start
Configure firewall on db1 to accept connections from web1
system-config-sevuritylevel-tui
Enable Security Level
Set SELinux to Enforcing
Set eth0 as trusted devices (customize button)
Test DB server by installing an application that uses php and MySQL.
Installing Wordpress.
On web1
cd /var/www/html/
yum install wget
tar -xzvf latest.tar.gz
mv wordpress blog
On db1
Configure password for mysqld root admin account:
mysqladmin – u root password Passw0rd
Create database for Wordpress:
mysql –u root –p
CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO “wpuser”@”192.168.1.112” IDENTIFIED BY “Pasw0rd”;
FLUSH PRIVILEGES;
EXIT
Note: 192.168.1.112 is the IP address of web1, the host from where we want to connect to db1. wpuser is the database user and wordpress is the database name.
On web1
Configure installation script for Wordpress:
cd /var/www/html/blog
cp wp-config-sample.php wp-config.php
vi wp-config.php
Edit this file as follows:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'wpuser');
/** MySQL database password */
define('DB_PASSWORD', 'Passw0rd');
/** MySQL hostname */
define('DB_HOST', 'db1.mydomain.local');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
note: db1.mydomain.local points to db1 (192.168.1.113)
Open a web browser and start Wordpress installation by entering the url:
It should display the Wordpress intallation web page that confirms that web1 is communicating with db1 and our servers are working properly.
References: