安装平台基于ubuntu 9.04.使用apt-get简单安装.在安装之前你要准备好源.还有安装库g++ vim ssh links因为你要用到这些功具.
下面这个就是我配置成功图.
1 Install Tools
#apt-get install g++ vim links ssh
2 安装 MySQL 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密码
3 安装 Nginx
#apt-get install nginx
启动nginx:
#/etc/init.d/nginx start
在IE浏览器输入你的IP地址:http://myip
root@ptubuntu:~# links ls.ptubuntu.com
看到这里,说明你已安装上了nginx了.接下来我们要来配置它.设置启动系统时会自动启动它.
root@ptubuntu:~# update-rc.d nginx defaults
提示:System startup links for /etc/init.d/nginx already exist.
4 安装 PHP5
root@ptubuntu:~# apt-get install php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
接下来要配置php.ini这个文件,在做一些配置文件之前最好你要做一个备份.
root@ptubuntu:~# cd /etc/php5/cgi/
root@ptubuntu:/etc/php5/cgi# ls
conf.d php.ini
root@ptubuntu:/etc/php5/cgi# cp php.ini php.ini.bak
root@ptubuntu:/etc/php5/cgi# vi php.ini
在php.ini这个文件里添加下一行cgi.fix_pathinfo = 1
安装lighttpd
root@ptubuntu:# apt-get install lighttpd
安装完接下来要移除它的自动启动程序让它不自动启动.
root@ptubuntu:# update-rc.d -f lighttpd remove
Removing any system startup links for /etc/init.d/lighttpd …
/etc/rc0.d/K09lighttpd
/etc/rc1.d/K09lighttpd
/etc/rc2.d/S91lighttpd
/etc/rc3.d/S91lighttpd
/etc/rc4.d/S91lighttpd
/etc/rc5.d/S91lighttpd
/etc/rc6.d/K09lighttpd
开启PHP FastCGI 设置听的端口9000上运行的本地用户和www-data, 运行下面程序:
root@ptubuntu:# /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid
显示 spawn-fcgi.c.197: child spawned successfully: PID: 29470
修改rc.local 这个文件.先备份一个.
root@ptubuntu:~# cp /etc/rc.local .
root@ptubuntu:~# vi /etc/rc.local
添加
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid
5 配置Nginx
root@ptubuntu:/etc/nginx# cp nginx.conf nginx.conf.bak
root@ptubuntu:/etc/nginx# vi nginx.conf
修改如下
[...]
worker_processes 5;
[...]
keepalive_timeout 2;
[...]
配置sites-available/default
root@ptubuntu:/etc/nginx/sites-available# cp default default.bak
root@ptubuntu:/etc/nginx/sites-available# vi default
下面这个就是我的配置文档,红色是添加修改:
root@ptubuntu:/etc/nginx/sites-available# vi default
# You may add here your
# server {
# …
# }
# statements for each of your virtual hostsserver {
listen 80;
server_name ls.ptubuntu.com localhost;access_log /var/log/nginx/localhost.access.log;
location / {
root /var/www/nginx-default;
index index.php index.html index.htm;
}location /doc {
root /usr/share;
autoindex on;
allow 127.0.0.1;
deny all;
}location /images {
root /usr/share;
autoindex on;
}#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/nginx-default;
}# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
#proxy_pass http://127.0.0.1;
#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
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;
}#
#location ~ \.php$ {
#fastcgi_pass 127.0.0.1:9000;
#fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
#includefastcgi_params;
#}# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
#location ~ /\.ht {
#deny all;
#}
}# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#listen 8000;
#listen somename:8080;
#server_name somename alias another.alias;#location / {
#root html;
#index index.html index.htm;
#}
#}# HTTPS server
#
#server {
#listen 443;
#server_name localhost;#ssl on;
#ssl_certificate cert.pem;
#ssl_certificate_key cert.key;#ssl_session_timeout 5m;
#ssl_protocols SSLv2 SSLv3 TLSv1;
#ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
#ssl_prefer_server_ciphers on;#location / {
#root html;
#index index.html index.htm;
#}
#}
创建一个info.php页面.
#vi /var/www/nginx-default/info.php
<?php phpinfo(); ?>
重启nginx
root@ptubuntu:/etc/nginx/sites-available# /etc/init.d/nginx restart
root@ptubuntu:/var/www/nginx-default# /etc/init.d/lighttpd stop
这lighttp 要关了.要不然会网页显示会给跑到这里来.因为nginx & ligttpd两个同时打开也会发生冲突的.而这里我们只是用到lighttp的插件所以没有必要开启.
安装成功后的示图如下:
接下来要安装的是支持PHP mysql
root@ptubuntu:/usr/local/src# wget http://nchc.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-2.11.9.5-all-languages.tar.bz2
root@ptubuntu:/usr/local/src#cp phpMyAdmin-2.11.9.5-all-languages.tar.bz2 /var/www/nginx-default/
root@ptubuntu:/usr/local/src#cd /var/www/nginx-default/
root@ptubuntu:/usr/local/src#tar xvf phpMyAdmin-2.11.9.5-all-languages.tar.bz2
root@ptubuntu:/usr/local/src#mv phpMyAdmin-2.11.9.5-all-languages phpmyadmin
root@ptubuntu:/usr/local/src#cd phpmyadmin/
接着修改配置文档.
root@ptubuntu:/usr/local/src#cp config.sample.inc.php config.inc.php
*/
$cfg['blowfish_secret'] = ‘ptubuntu’; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ ptubuntu 改为你的mysql密码/*
其他地方也就不用改了就可以使用了.
参考外文:http://www.howtoforge.com/installing-nginx-with-php5-and-mysql-support-on-ubuntu-8.10
原创文章,转载请注明: 转载自PT Ubuntu Blog




一直都看到你研究LINUX,难道你是所谓的工程师?
那是什么工程师就是一个打工的呀.
你这是8.04的配置还是9.04?
2009年4月9日发表文章时9.04出来了么?
那里我装的是9.04 best版本.呵.所以时间上有些早了.
哦.我说呢!!!我是个新手我想问一下,我现在用的9.04 server 按你说的这个咋架不起来呢~~~在PHP配置这一步出了问题
“配置sites-available/default” 这一步我用VIM打开了default文件,也改过来了“但是退出保存时不对.用”:WQ”命没用!!保存不了解也退不出去!请问这是什么原因呢!!
很感谢你能提供这样的文章,现在像这样关于NGINX的相关文章太少了,网上一堆一堆的都是IT搬运工!
“:WQ”命没用!! 这个是错误的呀.在linux下面对大小写有很严格的要求呀.如果你不清楚.那你要先从命令开始.一定要记清大小写在linux下是有区别的.你要退出保存”:wq”
呵呵弄的差不多了“最后问一下“设置多个目录在哪个里设呀“像这样!
1.com /var/www/web1
2.com /var/www/web2
3.com /var/www/web3
你可以到这里看虚拟主机目录设置 .http://www.ptubuntu.com/2009/05/14/2467/
is.ptubuntu.com/info.php 就打开下载了怎么回事。。。。。。
@生活没借口:
打错了吧.是
ls不是is
ls.ptubuntu.com/info.php
如果你打开就会下载那说明你PHP没有配置正确哦.还有一个你要设置默认可以读取index.php这个要添加看清下面这个添加的.
配置sites-available/default
root@ptubuntu:/etc/nginx/sites-available# cp default default.bak
root@ptubuntu:/etc/nginx/sites-available# vi default
下面这个就是我的配置文档,红色是添加修改:
root@ptubuntu:/etc/nginx/sites-available# vi default
# You may add here your
# server {
# …
# }
# statements for each of your virtual hosts
server {
listen 80;
server_name ls.ptubuntu.com localhost;
access_log /var/log/nginx/localhost.access.log;
location / {
root /var/www/nginx-default;
index index.php index.html index.htm;