安装nginx环境
安装环境
yum install gcc
yum install pcre-devel
yum install zlib zlib-devel
yum install openssl openssl-devel
在usr/local目录下新建nginx文件夹
cd /usr/local
mkdir nginx
进入nginx文件夹
cd nginx
下载nginx的tar包
wget http://nginx.org/download/nginx-1.9.7.tar.gz
解压tar
tar -zxvf nginx-1.9.7.tar.gz
安装nginx
./configure
执行make
make
执行make install
make install
进入sbin
cd sbin
启动
sudo ./nginx
查询nginx.conf是否正确
/usr/local/nginx/sbin/nginx -t
部署静态文件
cd nginx
vim conf/nginx.conf
server {
listen 80;
server_name _;
#root /usr/local/nginx/nginx-1.9.7/web/; # 静态页面根目录
#index index.html;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/local/nginx/nginx-1.9.7/web/;
index index.html;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
重启:./sbin/nginx -s reload