(1)解压nginx:
(2)解压openssl:
(3)解压pcre:
(4)解压zlib:
(5)进行配置,先进入到nginx里面去,然后执行下面语句:
./configure --prefix=/usr/local/nginx
--with-http_realip_module
--with-http_addition_module
--with-http_gzip_static_module
--with-http_secure_link_module
--with-http_stub_status_module
--with-stream
--with-pcre=/home/txp/share/nginx/pcre-8.41
--with-zlib=/home/txp/share/nginx/zlib-1.2.11
--with-openssl=/home/txp/share/nginx/openssl-1.1.0g
然后直接make:
然后接着再sudo make install:
最终我们可以看到在/usr/local/nginx/目录下看到安装的nginx:
现在我们可以试着来运行nginx,并进行访问(下面的访问成功):
这里小结一下:
很多开源软件的安装步骤大概都差不多是下面这样的套路(比如等下我们下面要安装的模块,也是这样安装的思路,所以这里就不造轮子了)
-- ./cofigure
-- make
--sudo make install
2、自己写conf文件
在平时的开发过程中,主要我们要去配置它的conf文件夹下的nginx.conf文件
root@ubuntu:/usr/local/nginx# ls
client_body_temp conf fastcgi_temp
html logs proxy_temp sbin scgi_temp
uwsgi_temp
这个文件原本内容是:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html