Just another WordPress.com site

Archive for the ‘phpmyadmin’ Category

Installing Nginx With PHP5 And MySQL Support On Ubuntu 12.04 (precise)

add relevant PPA in the source list.
 edit like

nano /etc/apt/sources.list

as i am using ubuntu 12.04 (precise ) so add following

deb http://ppa.launchpad.net/nginx/development/ubuntu precise main 
deb-src http://ppa.launchpad.net/nginx/development/ubuntu precise main

 First, for good measure lets make sure our server is all up-to-date.

apt-get update

Installing MySQL

Then let’s begin by installing MySQL:

apt-get install mysql-server mysql-client
after entering the above command you will also be prompted for a MySQL “root” user password…

Installing PHP

Next up, lets install PHP5 and a few common extensions (here is a list if you are in need of other extensions):

apt-get install php5-cgi php5-cli php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-pspell php5-recode php5-sqlite php5-tidy php5-xmlrpc php5-xsl

As you may have noticed, we have installed php-cgi, that is because we will be running a FastCGI interface.
here are some articles online which recommend using lighttpd for its FastCGI interface, this is totally not needed. PHP has its own FastCGI interface which works perfectly well (thanks to Tomasz Sterna for a great article on FastCGI with Nginx)

At this point, we will be using a little bit of vim to do a bit of file editing, so here is a quick primer on using vim.
Lets create the following file:  

vim /etc/init.d/php-fastcgi

 This file will have the following content:

#!/bin/bash
BIND=127.0.0.1:9000
USER=www-data
PHP_FCGI_CHILDREN=5
PHP_FCGI_MAX_REQUESTS=500

PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS=”- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND”
RETVAL=0

start() {
      echo -n “Starting PHP FastCGI: “
      start-stop-daemon –quiet –start –background –chuid “$USER” –exec /usr/bin/env — $PHP_CGI_ARGS
      RETVAL=$?
      echo “$PHP_CGI_NAME.”
}
stop() {
      echo -n “Stopping PHP FastCGI: “
      killall -q -w -u $USER $PHP_CGI
      RETVAL=$?
      echo “$PHP_CGI_NAME.”
}

case “$1” in
    start)
      start
  ;;
    stop)
      stop
  ;;
    restart)
      stop
      start
  ;;
    *)
      echo “Usage: php-fastcgi {start|stop|restart}”
      exit 1
  ;;
esac
exit $RETVAL

 As Tomasz Sterna mentions, you will need to fiddle with the PHP_FCGI_CHILDREN and PHP_FCGI_MAX_REQUESTS variables depending on your server’s amount of memory and compute power. I am running a baseline 256 MB / 10 GB Rackspace Cloud Server so I use the following settings which seem to work very well (as seen above):

PHP_FCGI_CHILDREN=5
PHP_FCGI_MAX_REQUESTS=500

Moving on … after you’ve created and saved the file we will make it executable and then start up the FastCGI service with the following commands:

chmod +x /etc/init.d/php-fastcgi
/etc/init.d/php-fastcgi start

We will want the service to auto start when we reboot our server, so we also do the following:

 update-rc.d php-fastcgi defaults

Installing Nginx

Installing Nginx is easy, use the following commands to install and then start up the Nginx server.

apt-get install nginx
/etc/init.d/nginx start

After installing Nginx, it will be automatically configured to start when we reboot our server (unlike the PHP FastCGI service we had to setup), so we are all set.

Testing Nginx and PHP

