Nginx 在安装入门
2015-09-22 09:23
766 查看
1.首先需要安装必要的库,PCRE,zlib
sudo apt-get install libpcre3 libpcre3-dev
假设找不到文件的话就下载源文件进行安装。
2.解压下载的nginx源代码。进入文件夹: sudo ./configure 得到的输出例如以下:
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using builtin md5 code
+ sha1 library is not found
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
3. sudo make
4. sudo make install
5. 查看配置文件,然后启动
vonzhou@de16:~/nginx-1.0.15$ sudo /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
vonzhou@de16:~/nginx-1.0.15$ sudo /usr/local/nginx/sbin/nginx
此时查看进程有:
vonzhou@de16:~/nginx-1.0.15$ ps -axu | grep nginx
root 9723 0.0 0.0 22536 592 ?
Ss 22:49 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 9724 0.0 0.0 22936 1052 ?
S 22:49 0:00 nginx: worker process
6. 然后能够通过curl简单測试index页面:
vonzhou@de16:~$ curl http://localhost:80/
<html>
<head>
<title>Welcome to nginx!</title>
</head>
<body bgcolor="white" text="black">
<center><h1>Welcome to nginx!</h1></center>
</body>
</html>
依据nginx.conf的配置。响应文件是html/index.html页面:
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
}
sudo apt-get install libpcre3 libpcre3-dev
假设找不到文件的话就下载源文件进行安装。
2.解压下载的nginx源代码。进入文件夹: sudo ./configure 得到的输出例如以下:
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using builtin md5 code
+ sha1 library is not found
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
3. sudo make
4. sudo make install
5. 查看配置文件,然后启动
vonzhou@de16:~/nginx-1.0.15$ sudo /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
vonzhou@de16:~/nginx-1.0.15$ sudo /usr/local/nginx/sbin/nginx
此时查看进程有:
vonzhou@de16:~/nginx-1.0.15$ ps -axu | grep nginx
root 9723 0.0 0.0 22536 592 ?
Ss 22:49 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 9724 0.0 0.0 22936 1052 ?
S 22:49 0:00 nginx: worker process
6. 然后能够通过curl简单測试index页面:
vonzhou@de16:~$ curl http://localhost:80/
<html>
<head>
<title>Welcome to nginx!</title>
</head>
<body bgcolor="white" text="black">
<center><h1>Welcome to nginx!</h1></center>
</body>
</html>
依据nginx.conf的配置。响应文件是html/index.html页面:
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
}
相关文章推荐
- Laravel nginx 伪静态规则
- Nginx windows下搭建过程
- 安装Nginx
- Nginx配置upstream实现负载均衡
- LNMP系列——Nginx生产环境配置
- Nginx服务器搭建和基本配置详解
- linux环境停止和启动nginx
- nginx+rtmp实现视频直播
- 关于使用NGINX PIUS配置负载均衡
- RHEL5.8搭建LNMP平台实例
- (总结)Nginx配置文件nginx.conf中文详解
- centos下安装nginx
- Nginx 虚拟主机 VirtualHost 配置
- Nginx + fail2ban 提高安全性
- 大型架构.net平台篇(WEB层均衡负载nginx)
- Ubuntu中Nginx的安装与配置
- PHP+Nginx环境搭配
- Linux下的nginx启动、重新启动
- Nginx Location配置总结
- HAProxy+Nginx 负载均衡