Ubuntu安装Nginx
发布日期:2021-06-30 19:22:18
浏览次数:4
分类:技术文章
本文共 1846 字,大约阅读时间需要 6 分钟。
其实其他Linux安装都是差不多的 可能稍微目录不一样
需要注意的是要改Apache为另外的端口例如81 不然跑2个80会打架的。
1.安装nginx
运行:sudo apt-get intsall nginx
2.启动nginx
运行:
sudo /etc/init.d/nginx start
3.查看网页
浏览器里输入
提示 Welcome to nginx说明安装成功了!
提示:在ubuntu11.04中nginx 默认网站目录为
/usr/share/nginx/www
这个是被我改了HTML的。
不要高兴的太早,要想支持PHP还要经历一番折腾。
4.安装PHP5
apt-get install php5-fpmPHP – FPM是一个守护进程(与初始化脚本 / etc/init.d/php5-fpm )运行FastCGI服务器上的端口 9000 。 5.nginx的配置配置文件/etc/nginx/nginx.confvi /etc/nginx/nginx.conf你可以通过和网址了解更多配置信息。增加工作进程,可选,可以不修改worker_processes 5;keepalive_timeout 2;默认虚拟主机配置文件地址/etc/nginx/sites-available/default CODE: vi /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 restartsudo /etc/init.d/php5-fpm restart
转载地址:https://linuxstyle.blog.csdn.net/article/details/6572103 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
表示我来过!
[***.240.166.169]2024年04月07日 02时06分33秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
HDU - 2068 RPG的错排 (错排+组合数)
2019-04-30
CodeForces 591C Median Smoothing(思维 模拟)
2019-04-30
升级yosemite后java出错的解决
2019-04-30
开发人员与测试人员, 道不同也相谋
2019-04-30
Thirdparty之CrashRptProbe, 查询程序奔溃的利器
2019-04-30
基于VTK实现面绘制(SR)和体绘制(VR)的基本代码
2019-04-30
Visual Studio之RelWithDebInfo模式,“被忽视”的编译模式
2019-04-30
提示框的综合使用--UIAlertViewController
2019-04-30
最全的UIAlertController的使用
2019-04-30
CBPeripheralManager学习笔记
2019-04-30
CLLocationManager定位服务
2019-04-30
iOS 开发如何获取当前的应用版本号
2019-04-30
友盟统计的那些事
2019-04-30
3款流行的移动应用平台数据统计比较
2019-04-30
iOS 开发 实现 将16进制字符串转换成16进制数
2019-04-30
UILabel自适应高度和自动换行
2019-04-30