Installing Apache, PHP, and MySQL on rhel5.1
This will install the basic components for a dynmaic, database-driven web site. We use
Yum to handle dependencies and gather all of the required packages.
1. install Apache (httpd), PHP, MySQL (server and client), and the component that allows
PHP to talk to MySQL.
Yum-y install httpd PHP MySQL mysql-server PHP-MySQL
2. Configure the new services to start automatically
/Sbin/chkconfig httpd on
/Sbin/chkconfig -- add mysqld
/Sbin/chkconfig mysqld on
/Sbin/service httpd start
/Sbin/service mysqld start
3. Important! Set up the MySQL Database Root Password. Without
Password, any user on the box can login to MYSQL as database root.
MySQL Root Account is a separate password from the machine Root
Account.
Mysqladmin-u Root Password 'new-password' [quotes are required]
4. Make additional security-related changes to MySQL.
Mysql-u root-P
Mysql> drop database test; [Removes the test database]
Mysql> Delete from mysql. User where user = ''; [Removes Anonymous Access]
Mysql> flush privileges;
5. Following the above steps, the document root for Apache is/var/www/html/
Create a test PHP script (such as phpinfo. php) and place it in the document root. A useful
Test script sample:
<? PHP
Phpinfo ();
?>
6. Create a database and database user for your data. You will use this database and user name
In your database connection string. The grant statement actually creates a new MySQL user account.
mysql> Create Database web_db;
mysql> grant all privileges on web_db. * To 'web _ user' @ 'localhost' identified by 'thepassword';