文章归档

Ubuntu+Nginx+PHP5+FastCGI

基于平台ubuntu的基础上安装nging,5,, .

1.安装 MySQL:

root@ptubuntu:~#aptitude install mysql-server mysql-client libmysqlclient15-dev

2.安装 PHP5

root@ptubuntu:~#aptitude install php5-common php5-cgi php5-mysql php5-cli

3.安装gcgi程序

有几个不同的做法在这里使用安装 lighttpd 提取spawn-fcgi所以我们编辑它但不安装.

root@ptubuntu:~#wget ://www.lighttpd.net/download/lighttpd-1.4.19.tar.gz
root@ptubuntu:~#tar xvzf lighttpd-1.4.19.tar.gz
root@ptubuntu:~#cd lighttpd-1.4.18.tar.gz
root@ptubuntu:~#./configure
root@ptubuntu:~#make
root@ptubuntu:~#cp src/spawn-fcgi /usr/bin/spawn-fcgi

接下来要配置 FastCGI 设置端口号 listen on 127.0.0.1 port 9000, 配置文档 /usr/bin/php5-fastcgi

root@ptubuntu:~#/usr/bin/php5-fastcgi

#!/bin/sh
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -C 2 -f /usr/bin/php5-cgi

设置php5-fastcgi权限:

root@ptubuntu:~#chmod +x /usr/bin/php5-fastcgi

创建连接使用(ln -s)  php-fastcgi:

root@ptubuntu:~#ln -s /usr/bin/php5-fastcgi /usr/bin/php-fastcgi

现在打开init.d 目录修改 /etc/init.d/fastcgi文档:

root@ptubuntu:~#/etc/init.d/fastcgi

#!/bin/bash
PHP_SCRIPT=/usr/bin/php-fastcgi
RETVAL=0
case "$1" in
	start)
		echo "Starting fastcgi"
		$PHP_SCRIPT
		RETVAL=$?
  ;;
	stop)
		echo "Stopping fastcgi"
		killall -9 php5-cgi
		RETVAL=$?
  ;;
	restart)
		echo "Restarting fastcgi"
		killall -9 php5-cgi
		$PHP_SCRIPT
		RETVAL=$?
  ;;
	*)
		echo "Usage: php-fastcgi {start|stop|restart}"
		exit 1
  ;;
esac
exit $RETVAL

修改fastcgi权限:

root@ptubuntu:~#chmod 755 /etc/init.d/fastcgi

启动Fastcgi:

root@ptubuntu:~#/etc/init.d/fastcgi start

你应该会看到下面这个:

Starting fastcgi
spawn-fcgi.c.197: child spawned successfully: PID: 19026

设置系统开机启动:

root@ptubuntu:~#update-rc.d fastcgi defaults

创建FastCGI配置文件nginx /usr/local//fastcgi.conf

root@ptubuntu:~#vi /usr/local/nginx/fastcgi.conf

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
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 REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
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;

修改 nginx文档

root@ptubuntu:~# vi /etc/nginx/sites-available/default

添加下面这几行使得nginx可以支持PHP FastCGI socket:

location ~ \.php$ {

fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/ptubuntu.com/public_html$fastcgi_script_name;
include /usr/local/nginx/fastcgi.conf;

}

Share

Ubuntu9.04+Nginx+MySQL5+PHP5+Wordress

The Perfect Setup:

Ubuntu Server 8.04.1 LTS Hardy + EngineX () Web Server built from sources + 5 + 5.
(Or LEMP )

测试机器基于256MB VPS slice at SliceHost. Should work for other hardware.

在这机器上安装Ubuntu Server. WordPress 基于 WP Super Cache plugin.
安装 NGinx WEB Server.
这里用户 ‘jsmith’ 替换为你的域名 ‘mydomain.com’.

现在就让我们开始来执行下面的操作!

在服务器Ubuntu Server 要这安装的:

  • 登录 root.
  • 修改 root password:
    #sudo passwd
  • 添加新用户 yourself:
    #adduser jsmith
    #visudo
  • Append this line to end of file (to navigate within ‘vi’ editor to create next line – use these: L, $, a, <ENTER>):
    jsmith ALL=(ALL) ALL
    保存退出: <ESC>, :wq, <ENTER>
  • 配置 SSH:
    #vi /etc/ssh/sshd_config
    修改下面:
    Port 22
    – 这个设置ssh连接端口,默认值是22.
    - Set these to:
    PermitRootLogin no   阻止root用户登录
    X11Forwarding no
    UsePAM no

    -设置可以登录的用户:
    UseDNS no
    AllowUsers jsmith

