What Is PhpMyAdmin?
PhpMyAdmin is an open source and most popular web based MySQL administration application for handlingMySQL databases. It was written in PHP language, through this application you can do various MySQLadministration tasks such as create, drop, alter, delete, import, export, search, query, repair, optimize and run other database management command via browser.
In the previous post we saw about installing and configuring nginx/1.10.0 on centos 6.7 . Here we can see about installing PhpMyAdmin 4.0.10.15 on nginx server.
Before starting please make sure you have installed LEMP stack ( Nginx , mysql and php )
Refer this post (Install LEMP on centos 6.7)
Install phpMyAdmin 4.0.10.15 on CentOS 6.7
1. Install PhpMyAdmin
you can run the following command to install it.
1 |
yum --enablerepo=remi-php56,epel install phpMyAdmin |
2. Configuring PhpMyAdmin
Enabling Configuration Storage
edit /etc/phpMyAdmin/config.inc.php
and replace this line:
1 |
$cfg['Servers'][$i]['auth_type'] = 'cookie'; // Authentication method (config, http or cookie based)? |
With this:
1 |
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config, http or cookie based)? |
and replace this line:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
$cfg['Servers'][$i]['pmadb'] = ''; // Database used for Relation, Bookmark and PDF Features // (see scripts/create_tables.sql) // - leave blank for no support // DEFAULT: 'phpmyadmin' $cfg['Servers'][$i]['bookmarktable'] = ''; // Bookmark table // - leave blank for no bookmark support // DEFAULT: 'pma_bookmark' $cfg['Servers'][$i]['relation'] = ''; // table to describe the relation between links (see doc) // - leave blank for no relation-links support // DEFAULT: 'pma_relation' $cfg['Servers'][$i]['table_info'] = ''; // table to describe the display fields // - leave blank for no display fields support // DEFAULT: 'pma_table_info' $cfg['Servers'][$i]['table_coords'] = ''; // table to describe the tables position for the PDF schema // - leave blank for no PDF schema support // DEFAULT: 'pma_table_coords' $cfg['Servers'][$i]['pdf_pages'] = ''; // table to describe pages of relationpdf // - leave blank if you don't want to use this // DEFAULT: 'pma_pdf_pages' $cfg['Servers'][$i]['column_info'] = ''; // table to store column information // - leave blank for no column comments/mime types // DEFAULT: 'pma_column_info' $cfg['Servers'][$i]['history'] = ''; // table to store SQL history // - leave blank for no SQL query history // DEFAULT: 'pma_history' |
With this:
1 2 3 4 5 6 7 8 9 10 |
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin'; $cfg['Servers'][$i]['recent'] = 'pma__recent'; $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig'; $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark'; $cfg['Servers'][$i]['relation'] = 'pma__relation'; $cfg['Servers'][$i]['table_info'] = 'pma__table_info'; $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords'; $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages'; $cfg['Servers'][$i]['column_info'] = 'pma__column_info'; $cfg['Servers'][$i]['history'] = 'pma__history'; |
Import database
Create new tables by importing examples/create_tables.sql
. Type this command to find create_tables.sql
file
1 |
rpm -ql phpMyAdmin | grep create_tables.sql |
then import it
1 |
mysql -u root -p < /usr/share/doc/phpMyAdmin-4.0.10.15/examples/create_tables.sql |
3. Configuring PhpMyAdmin for Nginx
Create this file /etc/nginx/phpmyadmin.conf
, and add this content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
location /phpMyAdmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpMyAdmin/(.+\.php)$ { try_files $uri =404; root /usr/share/; 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 $request_filename; 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 GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 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; fastcgi_param HTTPS $https; # PHP only, required if PHP was built with --enable-force-cgi-redirect fastcgi_param REDIRECT_STATUS 200; # To access phpMyAdmin, the default user (like www-data on Debian/Ubuntu) must be used fastcgi_pass 127.0.0.1:9000; #fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_buffer_size 128k; fastcgi_buffers 256 4k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_read_timeout 1200; } location ~* ^/phpMyAdmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/; } } location /phpmyadmin { rewrite ^/* /phpMyAdmin last; } |
Edit /etc/nginx//conf.d/default.conf
file and add this line
1 2 |
# Include phpmyadmin include /etc/nginx/phpmyadmin.conf; |
For reference see below of code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
server { listen 80; server_name localhost; root /usr/share/nginx/html; client_max_body_size 20M; location / { index index.php index.html; } # serve static files directly location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ { access_log off; } location ~ \.php$ { try_files $uri =404; include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_buffer_size 128k; fastcgi_buffers 256 4k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; } location ~ /\. { deny all; access_log off; log_not_found off; } location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } # Include phpmyadmin include /etc/nginx/phpmyadmin.conf; } |
4. Final Step
Make folder phpMyAdmin readable for nginx
1 2 3 4 |
chown -R nginx.nginx /etc/phpMyAdmin chown -R nginx.nginx /usr/share/phpMyAdmin chown -R nginx.nginx /var/lib/phpMyAdmin chown -R nginx.nginx /var/lib/php/session |
Now let’s test our configuration:
1 |
nginx -t |
You should hopefully see a nice successful output from nginx like so:
1 2 |
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful |
If your test is successful, you can restart the nginx
1 |
/etc/init.d/nginx restart |
Now open http://yoursite.com/phpmyadmin in your browser. You could see phpmyadmin login page . use mysql root username and password to login
DONE
How To Install Linux, nginx, MySQL, PHP (LEMP) stack on CentOS 6.7
phpMyAdmin “Cannot start session without errors”
Source:
[lastupdated]
.