At this point we can see that Nginx is working by typing the server’s IP address into a web browser (http://%5BIP_ADDRESS%5D/). You should get a “Welcome to nginx!” message.
Now lets test PHP, we will create a generic phpinfo.php file with the following:

echo "" > /var/www/nginx-default/phpinfo.php

/var/www/nginx-default/ is the Nginx server default root directory…
If you use your browser to go to  

http://%5BIP_ADDRESS%5D/phpinfo.php 

,you will notice that it doesn’t work … before this will work, we have to enable FastCGI in the Nginx config file. Open up the following file:

vim /etc/nginx/sites-available/default

in the server {

change #root /usr/share/nginx/www; 

to root /var/www;
 

 
Find the following lines (scroll to line 47):
       

#location ~ \.php$ {
    #fastcgi_pass   127.0.0.1:9000;
    #fastcgi_index  index.php;
    #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #includefastcgi_params;
#}

 and change them to (removing the # character from each line, changing line 50 and adding a space between include and fastcgi_params on line 51):

location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /var/www/nginx-default/$fastcgi_script_name;
    include fastcgi_params;
}

Now lets restart Nginx so our config changes will take effect:

/etc/init.d/nginx restart

 Now use your web browser to go to http://%5BIP_ADDRESS%5D/phpinfo.php, you should see a PHP info page.

Installing phpMyAdmin + phpMyAdmin Vhost Configuration 

apt-get install phpmyadmin

You will see the following questions:
Web server to reconfigure automatically: <– select none (because only apache2 and lighttpd are available as options)
Configure database for phpmyadmin with dbconfig-common? <– No
You can now find phpMyAdmin in the /usr/share/phpmyadmin/ directory. Now we must configure our vhost so that nginx can find phpMyAdmin in that directory.
Open /etc/nginx/sites-available/

nano /etc/nginx/sites-available/

 and add the following part to the server {} container:

server {
[...]
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
[...]
}

Reload nginx:

/etc/init.d/nginx reload

That’s it! You can now go to

http://127.0.0.1/phpmyadmin/
or http://localhost/phpmyadmin

 some useful links for further help regarding LEMP (linux,enginx,mysql,php)

  1. http://suckup.de/linux/ubuntu/nginx-php5-fpm-auf-debianubuntu/
  2. http://www.rackspace.com/knowledge_center/article/installing-nginx-and-php-fpm-running-on-unix-file-sockets
  3. http://www.howtoforge.com/running-phpmyadmin-on-nginx-lemp-on-debian-squeeze-ubuntu-11.04

nginx

Install phpMyAdmin on CentOs

while installing phpmyadmin on my local machine using vmware at Centos 5.5.

i faced some problems so thought to share the steps for other to overcome these problems.
1. Update the packages

# yum update -y

2. Install MySQL packages

# yum install mysql-server mysql mysql-devel

3. Make MySQL boot up automatically

# chkconfig mysqld on

4. Start MySQL service

# service mysqld start
# /etc/init.d/mysqld restart

5. Set the password for the root user

# /usr/bin/mysql_secure_installation (Recommended)
OR
# mysqladmin -u root password eaziweb

6. Install php and common packages

# yum install php php-gd php-imap php-mysql php-pear php-xml phpxmlrpc curl libxml2 php-mbstring php-mcrypt

7. Install phpMyAdmin
Because the version of php on CentOS 5.5 is 5.1.6, we only can install phpMyAdmin 2.x, I choose 2.11.11.3.

# cd /usr/share
# wget http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/2.11.11.3/phpMyAdmin-2.11.11.3-english.tar.gz/download
# tar xvfz phpMyAdmin-2.11.11.3-english.tar.gz
# mv phpMyAdmin-2.11.11.3-english phpmyadmin
# rm phpMyAdmin-2.11.11.3-english.tar.gz
# cd phpmyadmin
# cp config.sample.inc.php config.inc.php

8. Edit the config.inc.php file, find the line that contain “blowfish_secret”, and modify like below.

$cfg[‘blowfish_secret’] = ‘TypeAnything_for_Secure’;

9. Restart the httpd service

# /etc/init.d/httpd restart

10. Enter the URL http://%5BIP Address]/phpMyAdmin/ on Firefox browser, we’ll can see the login web page.

http://localhost/phpMyAdmin

After inputting the root user and its password(eaziweb), we can use phpMyAdmin to manage the MySQL.
Errors
1. 404 Not Found Error
Please make sure you push your phpMyAdmin directory in your webroot. In my case it’s /var/www/html

cp -r phpMyAdmin/ /var/www/html/

2. 403 Forbidden Error
I spend good amount of time finding why access is forbidden and finally did following setting

2.1 Go to /etc/httpd/conf.d/
2.2 vi phpMyAdmin.conf
2.3 Add following lines

Order allow,deny
Options Indexes
Allow from all

Still not able to access, try disabling the SElinux
SElinux is extra security layer in Linux and sometimes it provide conflicts for apache to work

vi /etc/selinux/config

Modify SELINUX=enforcing  to SELINUX=disabled  //Discuss with your senior. Mine is test server.
Restart your machine
hit http://localhost/phpMyAdmin prompt for username/password for mysql login 
Please note all the steps executed via root credentials . You can use su command to login as root and carry the same steps.
%d bloggers like this: