標籤:phpmyadmin php-mysql
安裝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模組