Step by Step Nginx + Wordpress-mu Blog Service Creation - Step 3: PHP configuration

After a long break, helllloooo everyoneeee again. Kinda radio show opening, sorry :)

Now, we will configure php.

For spawning php processes (for using as fastcgi), we will use lighttpd spawn-fcgi, now it’s seperated from lighttpd project.

wget http://www.lighttpd.net/download/spawn-fcgi-1.6.2.tar.gz
tar -xzvf spawn-fcgi-1.6.2.tar.gz
cd pawn-fcgi-1.6.2
./configure
make
make install

Now, edit /usr/bin/spawn-php.sh. FCGIPROGRAM, FCGIPORT (select which you want), PHP_FCGI_CHILDREN (maybe 3 or 5) and set USERID=www-data, GROUPID=www-data.

Give it execute rights. chmod +x /usr/bin/spawn-php.sh

After that point, you can continue with blog.elderec.com. Because i will write same things, and i don’t like repetition…

Do whatever  elderec did after “Now we create a init.d script /etc/init.d/fastcgi”  point. Only make scripts “PHP_SCRIPT” variable as “PHP_SCRIPT=/usr/bin/spawn-php.sh”

After that steps, you must install some cache plugins for php, like eaccelerator or xcache. I prefer eaccelerator, because it caches and optimizes scripts. Xcache only caches. I said “must” because, i gained approx. %400 speed boost with eaccelerator.

Installing Wordpress-mu

wget http://mu.wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz

Now, move files etc. wihtin folder to your sites public folder. Copy wp-config-sample.php as wp-config.php and edit.

At last, open your browser and point your site.

 

That’s all folks!

———

Step by Step Nginx + Wordpress-mu Blog Service Creation - Step 2: Nginx, and MySql configuration

Step by Step Nginx + Wordpress-mu Blog Service Creation - Step 1: Install OS, Firewall, Nginx, Mysql, PHP

, , ,

No Comments

Step by Step Nginx + Wordpress-mu Blog Service Creation - Step 2: Nginx, and MySql configuration

Hi again. You are welcome to second stage!

We will continue from here.

Now, we must configure nginx, php and mysql.

Firstly, take a look to /etc/nginx/nginx.conf. You may want to increase worker_processes to a higher value than 1. Maybe 3 or 5. This identifies number of request handler processes.

Then add a virtual host to nginx. If you will use the server for only that site, then you may consider configuring default files. Default file is /etc/nginx/sites-available/default. This file includes server defaults, for example, if you want to give all your sites php support, then insert fastcgi parameters here. If you prefer a virtual host, adding it is quite simple. Create a config file to /etc/nginx/sites-available and link to that config from /etc/nginx/sites-enabled. That approach more tidy -in my opinion-, by the way.

#nano /etc/nginx/sites-available/your-site.com

#ln -s /etc/nginx/sites-available/your-site.com /etc/nginx/sites-enabled/your-site.com

This file must include at least:

server {
server_name your-site.com, www.your-site.com; #your domain

location / {
root /var/www/your-site.com; #/path/to/your-site.com/files
index index.html index.htm; #default index page
}
}

Great resource for config files: nginx wiki

And this is a config file for worpress-mu:
(This is not my own stuff, i merged from siava.su and this slicehost forum post. Thanks to them!)

(Assumed that your site directory includes two folders, first, logs for log files and second public for site root.)

server {
    listen 80;
    server_name your-domain.com *.your-domain.com; #requires a type wildcard dns entry
    access_log /var/www/your-domain.com/logs/access.log;
    error_log /var/www/your-domain.com/logs/error.log;
    error_page 500 502 503 504 /error/50x.html; #your error files
    client_max_body_size 16M; #for file uploads

#####Below wp-mu rewrite rules
   location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
    {
        root /var/www/your-domain.com/public;
        rewrite ^/.*(/wp-.*/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
        rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ /wp-content/blogs.php?file=$1 last;
        expires 30d;
        break;
    }

    location / {
        root /var/www/your-domain.com/public;
        index index.php index.html;

        if (!-e $request_filename) {
            rewrite ^.+/?(/wp-.*) $1 last;
            rewrite ^.+/?(/.*\.php)$ $1 last;
            rewrite ^(.+)$ /index.php?q=$1 last;
        }

#####Below for wp-super-cache
     # enable search for precompressed files ending in .gz
     # nginx needs to be complied using .-with-http_gzip_static_module
     # for this to work, comment out if using nginx from aptitude
     # gzip_static on;
     # if the requested file exists, return it immediately

        if (-f $request_filename) {
                break;
        }

        set $supercache_file '';
        set $supercache_uri $request_uri;

        if ($request_method = POST) {
                set $supercache_uri '';
        }

        # Using pretty permalinks, so bypass the cache for any query string
        if ($query_string) {
                set $supercache_uri '';
        }

        if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
                set $supercache_uri '';
        }

        # if we haven't bypassed the cache, specify our supercache file
        if ($supercache_uri ~ ^(.+)$) {
                set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
        }

        # only rewrite to the supercache file if it actually exists
        if (-f $document_root$supercache_file) {
                rewrite ^(.*)$ $supercache_file break;
        }

        # all other requests go to Wordpress
        if (!-e $request_filename) {
                rewrite . /index.php last;
        }
        }

    }

