Ubuntu安装Nginx
来源:互联网 发布:2016诺贝尔奖预测 知乎 编辑:程序博客网 时间:2024/05/01 22:21
其实其他Linux安装都是差不多的 可能稍微目录不一样
需要注意的是要改Apache为另外的端口例如81 不然跑2个80会打架的。
1.安装nginx
运行:
sudo apt-get intsall nginx
2.启动nginx
运行:
sudo /etc/init.d/nginx start
3.查看网页
浏览器里输入http://localhost/
提示 Welcome to nginx说明安装成功了!
提示:在ubuntu11.04中nginx 默认网站目录为
/usr/share/nginx/www
这个是被我改了HTML的。
不要高兴的太早,要想支持PHP还要经历一番折腾。
4.安装PHP5
apt-get install php5-fpm
PHP – FPM是一个守护进程(与初始化脚本 / etc/init.d/php5-fpm )运行FastCGI服务器上的端口 9000 。
5.nginx的配置
配置文件/etc/nginx/nginx.conf
vi /etc/nginx/nginx.conf
你可以通过http://wiki.codemongers.com/NginxFullExample和http://wiki.codemongers.com/NginxFullExample2网址了解更多配置信息。
增加工作进程,可选,可以不修改
worker_processes 5;
keepalive_timeout 2;
默认虚拟主机配置文件地址/etc/nginx/sites-available/default
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6
root /usr/share/nginx/www;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.html;
}
location /doc {
root /usr/share;
autoindex on;
allow 127.0.0.1;
deny all;
}
location /images {
root /usr/share;
autoindex off;
}
#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 /usr/share/nginx/www;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ /.php$ {
# proxy_pass [url]http://127.0.0.1[/url];
#}
# 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;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
location ~ //.ht {
deny all;
}
}
6.重启命令
ngnix重新加载一下配置
nginx -s reload
最后重启生效
sudo /etc/init.d/nginx restart
sudo /etc/init.d/php5-fpm restart
- ubuntu 8.04 nginx 安装
- ubuntu server安装nginx
- 编译安装nginx [Ubuntu]
- Ubuntu安装Nginx
- ubuntu下nginx安装
- Ubuntu安装nginx
- ubuntu 编译安装nginx
- ubuntu 上安装 Nginx
- ubuntu下安装nginx
- Ubuntu安装Nginx
- ubuntu Nginx安装
- Ubuntu 离线安装 Nginx
- Ubuntu下安装Nginx
- Ubuntu下安装Nginx
- ubuntu 安装nginx
- ubuntu 下nginx安装
- ubuntu nginx安装
- nginx ubuntu安装(1)
- hadoopStreamming 编程
- hdu Party at Hali-Bula 树形最大独立集 刷表递推解
- 精确分析复杂的递推关系(n*logn*logn算法的稳定性)
- Android基础类之BaseAdapter
- 查看当前用户的对象权限
- Ubuntu安装Nginx
- 页面缓存设置
- JS控制文本框输入
- lisi用户使用表空间的权限
- Flex addEventListener增加事件侦听函数时传递多个参数
- PHP面试题之[求相对路径]
- xxx.lib(xxx.obj)fatal error LNK1103: debugging information corrupt; recompile module
- 如何指定GCC的默认头文件路径
- 清除浏览器中的缓存