编译安装
编译安装Nginx:
**系统:**CentOS-7.5
**软件:**Nginx-1.14.2
**IP地址:**10.0.0.10
下载源码包:点击下载
安装依赖包:
yum -y install pcre* openssl-devel
创建目录:
mkdir /home/tools && cd /home/tools
创建用户:
useradd nginx -s /sbin/nologin -M
解压源码包:
wget http://nginx.org/download/nginx-1.14.2.tar.gz
tar zxf nginx-1.14.2.tar.gz && cd nginx-1.14.2/
预编译:
./configure --prefix=/usr/local/nginx-1.14.2 \
--with-http_ssl_module --with-http_stub_status_module \
--with-http_stub_status_module --with-pcre \
--with-http_realip_module
编译:
make && make install && echo $?
ln -s /usr/local/nginx-1.14.2 /usr/local/nginx
检测是否安装成功:
/usr/local/nginx/sbin/nginx -t --------->输入命令查看nginx版本
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
备份并修改配置文件:
cd /usr/local/nginx/conf/ && cp nginx.conf nginx.conf.bak && vim nginx.conf
user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
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;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
}
}
加入systemd管理:
vim /etc/systemd/system/nginx.service
[Unit]
Description=nginx server daemon
Documentation=man:nginx(8)
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
启动Nginx:
systemctl start nginx
systemctl enable nginx
默认站点目录:
cd /usr/local/nginx/html/
浏览器访问:
systemctl start nginx
systemctl enable nginx
默认站点目录:
cd /usr/local/nginx/html/
浏览器访问:

1032

被折叠的 条评论
为什么被折叠?