#####Finally php fastcgi
    location ~ \.php$ {
        rewrite ^/.*(/wp-.*/.*.php)$ $1;
        fastcgi_pass 127.0.0.1:2345;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /var/www/your-site.com/public$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }

}

Change your-site.com to your domain, all done, pretty straight forward :)

wp-super-cache is a cache plugin for wordpress and wordpress-mu. Saves lots of cpu time.

I added some comments on config for explaining code blocks and some variables.

Now, an easy thing, add an user to mysql. This step is not essential, you give root user to wordpress-mu, but this is not a good way especially on production.

#mysql -u root -p

#create user 'user'@'localhost' identified by 'password';

#create database 'wordpress-mu-database';

#grant all on wordpress-mu-database.* to 'user'@'localhost';

Last line gives your user all privileges on wp-mu database, including drop! If you prefer, this line may be like this:

#grant create,alter,insert,update,delete on wordpress-mu-database.* to 'user'@'localhost';

This is obviously a better solution.

So far, we installed os, nginx, mysql and php. Configured nginx and mysql. Next article will cover php settings and making it running on boot.

———

Step by Step Nginx + Wordpress-mu Blog Service Creation - Step 1: Install OS, Firewall, Nginx, Mysql, PHP

Step by Step Nginx + Wordpress-mu Blog Service Creation - Step 3: PHP configuration

, , ,

No Comments

ilahiyatblog.com açıldı..

Geçen haftadan beri tüm vaktimi çalan ilahiyatblog.com, nihayet kullanılabilecek kıvama geldi.

Yeni ortamımıza hepinizi bekleriz.

Buradan alalım http://ilahiyatblog.com

, ,

No Comments

Pscp ile servera dosya yüklemek

Serverınıza bir dosya yüklemek istediğinizde, linuxta scp, windowsta PuTTY’nin pscp.exe sini kullanabilirsiniz. Vermeniz gereken komut şöyle bişi:

c:\dosyanin-yolu\pscp.exe gidecek.zip kullanici@server:/tmp/

Ben en sondaki italik bölümü, yani dosyanın gönderildiği serverda kaydedileceği yeri yazmadığımdan, bir türlü çalıştıramayıp epeyce uğraştım. Siz uğraşmayın.

,

No Comments

Step by Step Nginx + Wordpress-mu Blog Service Creation - Step 1: Install OS, Firewall, Nginx, Mysql, PHP

We will discuss here and show a how-to  to create a server for serving blogs with wordpress-mu.

First of all, be prepared for a little time consuming and tiresome work. Let’s Begin!

Firstly, we need a server, it can be a dedicated or vps bleong to your expectations, i prefer to start with a vps since there is no guarantee that i will succeed in this business :)

By the way, i highly recommend my VPS provider Linode. These guys really rock! (Yep, i added referral code, you find great service, i get some free budget.)

Whatever you choose, firstly we have to have an os. I prefer Ubuntu (8.10) because of its easiness, and rest of the article is assumes you preferred that also.

If you using a vps, then probably you will create a new distro with hdd and swap attached from some control panel.

Now, we can begin the real thing.

#ssh your.servers.ip.address (For Windows users like me, there is PuTTY.)

When connected to the box, i see, the timezone is different from mine. Let’s fix that.

#ln -sf /usr/share/zoneinfo/Europe/Istanbul /etc/localtime

Here, you must select your area after zoneinfo/

After that, we install a easy-to-use firewall ufw (uncomplicated firewall), it’s iptables based and very easy to configure and use.

#apt-get update

#apt-get install ufw

Then, before activating firewall, we must allow ssh for not being kicked.

#ufw allow OpenSSH

Then, enable the firewall. #ufw enable

Now, it’s time to install some everyday tools.

#apt-get install nano wget htop lynx zip

nano is a text editor (i know vim is far more better but i can’t use it effectively), wget is a download tool, htop is a better top, lynx is a text-based web browser, zip is for creating and decompressing files which compressed with that format.

Now, it’s time to install webserver. We will install with apt, but it’s always possible and generally better choice compiling from source. Ubuntu repositories have 0.6.32 version of nginx but actual stable release is 0.6.36.

#apt-get install nginx

#ufw allow 80 (Open port 80 to connections)

#apt-get install php5-common php5-cgi php5-mysql php5-cli (php install)

#apt-get install mysql-server mysql-client (mysql install, that will ask a password for database root access, it must be something complex)

———

Step by Step Nginx + Wordpress-mu Blog Service Creation - Step 2: Nginx, and MySql configuration

Step by Step Nginx + Wordpress-mu Blog Service Creation - Step 3: PHP configuration

, , ,

5 Comments