php5.5安装及phpmyadmin&nginx配置php模块
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php5.5安装及phpmyadmin&nginx配置php模块相关的知识,希望对你有一定的参考价值。
安装php5.5;
下载源地址:rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
rpm包安装:yum install php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-ldap.x86_64 php55w-mbstring.x86_64 php55w-mcrypt.x86_64 php55w-mysql.x86_64 php55w-pdo.x86_64
安装后如需要调用mysql模块需要安装mysql依赖:
yum install php55w-mysql
至此,php就安装完成了;
phpmyadmin也一样可以用yum安装:
yum install phpmyadmin
安装完成后,需要修改配置文件信息,比如mysql的信息,为正确的信息:
到phpmyadmin安装目录下面,/etc/phpMyAdmin/
编辑配置文件:config.inc.php
修改对应的mysql配置:
$cfg[‘Servers‘][$i][‘host‘] = ‘localhost‘; // MySQL hostname or IP address
$cfg[‘Servers‘][$i][‘port‘] = ‘60090‘; // MySQL port
$cfg[‘Servers‘][$i][‘extension‘] = ‘mysqli‘; // The php MySQL extension to use (‘mysql‘ or ‘mysqli‘)
$cfg[‘Servers‘][$i][‘auth_type‘] = ‘cookie‘; // Authentication method (config, http or cookie based)
$cfg[‘Servers‘][$i][‘AllowRoot‘] = TRUE; // whether to allow root login
重点是修改mysql的端口为对应的mysql端口,如连接的是远程mysql服务器,则需要把localhost改为远程服务器的ip地址;
提供phpmyadmin服务:
将/usr/share/phpMyAdmin建立软连接到/usr/share/nginx/html/下面,提供通过nginx访问phpmyadmin;
配置nginx添加php模块:
到nginx配置文件里,如/etc/nginx/conf.d/default.conf,添加如下配置:
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
完成后,重启nginx;
启动php,service php-fpm start
如页面提示错误信息,可能php模块调用有问题,需要修改nginx的fastcgi_params,替换为如下内容:
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
重启nginx或者service nginx reload;
访问phpmyadmin:http://localhost/phpMyAdmin
界面需要mysql的账户和密码,配置正确即可登陆进去了;
php调用数据库:
需要修改/etc/php.ini文件,修改mysql的参数为正确的参数,如port,socket等;
以上是关于php5.5安装及phpmyadmin&nginx配置php模块的主要内容,如果未能解决你的问题,请参考以下文章