【笔记】nginx@ubuntu安装

xiaoxiao2021-02-28  63

进入root用户: sudo su 进入/lans/soft目录,上传nginx压缩包:  cd /lans/soft  rz -y 解压: tar -zxf nginx-1.9.15.tar.gz  更新服务器包列表: apt-get update ***************************************************************************************************** * 如果出现以下错误: * E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) * E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it? * 删除lock文件: * rm -rf /var/li/dpkg/lock ***************************************************************************************************** 安装Nginx所需类库:(注意空格) apt-get install gcc libpcre3 libpcrecpp0v5 libpcre3-dev libssl-dev 在/lans/bin目录创建Nginx所需文件夹:(注意空格) cd /lans/bin mkdir nginx;cd nginx;mkdir logs conf fastcgi_temp sbin client_body_temp proxy_temp uwsgi_temp scgi_temp 在/lans/soft/nginx-1.9.15目录,开始编译安装包: ./configure --prefix=/lans/bin/nginx/ --sbin-path=/lans/bin/nginx/sbin/ --with-http_ssl_module --conf-path=/lans/bin/nginx/conf/nginx.conf --pid-path=/lans/bin/nginx/logs/nginx.pid --error-log-path=/lans/bin/nginx/logs/error.log --http-log-path=/lans/bin/nginx/logs/access.log --http-fastcgi-temp-path=/lans/bin/nginx/fastcgi_temp --http-client-body-temp-path=/lans/bin/nginx/client_body_temp --http-proxy-temp-path=/lans/bin/nginx/proxy_temp --http-uwsgi-temp-path=/lans/bin/nginx/uwsgi_temp --http-scgi-temp-path=/lans/bin/nginx/scgi_temp 如果要重新编译,先删除 /lans/soft/nginx-1.9.15/Makefile文件 执行安装命令: make;make install ******************************************************************************** * 出错: * The program 'make' can be found in the following packages: * * make * * make-guile * Try: apt install <selected package> * makeinstall: command not found * 解决:sudo apt-get install build-essential ******************************************************************************** 进入Nginx下sbin目录,启动Nginx, cd /lans/bin/nginx/sbin ./nginx 最终确认Nginx启动: ps -ef|grep nginx 访问网页: 自己的ip nginx命令: ./nginx -t 测试配置并退出 ./nginx -s  *****(stop:停止nginx服务, quit, reopen, reload:重新加载配置文件) Nginx配置 配置文件nginx/conf/nginx.conf:  http{ …… }部分,HTTP服务设置,全局设置 include mime.types; #文件扩展名不文件类型映射表 default_type application/octet-stream; #默认文件类型 sendfile on; #开启高效文件传输模式,sendfile指令指定nginx是否调用sendfile函数来输出文件,对于普通应用设为on,如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘不网络I/O处理速度,降低系统的负载。注意:如果图片显示丌正常把这个改成off。 keepalive_timeout120; #长连接超时时间,单位是秒 server{ …… }部分,虚拟主机的配置 listen 80; #监听端口 server_name lans.xxx.com; #域名可以有多个,用空格隔开 index index.html index.jsp; #默认访问页面 root /lans/webSite/xxx; #默认站点路径 error_page 500 502 503 504 /50x.html; #默认错误内容展示页
转载请注明原文地址: https://www.6miu.com/read-48834.html

最新回复(0)