Linux下APACHE2 + PHP5 + MYSQL5 + PHPMYADMIN 安装配置

我的坐骑是GENTOO,所以用Gentoo测试的,我也有一个FC6在机器上,如果要装软件用yum install很方便的,只要有一个网线连到网上,这年头还有办不了的事情?

# emerge -av phpmyadmin


These are the packages that would be merged, in order:

Calculating dependencies… done!

[ebuild N ] app-admin/webapp-config-1.50.15 95 kB

[ebuild N ] dev-db/mysql-5.0.26-r1 USE="berkdb perl ssl
-big-tables -cluster -debug -embedded -extraengine -latin1 -max-idx-128
-minimal (-selinux) -srvdir -static" 25,381 kB

[ebuild N ] perl-core/Sys-Syslog-0.18 51 kB

[ebuild N ] dev-perl/Net-Daemon-0.39 31 kB

[ebuild N ] app-misc/mime-types-5 7 kB

[ebuild N ] dev-libs/libmcrypt-2.5.7 512 kB

[ebuild N ] app-admin/php-toolkit-1.0-r2 0 kB

[ebuild N ] media-libs/t1lib-5.0.2 USE="X -doc" 1,658 kB

[ebuild N ] virtual/mysql-5.0 0 kB

[ebuild N ] dev-perl/PlRPC-0.2018 18 kB

[ebuild N ] net-www/apache-2.0.58-r2 USE="apache2 ldap ssl -debug
-doc -mpm-itk -mpm-leader -mpm-peruser -mpm-prefork -mpm-threadpool
-mpm-worker (-selinux) -static-modules -threads" 4,652 kB

[ebuild N ] dev-perl/DBI-1.52 410 kB

[ebuild N ] dev-lang/php-5.1.6-r6 USE="apache apache2 berkdb cgi
cli crypt ftp gdbm iconv ipv6 ldap mysql ncurses nls pcre readline
reflection session spell spl ssl truetype unicode xml zlib (-adabas)
-bcmath (-birdstep) -bzip2 -calendar -cdb -cjk -concurrentmodphp -ctype
-curl -curlwrappers -db2 -dbase (-dbmaker) -debug -discard-path -doc
(-empress) (-empress-bcs) (-esoob) -exif -fastbuild (-fdftk) (-filepro)
-firebird -flatfile -force-cgi-redirect (-frontbase) -gd -gd-external
-gmp -hardenedphp -hash -hyperwave-api -imap (-informix) -inifile
-interbase -iodbc -java-external -kerberos -libedit -mcve -memlimit
-mhash -ming -msql -mssql -mysqli -oci8 (-oci8-instant-client) -odbc
-pcntl -pdo -pdo-external -pic -posix -postgres -qdbm -recode -sapdb
-sasl -sharedext -sharedmem -simplexml -snmp -soap -sockets (-solid)
-sqlite (-sybase) (-sybase-ct) -sysvipc -threads -tidy -tokenizer
-vm-goto -vm-switch -wddx -xmlreader -xmlrpc -xmlwriter -xpm -xsl -yaz
-zip" 6,329 kB

[ebuild N ] dev-db/phpmyadmin-2.9.1.1 USE="-vhosts" 1,510 kB

[ebuild N ] dev-perl/DBD-mysql-3.0007 114 kB

Total: 15 packages (15 new), Size of downloads: 40,761 kB

Would you like to merge these packages? [Yes/No]

Apache设置

起动 Apache:
# /etc/init.d/apache2 start

* Starting apache2 …
apache2: Could not determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName

*如果看到如上字样,这是把服务器域名直接用127.0.0.1

让系统起动时自动起动 Apache:
# rc-update add apache2 default

配置文件
# vi /etc/apache2/httpd.conf

然后在这个文件的第120行,你会发现"Listen 80" 80是默认的端口。如果想更改端口,把这个80改成你想要的端口,当然在你用浏览器浏览的时候也不要忘了加上端口。
如果设置 Listen 90 。测试打开http://127.0.0.1:90/即可。

