Tuesday, February 21, 2012

Configure Apache PHP MySQL on centos

Today, I will use centos minimal to setup a php server with mysql database
1. #yum -y update

2. install packets

yum -y install httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc mysql-connector-odbc mysql-devel libdbi-dbd-mysql

3. start http and mysql service, and set them as auto boot

[[email protected] ~]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
[ OK ]
[[email protected] ~]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
Filling help tables...

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

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 localhost.localdomain password 'new-password'

Alternatively you can run:

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 mysqld: [ OK ]
[[email protected] ~]# chkconfig httpd on
[[email protected] ~]# chkconfig mysqld on


4. configure mysql

set mysql root password:
[[email protected] ~]#mysql -u root password 'your password'

Now we can access the web server with ip address.



If can not access check the status of iptables (linux firewall)
use the following commands to close the iptables:

[[email protected] ~]#service iptables status
[[email protected] ~]#service iptables stop
[[email protected] ~]#chkconfig iptables off

/etc/my.cnf mysql configuration file.
/etc/php.in php configuration file.

use command find to find out file:
find / -name my.cnf

html file dir: /var/www/html

[[email protected] etc]# find / -name mysqladmin
[[email protected] etc]# /var/www/mysql-5.5.2-m2/client/mysqladmin -u root password 'zz'

No comments:

Post a Comment

English study diary

 dictating is a good way to memorise   new words, I dictate words for more than one hour a day  I have to spend more time to practice writing