更多的资料请移到.://www.mensk.com/webmaster-toolbox/perfect--hardy-nginx-mysql5-php5-wordpress/

Share

ubuntu9.04 install nginx+mysql+php+phpmyadmin

安装平台基于ubuntu 9.04.使用apt-get简单安装.在安装之前你要准备好源.还有安装库g++ vim ssh links因为你要用到这些功具.

下面这个就是我配置成功图.

nginx04

1 Install Tools

#apt-get install g++ vim links ssh

2 安装 5.0

#apt-get install mysql-server mysql-client

在安装这个过程中会提示让你输入MYSQL数据库的密码:
New password for the MySQL “root” user: <– yourrootsqlpassword 你的MYSQL密码
Repeat password for the MySQL “root” user: <– yourrootsqlpassword 你的MYSQL密码

阅读更多 »

Share

nginx+PHP+ mysql

环境说明: /0.5.33 + 5.2.4-2  +   5.0.51a

1. 安装Nginx.PHP和Mysql

  1. sudo apt-get install nginx
  2. sudo apt-get install php-pear php5-cli php5-common php5-xcache php5-cgi php5-mysql php5-gd
  3. sudo apt-get install mysql-server mysql-client

2. 从lighttpd中取得spawn-fcgi

  1. cd /home/hacder/
  2. sudo apt-get install lighttpd
  3. sudo cp /usr/bin/spawn-fcgi ./
  4. sudo apt-get remove lighttpd
  5. sudo mv spawn-fcgi /usr/bin/

阅读更多 »

Share

在Linux平台上安装和配置Ruby on Rails详解

on rails推荐的生产运行环境是Linux/FreeBSD/Unix,即Unix系列的操作系统,采用lighttpd+FCGI的解决方案。以下我将 以Linux操作系统,lighttpd+FCGI,MySQL数据库为例,从源代码编译安装开始讲解。

在安装之前,应该确认Linux操作系统已经安装好gcc编译器,否则请用Linux安装光盘先行安装gcc编译器:

gcc –v

如能返回gcc版本号,则gcc正确安装。

一、安装 Ruby 解析器
一些Linux发行版本,MacOSX操作系统都自带Ruby解析器,但是我仍然建议自行下载ruby源代码编译安装。因为一方面可以自己定制ruby安装的路径,另一方面可以在编译过程中自行添加更多的特性。
ruby的源代码可以从Ruby官方网站下载:
下载源代码包到本地Linux主机,然后解压缩,进入该目录,进行配置,编译和安装:
tar xzvf ruby-1.8.5.tar.gz
cd ruby-1.8.5
./configure –prefix=/usr/local/ruby
make && make install
如果想浏览所有的configure参数,可以:
./configure –help |more
Share

强大的负载均衡+静态文件WEB服务器nginx实战

当前比较流行的负载均衡前端服务器主要有apache(with mod_proxy),,lighttpd,squid,perlbal,pound,或者如果你的域名服务商提供DNS级别的负载均衡,也可以(就是一个域名随机指向多个IP,定制性不高)。

以前自己常用pound作为前端,它专注于负载均衡,支持https协议,配置还算简单,不过渐渐发现功能不够强大,转而研究其他一些既可以做负载均衡, 又能做web服务器的高性能工具吧。Perlbal是第一个看的,大牛Danga的杰作,它们开发的memcached(分布式内存cache系统)非常 好用,Perlbal也不差,虽然是基于Perl的,速度上比纯C开发的可能稍逊,但不得不说Danga大牛实力非凡。不过公司的机器都是 perl5.8.5,而Perlbal必须perl5.8.8以上,升级可能有兼容性问题,故只能作罢。

转而研究nginx:Nginx (“engine X”) 是一个高性能的 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,它已经在该站点运行超过两年半了。Igor 将源代码以类BSD许可证的形式发布。尽管还是测试版,但是,Nginx 已经因为它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名了。

中文维基地址:http://wiki.codemongers.com/NginxChs

模块依赖:
1 gzip支持,需要zlib http://www.zlib.net/ 下载最新版即可
2 rewrite module requires pcre library http://www.pcre.org/ 下载最新版即可
3 ssl 功能需要 openssl 库 http://www.openssl.org/ => http://www.openssl.org/source/ LASTEST版本即可

阅读更多 »

Share
Page 4 of 41234