毕业设计那点事 — 源码安装Nginx

xiaoxiao2021-02-28  92

为Nginx创建用户组 sudo groupadd nginx sudo useradd -g nginx -M nginx 安装Nginx依赖包 - pcre sudo apt-get install libpcre3 libpcre3-dev - zlib sudo apt-get install zlib1g zlib1g-dev - openssl sudo apt-get install openssl libssl-dev sudo apt-get install libgeoip sudo apt-get install libgd sudo apt-get install libxml2 libxslt 下载nginx tar zxvf nginx.tar.gz //下载的对应nginx版本 开启对应模块并安装 cd nginx ./configure --user=bee --group=bee --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module sudo make && make install 修改配置(了解Nginx配置可看下一篇文章) sudo vim /usr/local/nginx/conf/nginx.conf //在http模块内添加server server { listen 8000; # 监听端口 server_name yaf.com; # 域名 root /home/app/yaf/demo/yafApp; #网站目录 index index.php index.html; #默认读取文件,入口文件 location / { try_files $uri $uri/ /index.php$is_args$args; } #使用php-fpm处理php请求 location ~ \.php$ { try_files $uri =404; include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; } } //以下为个人nginx.conf配置文件 user nginx nginx; worker_processes 4; worker_priority 0; error_log logs/error.log; events { worker_connections 1024; accept_mutex on; accept_mutex_delay 500ms; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 8000; server_name yaf.com; # alias another.alias; root /home/app/yaf/demo/yafApp; index index.php index.html; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { try_files $uri =404; include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; } } } 开启服务 //由于是与php-fpm配合使用,需要在开启nginx服务之前开启php-fpm服务,上篇文章已介绍php-fpm sudo /etc/init.d/php-fpm start sudo /usr/local/nginx/sbin/nginx //通过访问 yaf.com 查看结果,需要修改hosts文件 sudo vim /etc/hosts 127.0.0.1 yaf.com nginx服务操作 /usr/local/nginx/sbin/nginx nginx -s stop 立即停止 nginx -s quit 温和停止守护进程 nginx -s reopen 重新打开日志文件 nginx -s reload 重新载入配置文件 killall nginx nginx -t 检测配置文件

参考链接: link1 | link2 | link3 | link4

转载请注明原文地址: https://www.6miu.com/read-76267.html

最新回复(0)