默认目录在/var/www/localhost/
打开http://127.0.0.1/测试,如果你看到 test page for apache installation 就说明安装配置成功了。

成功的画面

没有成功的话看看
# vi /etc/conf.d/apache2

有没有这句,没有的话加上就好了。
APACHE2_OPTS="-D DEFAULT_VHOST -D PHP5"

mysql 配置

#mysql_install_db
#/etc/init.d/mysql start

让系统起动时自动起动 MYSQL:
# rc-update add mysql default

配置密码
mysqladmin -u root password ‘你的密码’
也可以这样如:
mysqladmin -u root -p password 123456
*mysqladmin -u root -h localhost password ‘你的密码’ (这个还没发现有什么用)

回车出现
Enter password: ( 注:这是叫你输入原密码. 刚安装时密码为空,所以直接回车即可)

PHP 加载 MYSQL 扩展:
# vi /etc/php/apache2-php5/php.ini
在该文件中加入以下设置, 566行处:
加入extension=mysql.so,或者把这句前面的;(分号)去掉即可。

测试MYSQL:

#mysql
#mysql> SHOW DATABASES;

$ mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 17 to server version: 5.0.26-log

Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.

mysql> SHOW DATABASES;
+——————–+
| Database |
+——————–+
| information_schema |
| test |
+——————–+
2 rows in set (0.00 sec)

mysql>

如上输入说明正确。用exit退出就可以了。

查看输出信息
#mysqladmin status

如下的话,说明正常:
~ $ mysqladmin status

Uptime: 280 Threads: 1 Questions:
1 Slow queries: 0 Opens: 12 Flush tables: 1 Open tables: 6 Queries per
second avg: 0.004

*如果这样的话说明不正常:
localhost# mysqladmin status

mysqladmin: connect to server at ‘localhost’ failed
error: ‘Access denied for user ‘root’@’localhost’ (using password: NO)

mysql_fix_privilege_tables

This script updates all the mysql privilege tables to be usable by
MySQL 4.0 and above.

This is needed if you want to use the new GRANT functions,
CREATE AGGREGATE FUNCTION, or the more secure passwords in 4.1

Got a failure from command:
/usr/bin/mysql –no-defaults –force –user=root –host=localhost –database=mysql
Please check the above output and try again.

Running the script with the –verbose option may give you some information
of what went wrong.

If you get an ‘Access denied’ error, you should run this script again and
give the MySQL root user password as an argument with the –password= option


phpmyadmin的安装配置

些这个部分可用了1个多小时,妈的!干!

#cd /var/www/localhost/htdocs/phpmyadmin
#sudo cp config.sample.inc.php config.inc.php

# equery files phpmyadmin | grep config.default.php
可以得到
/usr/share/webapps/phpmyadmin/2.9.1.1/htdocs/libraries/config.default.php
这是个config的默认配置
or
(sudo)
cp
/usr/share/webapps/phpmyadmin/2.9.1.1/htdocs/libraries/config.default.php
/var/www/localhost/htdocs/phpmyadmin/config.inc.php

要看这两个网页:
http://wiki.cihar.com/pma/Quick_Install
http://wiki.cihar.com/pma/Config

现在测试是否可用
http://127.0.0.1/phpmyadmin/index.php


看到如上错误,是因为没有添加$cfg[‘blowfish_secret’] = 值

#vi config.default.php (/var/www/localhost/htdocs/phpmyadmin/config.inc.php)
$cfg[‘blowfish_secret’] = ‘任意值’;* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

$cfg[‘Servers’][$i][‘controluser’] = ‘root’;
$cfg[‘Servers’][$i][‘controlpass’] = ‘mysql相同密码’; /*(不然进入不了很奇怪,稍后解决一下)

到目前位置这个文章就算结束了。稍后补充一些解决方案,然后作为一个参考资料,转载请写出处: 转自Moo Vision
我花了3-4个多小时些这个东西呢!他妈的!我不务正业了!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s