OpenBSD: phpMyAdmin and NGINX


We will suppose MySQL is already installed.

# pkg_add php-fpm php-mysql phpmyadmin

 In /etc/rc.conf.local:

nginx_flags=""
pkg_scripts="mysqld php_fpm"
 # cp -fR /var/www/phpMyAdmin to /var/www/htdocs

Add to /etc/nginx/nginx.conf:

#PHP
location / {
     root   /htdocs;
     index  index.html index.htm index.php;
 }
location ~ \.php$ {
     try_files      $uri $uri/ =404;
     fastcgi_pass   unix:run/php-fpm.sock;
     fastcgi_index  index.php;
     fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
     include        fastcgi_params;
 }
location /phpmyadmin/ {
     root   /htdocs;
     index  index.html index.htm index.php;
 }
location ~ ^/phpmyadmin/\.php$ {
     try_files      $uri $uri/ =404;
     fastcgi_pass   unix:run/php-fpm.sock;
     fastcgi_index  index.php;
     fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
     include        fastcgi_params;
 }

Make a file ‘/var/www/htdocs/phpinfo.php with the following lines:

<?
php phpinfo();
?>

Start nginx and php_fpm:

/etc/rc.d/php_fpm start
/etc/rc.d nginx start

Test the PHP installation with your browser pointing to ‘localhost/phpinfo.php’. If a page with information about your PHP installation then nginx is executing php code. If what you see is php code then nginx is serving PHP pages as plain text (review your nginx configuration).

 

If nginx is executing PHP code then you can try phpMyAdmin, pointing your browser to:

 

http://localhost/phpmyadmin/index.php

A good article as reference:

http://www.h-i-r.net/p/openbsd.html

About jjjesss

I'm a guy interested in technology, bsd fan and concerned about the world around.
This entry was posted in BSD, OpenBSD. Bookmark the permalink.

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