Category Archives: server side

Step by step install Engine X (nginx) and php-fpm in FreeBSD

0
Filed under BSD, phpBB, server side
Tagged as

1. Install nginx

# cd /usr/ports/www/nginx
# make install

choose :

HTTP_MODULE
HTTP_REWRITE_MODULE
HTTP_SSL_MODULE
HTTP_STATUS_MODULE
.....

2. Install php

# cd /usr/ports/lang/php5
# make install

choose :

CLI
CGI
SUHOSIN
IPV6
FASTCGI
PATHINFO
.....

3. Install php-fpm freebsd ports

# wget

save.

edit /usr/local/etc/nginx/nginx.conf

Find this lines in nginx.conf and adjust :

root /usr/local/www/nginx;

location / {
index index.php index.html index.htm;
}

location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/www/nginx$fastcgi_script_name;
include fastcgi_params;
}

Edit /usr/local/etc/php-fpm.conf

Find these lines :

nobody –>
nobody –>

change nobody into www (or your www user)

www
www

Run the services

# /usr/local/etc/rc.d/php-fpm start
# /usr/local/etc/rc.d/nginx start

5. Testing

# cd /usr/local/www/nginx

# nano info.php

save.

done.

Compatible with Apache’s log file format

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';

FROM HERE

How to Install Nginx, PHP, PHP Extensions, MySQL, and Zend Optimizer on FreeBSD 7

1
Filed under BSD, server side, WEB-DEV-LOG
Tagged as

FROM http://www.corebsd.com/?p=10.

What is Nginx ?
Nginx is (pronounced “engine X”) is a lightweight web server/reverse proxy and e-mail (IMAP/POP3) proxy server, licensed under a BSD-like license. Nginx is written by Igor Sysoev. Nginx has been running for more than three years on many heavily loaded Russian sites including Rambler (RamblerMedia.com). In March 2007 about 20% of all Russian virtual hosts were served or proxied by nginx. According to Google Online Security Blog year ago nginx served or proxied about 4% of all Internet virtual hosts, although Netcraft showed much less percent. According to Netcraft in March 2008 nginx served or proxied 1 million virtual hosts. 2 of Alexa US Top100 sites use nginx.

Firstly, please get freebsd server up and running.
We will using port to install all packages needed it this tutorial.
Installing MySQL5 :

# cd/usr/ports/databases/mysql51-server
# make install clean
# cp /usr/local/share/mysql/my-small.cnf /etc/my.cnf
# rehash
# /usr/local/bin/mysql_install_db –user=mysql

Installing PHP5 :
# cd /usr/ports/lang/php5
# make config
[X] CLI        Build CLI version
[X] CGI        Build CGI version
[X] APACHE     Build Apache module
[ ] DEBUG      Enable debug
[X]] SUHOSIN Enable Suhosin protection system
[X] MULTIBYTE Enable zend multibyte support
[ ] IPV6       Enable ipv6 support
[ ] REDIRECT   Enable force-cgi-redirect support (CGI only)
[ ] DISCARD    Enable discard-path support (CGI only)
[X] FASTCGI    Enable fastcgi support (CGI only)
[X] PATHINFO   Enable path-info-check support (CGI only)
# make install clean
# cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini

Installing PHP5 Extension :
# cd /usr/ports/lang/php5-extensions/
# make config

Options for php5-extensions 1.0
————————————————-
[X] FTP        FTP support
[X] GD
[X] GETTEXT
[X] MBSTRING
[X] MYSQL
[ ] POSIX //去掉.
[ ] SQLITE //去掉.
[X] ZLIB
# make install clean

Installing Zend Optimizer :
# cd /usr/ports/devel/ZendOptimizer/
# make install clean
You will need to make sure your php.ini will have zend module like below :
[Zend]
zend_optimizer.optimization_level=15
zend_extension_manager.optimizer=”/usr/local/lib/php/20060613/Optimizer”
zend_extension_manager.optimizer_ts=”/usr/local/lib/php/20060613/Optimizer_TS”
zend_extension=”/usr/local/lib/php/20060613/ZendExtensionManager.so”
zend_extension_ts=”/usr/local/lib/php/20060613/ZendExtensionManager_TS.so”

Installing Nginx :
# cd /usr/ports/www/nginx/
# make install clean

Installing Lighttpd (this is needed for “spawn-fcgi” binary package) :
lighttpd
# cd /usr/ports/www/lighttpd/
# make install clean

Added Nginx and Mysql to auto start in /etc/rc.conf :
# pico /etc/rc.conf
mysql_enable=”YES”
nginx_enable=”YES”

Edit Nginx.conf  :
# pico /usr/local/etc/nginx/nginx.conf
## Change user nobody to www
user  www;



