-
下载
wget http://nginx.org/download/nginx-1.10.2.tar.gz
- 安装
-
上传到Linux服务器
-
解压缩 :
tar -zxvf nginx-1.10.2.tar.gz
-
编译nginx
-
配置makefile
./configure \ --prefix=/usr/local/nginx \ --pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/temp/nginx/client \ --http-proxy-temp-path=/var/temp/nginx/proxy \ --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \ --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \ --http-scgi-temp-path=/var/temp/nginx/scgi
注意:上边将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录
[root@bogon nginx-1.8.0]# mkdir /var/temp/nginx -p-
编译安装
make make install
-
-
启动nginx
sudo ./nginx
-
关闭nginx 和配置防火墙
-
关闭
[root@bogon sbin]# ./nginx -s stop -
重新加载配置文件:修改了配置文件,不想让nginx重启。
[root@bogon sbin]# ./nginx -s reload -
关闭防火墙
1. 关闭
[root@bogon sbin]# service iptables stop iptables: Flushing firewall rules: [ OK ] iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Unloading modules: [ OK ]
3. 也可以修改防火墙配置文件:[root@bogon sbin]# vim /etc/sysconfig/iptables 修改后需要重启防火墙: [root@bogon sbin]# service iptables restart
-
-
访问nginx服务
- 直接在 浏览器地址栏输入nginx 主机地址
- 如 192.168.43.106
- 直接在 浏览器地址栏输入nginx 主机地址
安装好以后,安装在了/usr/local/nginx 目录下
目录结构
nginx
|----------conf :所用的配置文件
|----------html :显示用的html
|----------sbin
|--------nginx:可执行文件
./nginx 执行此文件,启动服务器
配置Nginx服务器
修改配置文件
/usr/local/nginx/conf/nginx.conf
创建 /home/ftpuser/www文件夹
mkdir -p /home/ftpuser/www
需要nginx重新加载配置文件:
[root@bogon sbin]# ./nginx -s reload
访问 /home/ftpuser/www 文件夹下的资源
假如说是 /home/ftpuser/www/image/a.img
http://nginx服务器IP地址:端口号/image/a.img
就可以访问到了