首先要检查Linux环境中有没有安装Apache 因为Apache和Nginx同样占领了80 端口,如果同时开启会发生冲突。所以安装了Apache的可以先改变其默认端口。
我没有安装Apache 所以可以直接安装tenginx
步骤:
apt-get install libpcre3 libpcre3-dev
apt-get install openssl libssl-dev
apt-get install gcc g++ make
将tenginx安装包传入root文件夹下并解压
然后 ./configure
top 查看进程
make
make install
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
vim /etc/init.d/nginx
将以下内容配置到文件中
#! /bin/sh
BEGIN INIT INFO
Provides: nginx
Required-Start: $remote_fs $syslog
Required-Stop: $remote_fs $syslog
Default-Start: 2 3 4 5
Default-Stop: 0 1 6
Short-Description: nginx init.d dash script for Ubuntu or other *nix.
Description: nginx init.d dash script for Ubuntu or other *nix.
END INIT INFO
#------------------------------------------------------------------------------
nginx - this Debian Almquist shell (dash) script, starts and stops the nginx
daemon for Ubuntu and other *nix releases.
description: Nginx is an HTTP(S) server, HTTP(S) reverse \
proxy and IMAP/POP3 proxy server. This \
script will manage the initiation of the \
server and it’s process state.
processname: nginx
config: /usr/local/nginx/conf/nginx.conf
pidfile: /usr/local/nginx/logs/nginx.pid
Provides: nginx
Author: Jason Giedymin
<jason.giedymin AT gmail.com>.
Version: 3.7.0 30-JAN-2014 jason.giedymin AT gmail.com
Notes: nginx init.d dash script for Ubuntu.
Tested with: Ubuntu 13.10, nginx-1.5.9
This script’s project home is:
http://github.com/JasonGiedymin/nginx-init-ubuntu
#------------------------------------------------------------------------------
MIT X11 License
#------------------------------------------------------------------------------