location / {
root    /usr/local/www/nginx;
index   index.php index.html index.htm;
}
….
….
location ~ \.php$ {
fastcgi_pass    127.0.0.1:9000;
fastcgi_index   index.php;
fastcgi_param     SCRIPT_FILENAME    /usr/local/www/nginx$fastcgi_script_name;
include      fastcgi_params;
}
### save this file
Added spawn-fcgi and nginx to auto start when the server is rebooted :
# pico /etc/rc.local
### Added these line below
/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -C 4 -f /usr/local/bin/php-cgi
/usr/local/sbin/nginx -c /usr/local/etc/nginx/nginx.conf
#save this file

For more option about spawn-fcgi please see this result below :
# /usr/local/bin/spawn-fcgi
Usage: spawn-fcgi [options] — <fcgiapp> [fcgi app arguments]
spawn-fcgi v1.4.19 – spawns fastcgi processes
Options:
-f <fcgiapp> filename of the fcgi-application
-a <addr>    bind to ip address
-p <port>    bind to tcp-port
-s <path>    bind to unix-domain socket
-C <childs>  (PHP only) numbers of childs to spawn (default 5)
-P <path>    name of PID-file for spawed process
-n           no fork (for daemontools)
-v           show version
-h           show this help
(root only)
-c <dir>     chroot to directory
-u <user>    change to user-id
-g <group>   change to group-id

Running Spawn-fcgi and Nginx Webserver :
# /usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -C 4 -f /usr/local/bin/php-cgi
# /usr/local/sbin/nginx -c /usr/local/etc/nginx/nginx.conf

We also can see the Process with this command :
# ps -ax |grep nginx
1969  ??  Is     0:00.00 nginx: master process /usr/local/sbin/nginx -c /usr/local/etc/nginx/nginx.conf (nginx)
1970  ??  S      0:30.79 nginx: worker process (nginx)
1971  ??  S      0:28.95 nginx: worker process (nginx)
1972  ??  S      0:27.54 nginx: worker process (nginx)
1973  ??  R      0:26.73 nginx: worker process (nginx)
2211  p1  S+     0:00.00 grep nginx

You can trying to access your webserver from Firefox or any other browser,
example http://localhost you will see a page display “welcome to nginx”.

-done.

Install MySQL Server

0
Filed under BSD, server side, WEB-DEV-LOG
Tagged as

cd /usr/ports/databases/mysql50-server

Now run:

make install clean

in order to download and install MySQL.
Once the install is finished we install the databases by running:

mysql_install_db --user=mysql

If you get an error, run rehash in order to update FreeBSD’s path environment variables.
Once this is done we want to grant permissions to the mysql user in /var/db/mysql.

chown -R mysql /var/db/mysql/
chgrp -R mysql /var/db/mysql/

Now we can start MySQL by running:

/usr/local/bin/mysqld_safe -user=mysql &

Since we probably want MySQL to start after a reboot we will drop a line to /etc/rc.conf

echo 'mysql_enable="YES"' >> /etc/rc.conf

By default MySQL’s root account has no password, so to we need to change it (If we want our system to be somewhat secure). To change the password for root we enter the following command:

mysqladmin -u root password newpassword

…where newpassword is the password of our choice.

Now we can start making use of our new database server.

If you want to tweak your machine there are different configuration files you can use with your MySQL Server depending on load and what it will be used for. They are located in /usr/local/share/mysql and are called:

my-huge.cnf
my-innodb-heavy-4G.cnf
my-large.cnf
my-medim.cnf
my-small.cnf

We make an example with my-medium.cnf and copy it to /var/db/mysql as my.cnf.

cp /usr/local/share/mysql/my-medim.cnf /var/db/mysql/my.cnf

Read more about these option files at http://dev.mysql.com/doc/refman/5.0/en/option-files.html and maybe you can create your own to suit your needs better than the preconfigured ones.

Good luck with your MySQL Server! FROM http://www.druidsys.com/?q=node/8

New Server

0
Filed under BSD, server side, WEB-DEV-LOG
Tagged as

Signed up with serverbeach.com ($109 US/month) and got freeBSD the version installed is 7.0 which reached end of life May 1 ,2009 and was released Wed, 27 Feb 2008 17:19:52 -0500.

Ive spent the day learning how to upgrade BSD

 ports-mgmt/portupgrade [skiped]
# portupgrade -af [skiped]

Upgrade steps

  1. freebsd-update -r 7.2-RELEASE upgrade
  2. freebsd-update install
  3. shutdown -r now [for updated kernel]
  4. freebsd-update install
  5. Reboot the machine into the new FreeBSD version. The process is complete.

http servers

0
Filed under server side, WEB-DEV-LOG
Tagged as

nginx

used by wordpress.com

lighttpd

WordPress.com has this line in its response header: “X-hacker: If you’re reading this, you should visit automattic.com/jobs and apply to join the fun, mention this header.”

shell / GNU Coreutils

0
Filed under server side, WEB-DEV-LOG
Tagged as

http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html

ETL

http://commandline.org.uk/command-line/ten-cool-coreutils-commands/

GNU Coreutils