把我架设lnmp网站的过程写出来,希望对想架设网站的朋友有所帮助,如有更好的办法请提出来。
之所以用nginx没用apache,是因为nginx的效率更高一些,尤其是对一些低配置的服务器,比如我在单位256M内存的旧机器上架设的服务器。
1、安装ubuntu server 10.04或10.10
其中安装语言选的en,时区shanghai,服务只安装ssh,其他全部用默认就行。
提示:以上安装过程完成后,建议用其他计算机登录服务器,windows系统可以用putty,linux系统直接在终端用命令就可以:
ssh 登录名@服务器ip
因为以下过程得输入大量命令和代码,在客户机上直接粘贴即可(在windows下的putty中单击右键即可把剪贴板中的内容粘贴到终端)。
2、添加源:
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