添加源:
sudo vi /etc/apt/sources.list
lucid(10.04)的源添加如下:
代码:
deb http://archive.ubuntu.com/ubuntu/ lucid main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ lucid-security main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ lucid-backports main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ lucid main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ lucid-security main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ lucid-backports main restricted universe multiverse deb http://ppa.launchpad.net/nginx/stable/ubuntu lucid main deb http://ppa.launchpad.net/brianmercer/php/ubuntu lucid main maverick(10.10)的源:
代码:
deb http://archive.ubuntu.com/ubuntu/ maverick main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ maverick-security main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ maverick-updates main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ maverick-backports main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ maverick main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ maverick-security main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ maverick-updates main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ maverick-backports main restricted universe multiverse deb http://ppa.launchpad.net/nginx/stable/ubuntu maverick main 最后一行为nginx的ppa源,需要添加key,在终端运行:
代码:
sudo apt-key adv --keyserver keyserver.Ubuntu.com --recv-keys C300EE8C
3、更新
代码:
sudo apt-get update
安装nginxsudo apt-get install nginx Ubuntu安装之后的文件结构大致为:
[编辑]启动nginxsudo /etc/init.d/nginx start
然后就可以访问了,http://localhost/
[编辑]配置php和mysql[编辑]安装Php和mysql安装php和MySQL: sudo apt-get install php5-cli php5-cgi mysql-server php5-mysql [编辑]安装FastCgi/usr/bin/spawn-fcgi这个文件来管理 FastCgi,它原属于lighttpd这个包里面,但 9.10 后,spawn-fcgi 被分离出来单独成包: sudo apt-get install spawn-fcgi [编辑]配置 nginx修改nginx的配置文件:/etc/nginx/sites-available/default 修改主机名: server_name localhost; 修改index的一行修改为: index index.php index.html index.htm; 去掉下面部分的注释用于支持 php 脚本: 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 /etc/nginx/fastcgi_params; } 重新启动nginx: /etc/init.d/nginx stop /etc/init.d/nginx start 启动fastcgi php: spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi 为了让php-cgi开机自启动: cd /etc/init.d cp nginx php-cgi vim php-cgi 替换nginx为php-cgi
DAEMON=/usr/bin/spawn-fcgi DAEMON_OPTS="-a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi" ... stop) echo -n "Stopping $DESC: " pkill -9 php-cgi echo "$NAME." 然后运行rcconf设置php-cgi为开机自启动 创建、测试phpinfo: sudo vi /var/www/nginx-default/info.php <?php phpinfo();
打开
(责任编辑:IT) |