//-------------------------------------------------------// //------- lamp presentation at austin linux meetup ------// //---------- by bob carnaghi & jason schonberg ----------// //---------- june 7, 2010 ----------// //-------------------------------------------------------// //---------- install-per-rpm section ----------// `whereis {php | mysql | httpd}` `rpm -qa | grep {php | mysql | httpd}` `yum search {php | mysql | httpd}` `yum -y install {php* | mysql* | httpd*}` `yum grouplist` `yum groupinfo {x | y | z}` `yum -y groupinstall {x | y | z}` `service {mysqld | httpd} {start | stop | reload}` //-------------------------------------------------------// //---------- the short version ----------// `yum -y install mysql-server` `yum -y install httpd` `yum -y install php` `service mysqld start` `chkconfig mysqld on` `service httpd start` `chkconfig httpd on` //-------------------------------------------------------// //---------- install mysql ----------// //---------- mysql reference ----------// http://www.mysql.com/ http://dev.mysql.com/doc/ http://dev.mysql.com/doc/refman/5.0/en/ mysql "world" database http://dev.mysql.com/doc/world-setup/en/world-setup.html https://launchpad.net/test-db/ //---------- mysql backup resources ----------// http://www.zmanda.com/quick-mysql-backup.html http://dannyman.toldme.com/2006/08/22/mysql-backup-grant-privileges/ //---------- starting mysql first time ----------// --> service mysqld start Initializing MySQL database: Installing MySQL system tables... OK Filling help tables... OK ... SET A PASSWORD FOR THE MySQL root USER start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h gancio password 'new-password' login to mysql: `mysql -u root -p` (provide the password when prompted) general stuff: `mysql> show databases;` query the user database mysql> `select host,user from mysql.user` NOTE the empty fields for localhost and localhost.localdomain using a specific database: `use mysql;` removing the test databases and anonymous user created by default. This is strongly recommended for production servers. remove the anonymous accounts: `mysql> DROP USER ''@'localhost';` `mysql> DROP USER ''@'hostname';` etc. delete the test database `mysql> DROP DATABASE test;` `mysql> show databases` //---------- quitting the mysql client ----------// `mysql> quit` //---------- backing up mysql ----------// create a mysql backup operator Q: What privileges must I grant to a MySQL user to allow them to run mysqldump? A: LOCK TABLES, SELECT seems to do the trick. Example: GRANT LOCK TABLES, SELECT ON mydatabase.* TO 'backup'@'backuphost' IDENTIFIED BY 'somecoolpassword'; Principle of least-privilege: don’t entrust your backup host with the power to hurt the database if you don’t have to. SELECT allows the user to read data, and LOCK TABLES allows the user to lock the tables while running a “snapshot” . . . and of course, narrow the privileges to a specific user-host-password tuple. //---------- ----------// mysql> CREATE USER 'backup'@'localhost'; mysql> CREATE USER 'backup'@'gancio'; mysql> SET PASSWORD FOR 'backup'@'localhost' = PASSWORD('backup_2day'); mysql> SET PASSWORD FOR 'backup'@'gancio' = PASSWORD('backup_2day'); mysql> GRANT LOCK TABLES, SELECT ON *.* TO 'backup'@'localhost' IDENTIFIED BY 'backup_2day'; mysql> GRANT LOCK TABLES, SELECT ON *.* TO 'backup'@'gancio' IDENTIFIED BY 'backup_2day'; shell> mysqldump --add-drop-database --add-drop-table -c -e --create-options -u backup -pbackup_2day world > world.sql.bak FLUSH PRIVILEGES; mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost' -> WITH GRANT OPTION; mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%' -> WITH GRANT OPTION; mysql> CREATE USER 'admin'@'localhost'; mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost'; mysql> CREATE USER 'dummy'@'localhost'; FLUSH PRIVILEGES; //---------- the mysqldump facility ----------// mysqldump --add-drop-table -u root -p teacher > /home/backup/teacher.sql mysqldump --add-drop-database --add-drop-table -c -e --create-options -u root -p ht-1 > ht-1.sql.bak mysqldump --add-drop-database --add-drop-table --complete-insert --extended-insert --create-options -u root -p world > world.sql.bak mysqldump --add-drop-database --add-drop-table --complete-insert --extended-insert --create-options -u root -p world > world.sql.bak //---------- mysql load data infile ----------// http://dev.mysql.com/doc/refman/5.1/en/load-data.html //-------------------------------------------------------// //---------- additional mysql stuff ----------// To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system test the MySQL daemon with mysql-test-run.pl cd mysql-test ; perl mysql-test-run.pl //---------- mysql reference ----------// mysql - initial setup & reset root password http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html http://dev.mysql.com/doc/refman/5.0/en/security-guidelines.html http://dev.mysql.com/doc/refman/5.0/en/default-privileges.html alternate method to set password for root user shell> `mysql -u root` mysql> `SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');` mysql> `SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');` //-------------------------------------------------------// //---------- install apache ----------// `yum -y install httpd` //---------- configure apache ----------// config files: '/etc/httpd/conf/httpd.conf' //---------- apache reference ----------// www.apache.org Hardening Apache ISBN: 1590593782 http://www.amazon.com/Hardening-Apache-Tony-Mobily/dp/1590593782/ref=sr_1_1?ie=UTF8&s=books&qid=1275784515&sr=1-1 //-------------------------------------------------------// //---------- install php ----------// //---------- php reference ----------// http://www.php.net/ http://www.php.net/manual/en/ http://www.php.net/manual/en/ini.php http://pear.php.net/ //---------- configure php ----------// config file: '/etc/php.ini' '/etc/php.d/' //---------- test php ----------// create file '/var/www/html/test.php' with the following content: load file in browser //---------------------------------------------------------// //--------- phpmyadmin ---------// download the source {/usr/local/src/phpmyadmin} http://sourceforge.net/projects/phpmyadmin/files%2FphpMyAdmin%2F2.11.10%2FphpMyAdmin-2.11.10-english.tar.gz/download#!md5!e010375975ad03543bbba991dc11f091 `cd /usr/local/src/phpmyadmin` unzip: `tar xvzf xyz` //---------------------------------------------------------// //--------- webmin ---------// download the source {/usr/local/src/webmin} `cd /usr/local/src/webmin` unzip: `tar xvzf xyz` perl-Crypt-SSLeay.i386 : Crypt::SSLeay - OpenSSL glue that provides LWP https support perl-Net-SSLeay.i386 : Perl extension for using OpenSSL //-------------------------------------------------------// //---------- ----------// //-------------------------------------------------------//