linux+lighttpd+mysql+php的实现安装配置步骤
1.安装顺序:mysqlàlighttpdàphp
2.配置注意事项:
Lighttpd:
- [root@localhost lighttpd-1.4.30]# vi /etc/init.d/lighttpd
修改的配置点:
if [ -f /etc/sysconfig/lighttpd ]; then
. /etc/sysconfig/lighttpd ---其里的内容为下一个配置文件的路径(LIGHTTPD_CONF_PATH=/usr/local/lighttpd/conf/lighttpd.conf)
fi
if [ -z "$LIGHTTPD_CONF_PATH" ]; then
LIGHTTPD_CONF_PATH="/usr/local/lighttpd/conf/lighttpd.conf "
fi
prog="lighttpd"
lighttpd="/usr/local/lighttpd/sbin/lighttpd "
- [root@localhost lighttpd-1.4.30]# vim /usr/local/lighttpd/conf/lighttpd.conf
修改的配置点:
var.log_root = "/usr/local/lighttpd/log"
var.server_root = "/usr/local/lighttpd"
var.state_dir = "/var/run"
var.home_dir = "/var/lib/lighttpd"
var.conf_dir = "/etc/lighttpd"
server.port = 8090
server.use-ipv6 = "disable"
- [root@localhost ~]# vi /usr/local/lighttpd/conf/modules.conf
修改的配置点:(去掉注释符号)
server.modules = (
"mod_access",
"mod_redirect",
"mod_rewrite",
)
include "conf.d/compress.conf"
include "conf.d/fastcgi.conf"
d . [root@localhost ~]# vi /usr/local/lighttpd/conf/conf.d/fastcgi.conf
修改的配置点:(去掉注释符号和相关内容)
fastcgi.server = ( ".php" =>
( "php-local" =>
(
"socket" => "/tmp/php-fastcgi-1.socket",
"bin-path" => "/usr/local/php-fcgi/bin/php-cgi",---php安装的路径
)
),
( "php-tcp" =>
(
"host" => "127.0.0.1",
"port" => 9999,
"check-local" => "disable",
"broken-scriptfilename" => "enable",
)
),
( "php-num-procs" =>
(
"socket" => "/tmp/php-fastcgi-2.socket",
"bin-path" => "/usr/local/php-fcgi/bin/php-cgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "16",
"PHP_FCGI_MAX_REQUESTS" => "10000",
),
"max-procs" => 5,
"broken-scriptfilename" => "enable",
)
),
)
2.php的安装配置
[root@localhost php-5.2.17]# ./configure --prefix=/usr/local/php-fcgi --enable-fastcgi --enable-force-cgi-redirect --with-iconv --enable-mbstring --with-mysql
注意:
a> 安裝 PHP时可能出现这么一下问题:
checking for specified location of the MySQL UNIX socket…
no checking for MySQL UNIX socket location… /tmp/mysql.sock
configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore!
解决办法:
如果不知道 header file 在哪,用 「find / -name mysql.h」命令找出其位置
如果是自己也有手動安裝 MySQL 套件的話,直接指定該位置。
在 ./configure 下参数指定 header file 的位置(即mysql安装目录),加上如下类似语句:
./configure –with-apxs2=/usr/local/Apache2/bin/apxs –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config
若未找到其位置需安装相应的插件:MySQL-devel-community-5.1.51-1.rhel5.x86_64.rpm
checking for MSSQL support via FreeTDS... no
checking for MySQL support... yes
checking for specified location of the MySQL UNIX socket... no
checking for MySQL UNIX socket location... /var/lib/mysql/mysql.sock
configure: error: Cannot find libmysqlclient under /usr.
Note that the MySQL client library is not bundled anymore!
解决方法:
cp /usr/lib64/libmysqlclient.so /usr/lib/libmysqlclient.so
b> 测试php连接mysql成功时,登陆系统不成功时,可能是把with-iconv写成为【without-iconv】,此时重新执行php安装的所有步骤
php连接mysql测试代码:
b> 运行系统,页面不能呈现而提示:
Warning: Cannot modify header information - headers already sent by
此时修改配置文件php.ini改变output_buffering = off为on并重启服务
3.mysql
- root用户不能进行远程连接,要远程连接需添加一个用户并授权
注意语句一定要带分号 ;
1、登陆mysql数据库
mysql -u root -p
mysql> use mysql;
mysql> select host,user,password from user;
+--------------+------+-------------------------------------------+
| host | user | password |
+--------------+------+-------------------------------------------+
| localhost | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
| 192.168.1.1 | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
+--------------+------+-------------------------------------------+
2 rows in set (0.00 sec)
第一:更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改称'%'。
或者新加条记录,“host” 项为要访问的ip地址,并授权。重启mysql服务。
第二:在系统防火墙添加例外端口:3306,并允许例外。
错误提示:
ERROR 1130: Host '192.168.1.3' is not allowed to connect to this MySQL server
的解决方法:
1。改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
1.mysql -u root -pvmware
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
- 授权法。例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。
GRANT ALL PRIVILEGES ON . TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON . TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
3.在window自带的防火墙里的例外添加3306端口
- MySQL安装完成后不象SQL Server默认安装在一个目录,它的数据库文件、配置文件和命令文件分别在不同的目录,了解这些目录非常重要,尤其对于Linux的初学者,因为Linux本身的目录结构就比较复杂,如果搞不清楚MySQL的安装目录那就无从谈起深入学习。
下面就介绍一下这几个目录。
1、数据库目录
/var/lib/mysql/
2、配置文件
/etc/my.cnf或/usr/share/mysql/my.cnf(mysql.server命令及配置文件)
3、相关命令
/usr/bin(mysqladmin mysqldump等命令)
4、启动脚本
/etc/rc.d/init.d/(启动脚本文件mysql的目录)