之前写过一篇 CentOS yum安装LNMP,经常切换着用CentOS/Debian,由于各种原因我抛弃了CentOS,全面转向Debian....
其实代码差不多,但还是有点区别的- -
1、导入dotdeb源(也可以不导入,但是官方默认的软件版本很低)
1 2 3 4 |
vi /etc/apt/sources.list #在最后加入: deb http://mirror.us.leaseweb.net/dotdeb/ stable all deb-src http://mirror.us.leaseweb.net/dotdeb/ stable all |
1 2 |
wget http://www.dotdeb.org/dotdeb.gpg #导入密钥 apt-key add dotdeb.gpg |
2、更新源
1 |
apt-get update |
3、安装MySQL(3、4、5可以合在一起)
1 |
apt-get install -y mysql-server mysql-client |
4、安装nginx
1 |
apt-get install -y nginx-extras |
5、安装php
1 |
apt-get install php5-fpm php5-gd php5-mysql |
6、修改nginx conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
vi /etc/nginx/sites-available/default #将php前面的注释去掉 #即 …… location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: # fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } …… /etc/init.d/nginx restart |
7、新建phpinfo
1 2 |
vi /usr/share/nginx/html/phpinfo.php <?php phpinfo(); ?> |
8、访问ip/phpinfo.php,如无意外,安装成功,剩下的就是配置的问题了= =
如何新建网站?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
cd /etc/nginx/sites-available vi xxx #xxx为配置文件名称,可以自定义 server { listen 80; #listen [::]:80 default_server; #此处为ipv6 root /home/xxxx; index index.html index.htm; #默认首页 server_name localhost; #绑定域名 location / { try_files $uri $uri/ /index.html; #这里可以填伪静态规则 } #error_page 404 /404.html; #定义错误页 location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; } #PHP } |
一键包参考:
大胡子(全部用源安装,并优化php):http://www.notago.com/thread-383-1-1.html
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
这样才对吧
apt-get install -y nginx换成apt-get install -y nginx-full
full里面多了神马= =
多了个月姐