Saturday, October 30, 2010

quick LAMP install in fedora

I wanted to create a database of songs for my band, the stormpigs, and figured I use the Linux Apache Mysql Php (LAMP) stack to do it. Having this goal in mind, here are a few notes on installing apache, mysql, php, phpmyadmin in fedora.

1) install apache
yum install httpd


2) start apache
[root@box /]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName [ OK ]


3) install mysql and mysql-server
[root@ogre /]# yum install mysql mysql-server
Loaded plugins: presto, refresh-packagekit
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.x86_64 0:5.1.47-2.fc12 set to be installed
---> Package mysql-server.x86_64 0:5.1.47-2.fc12 set to be installed
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.47-2.fc12.x86_64
--> Processing Dependency: perl-DBI for package: mysql-server-5.1.47-2.fc12.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.47-2.fc12.x86_64
--> Running transaction check
---> Package perl-DBD-MySQL.x86_64 0:4.017-1.fc12 set to be installed
---> Package perl-DBI.x86_64 0:1.609-3.fc12 set to be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================================
Installing:
mysql x86_64 5.1.47-2.fc12
mysql-server x86_64 5.1.47-2.fc12 updates 9.4 M
Installing for dependencies:
perl-DBD-MySQL x86_64 4.017-1.fc12 updates 161 k
perl-DBI x86_64 1.609-3.fc12 fedora 695 k

Transaction Summary
====================================================================================================================================================================================
Install 3 Package(s)

Total download size: 9.3 M
Installed size: 27 M
Is this ok [y/N]: y


4) start your mysql server
[root@box /]# /etc/init.d/mysql start
or
[root@box /]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h ogre password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

[ OK ]
Starting MySQL: [ OK ]


5) setup mysql database root password
[root@box /]# mysqladmin -u root password 'password'

Sample login:
ip-10-203-5-13:~ # mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 5.1.44b-MariaDB-log SUSE MariaDB RPM

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>


6) install php and phpmyadmin
(installing phpmyadmin installs all you'll need)
[root@box ~]$ sudo yum install phpmyadmin Loaded plugins: presto, refresh-packagekit Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package phpMyAdmin.noarch 0:3.3.7-1.fc12 set to be installed --> Processing Dependency: php-gd >= 5.2.0 for package: phpMyAdmin-3.3.7-1.fc12.noarch --> Processing Dependency: php-mbstring >= 5.2.0 for package: phpMyAdmin-3.3.7-1.fc12.noarch --> Processing Dependency: php-mysql >= 5.2.0 for package: phpMyAdmin-3.3.7-1.fc12.noarch --> Processing Dependency: php >= 5.2.0 for package: phpMyAdmin-3.3.7-1.fc12.noarch --> Processing Dependency: php-mcrypt >= 5.2.0 for package: phpMyAdmin-3.3.7-1.fc12.noarch --> Running transaction check ---> Package php.x86_64 0:5.3.3-1.fc12 set to be installed --> Processing Dependency: php-common = 5.3.3-1.fc12 for package: php-5.3.3-1.fc12.x86_64 --> Processing Dependency: php-cli = 5.3.3-1.fc12 for package: php-5.3.3-1.fc12.x86_64 ---> Package php-gd.x86_64 0:5.3.3-1.fc12 set to be installed --> Processing Dependency: libt1.so.5()(64bit) for package: php-gd-5.3.3-1.fc12.x86_64 ---> Package php-mbstring.x86_64 0:5.3.3-1.fc12 set to be installed ---> Package php-mcrypt.x86_64 0:5.3.3-1.fc12 set to be installed --> Processing Dependency: libmcrypt.so.4()(64bit) for package: php-mcrypt-5.3.3-1.fc12.x86_64 ---> Package php-mysql.x86_64 0:5.3.3-1.fc12 set to be installed --> Processing Dependency: php-pdo for package: php-mysql-5.3.3-1.fc12.x86_64 --> Running transaction check ---> Package libmcrypt.x86_64 0:2.5.8-9.fc12 set to be installed ---> Package php-cli.x86_64 0:5.3.3-1.fc12 set to be installed ---> Package php-common.x86_64 0:5.3.3-1.fc12 set to be installed ---> Package php-pdo.x86_64 0:5.3.3-1.fc12 set to be installed ---> Package t1lib.x86_64 0:5.1.2-5.fc12 set to be installed --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================================================================================================== Package Arch Version Repository Size ==================================================================================================================================================================================== Installing: phpMyAdmin noarch 3.3.7-1.fc12 updates 3.6 M Installing for dependencies: libmcrypt x86_64 2.5.8-9.fc12 fedora 92 k php x86_64 5.3.3-1.fc12 updates 1.1 M php-cli x86_64 5.3.3-1.fc12 updates 2.2 M php-common x86_64 5.3.3-1.fc12 updates 521 k php-gd x86_64 5.3.3-1.fc12 updates 105 k php-mbstring x86_64 5.3.3-1.fc12 updates 452 k php-mcrypt x86_64 5.3.3-1.fc12 updates 30 k php-mysql x86_64 5.3.3-1.fc12 updates 77 k php-pdo x86_64 5.3.3-1.fc12 updates 71 k t1lib x86_64 5.1.2-5.fc12 fedora 153 k Transaction Summary ==================================================================================================================================================================================== Install 11 Package(s) Total download size: 8.3 M Installed size: 31 M Is this ok [y/N]: y

8) inspect the environment
Create a file called phpinfo.php and place it in the webroot of apache, usually /var/www/html
[root@box /]# cat /var/www/html/phpinfo.php
< ? phpinfo();
?>

This is a very nice utility that inspects your php and apache environment showing headers, modules, etc.


9) login to phpMyAdmin
Visit http://localhost/phpmyadmin. You will be prompted to enter the username and password of an authorized user (root, usually).


Those are the basics of a LAMP install. More to come.
TAG

Troubleshooting
If you setup mysql, but not the server component, you'll get this error
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

References
http://www.flmnh.ufl.edu/linux/install_apache.htm
http://wiki.phpmyadmin.net/pma/Welcome_to_phpMyAdmin_Wiki

MySQL Tutorial
Feel free to drop me a line or ask me a question.