- This page documents the steps I took in building an application with PHP5 on Apache 2 and MySQL5 back end on Red Hat Enterprise Linux 5.0
- Be sure to set hostname (r4rhela10.setc.com in this example) and add an entry in hosts for that hostname- Install Apache httpd-2.2.3-6.el5 and PHP php-5.1.6-5.el5- Customize - Add user Web with default home directory (/home/web); set password to "web"- As root: useradd web; passwd web [web]- Fix permissions on /home directories- As root: chmod 755 /home/web;
- Add user Web with default home directory (/home/web); set password to "web"- As root: useradd web; passwd web [web]- Fix permissions on /home directories- As root: chmod 755 /home/web;
- Remove any mysql packages with rpm -e (use rpm -qa|grep -i mysql to see installed packages)- As root, rpm -iv following files from RHEL5 installation DVD in the order listed: - perl-DBI-1.52-1.fc6.x86_64.rpm- perl-DBD-MySQL-3.0007-1.fc6.x86_64.rpm- mysql-5.0.22-2.1.x86_64.rpm - mysql-server-5.0.22-2.1.x86_64.rpm- php-pdo-5.1.6-5.el5.x86_64.rpm- php-mysql-5.1.6-5.el5.x86_64.rpm- Make mysqld start upon boot: chkconfig --level 35 mysqld on - Start mysqld: service mysqld start- Check: mysqladmin --password=(rootpw) status
- perl-DBI-1.52-1.fc6.x86_64.rpm- perl-DBD-MySQL-3.0007-1.fc6.x86_64.rpm- mysql-5.0.22-2.1.x86_64.rpm - mysql-server-5.0.22-2.1.x86_64.rpm- php-pdo-5.1.6-5.el5.x86_64.rpm- php-mysql-5.1.6-5.el5.x86_64.rpm
- Create user Web and remove anonymous user created by default installation #mysql --password=(rootpw)mysql> grant all privileges on *.* to web@localhost identified by 'web';mysql> grant all privileges on *.* to web@r4rhela10.setc.com identified by 'web';mysql> delete from mysql.user where User='';- Modify configuration file - Copy /usr/share/doc/mysql-server-5.0.22/my-large.cnf to /etc/my.cnf.1GB, apply edits in my.cnf.example.diff from ds2 MySQL kit- As root: cd /etc; mv my.cnf my.cnf.orig; cp my.cnf.1GB my.cnf- Optionally, add following line to mysqld section: log=/var/lib/mysql/mysql_query.log- To put new CNF file into effect: - shut down mysqld with service mysqld stop- Assuming you don't need data in mysql file, in /var/lib/mysql, remove - ibdata1, ib_logfile*, mysql-bin*- service mysqld start - To use log file, before starting MySQL: cd /var/lib/mysql;touch mysql_query.log;chown mysql.mysql mysql_query.log; chmod 644 mysql_query.log (still needed?)
#mysql --password=(rootpw)mysql> grant all privileges on *.* to web@localhost identified by 'web';mysql> grant all privileges on *.* to web@r4rhela10.setc.com identified by 'web';mysql> delete from mysql.user where User='';
- Copy /usr/share/doc/mysql-server-5.0.22/my-large.cnf to /etc/my.cnf.1GB, apply edits in my.cnf.example.diff from ds2 MySQL kit- As root: cd /etc; mv my.cnf my.cnf.orig; cp my.cnf.1GB my.cnf- Optionally, add following line to mysqld section: log=/var/lib/mysql/mysql_query.log
- shut down mysqld with service mysqld stop- Assuming you don't need data in mysql file, in /var/lib/mysql, remove - ibdata1, ib_logfile*, mysql-bin*- service mysqld start
- ibdata1, ib_logfile*, mysql-bin*
cd /var/lib/mysql;touch mysql_query.log;chown mysql.mysql mysql_query.log; chmod 644 mysql_query.log (still needed?)
- Copy tarballs (ds2.tar.gz and ds2_mysql.tar.gz) from http://linux.dell.com/dvdstore to /home/web/ and extract with tar xzf- This creates /home/web/ds2 and subdirectories- Either leave contents of /home/web/data_files alone (for small [10 MB] database) or copy over medium (1 GB) or large (100 GB) files- To build and load database, as web: sh mysqlds2_create_all.ksh
Contents of mysqlds2_create_all.sh:# mysqlds2_create_all.sh# start in ./ds2/mysqlds2cd buildmysql -u web --password=web < mysqlds2_create_db.sqlmysql -u web --password=web < mysqlds2_create_ind.sqlmysql -u web --password=web < mysqlds2_create_sp.sqlcd ../load/custmysql -u web --password=web < mysqlds2_load_cust.sqlcd ../ordersmysql -u web --password=web < mysqlds2_load_orders.sql mysql -u web --password=web < mysqlds2_load_orderlines.sql mysql -u web --password=web < mysqlds2_load_cust_hist.sql cd ../prodmysql -u web --password=web < mysqlds2_load_prod.sql mysql -u web --password=web < mysqlds2_load_inv.sql- To test: [web@r4rhela10 ~/ds2/mysqlds2]$ mysql --password=webWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 12 to server version: 5.0.22Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> use DS2Database changedmysql> select count(*) from CUSTOMERS;+----------+| count(*) |+----------+| 2000000 | +----------+1 row in set (2.64 sec)mysql> select count(*) from PRODUCTS;+----------+| count(*) |+----------+| 100000 | +----------+1 row in set (0.00 sec)
Contents of mysqlds2_create_all.sh:# mysqlds2_create_all.sh# start in ./ds2/mysqlds2cd buildmysql -u web --password=web < mysqlds2_create_db.sqlmysql -u web --password=web < mysqlds2_create_ind.sqlmysql -u web --password=web < mysqlds2_create_sp.sqlcd ../load/custmysql -u web --password=web < mysqlds2_load_cust.sqlcd ../ordersmysql -u web --password=web < mysqlds2_load_orders.sql mysql -u web --password=web < mysqlds2_load_orderlines.sql mysql -u web --password=web < mysqlds2_load_cust_hist.sql cd ../prodmysql -u web --password=web < mysqlds2_load_prod.sql mysql -u web --password=web < mysqlds2_load_inv.sql
[web@r4rhela10 ~/ds2/mysqlds2]$ mysql --password=webWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 12 to server version: 5.0.22Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> use DS2Database changedmysql> select count(*) from CUSTOMERS;+----------+| count(*) |+----------+| 2000000 | +----------+1 row in set (2.64 sec)mysql> select count(*) from PRODUCTS;+----------+| count(*) |+----------+| 100000 | +----------+1 row in set (0.00 sec)
- Set Apache to start upon system boot. As root: chkconfig --level 35 httpd on- Modify /etc/httpd/conf/httpd.conf: KeepAlive OnKeepAliveTimeout 50ServerName r4rhelm605a10:80 AddType application/x-httpd-php .php- Make following changes to PHP config file /etc/php.ini for MySQL: uncomment error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERRORcomment out error_reporting = E_ERRORdisplay_errors = Onmysqli.default_host = r4rhelm605a10mysqli.default_user = webmysqli.default_pw = web- Start Apache: service httpd start
KeepAlive OnKeepAliveTimeout 50ServerName r4rhelm605a10:80 AddType application/x-httpd-php .php
uncomment error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERRORcomment out error_reporting = E_ERRORdisplay_errors = Onmysqli.default_host = r4rhelm605a10mysqli.default_user = webmysqli.default_pw = web
dsbrowse.php, dslogin.php,dspurchase.php, dscommon.inc, dsnewcustomer.php, index.html
mysql> show create table CUSTOMERS; // to show Create statement that would be used to create CUSTOMERSmysql> select table_name, engine from information_schema.tables where table_schema='ds2';