ubuntu下安装nginx
个人建议还是不要自己apt-get安装,反正最后加模块还是得用源码编译安装那一套流程
下的慢的该换源换源,该换网换网~
安装gcc g++的依赖库
sudo apt-get install build-essential
sudo apt-get install libtool
pcre依赖库
正则一般都会用到,建议装
sudo apt-get install libpcre3 libpcre3-dev
zlib依赖库
sudo apt-get install zlib1g-dev
ssl依赖库
sudo apt-get install openssl
安装稳定版nginx
cd /usr/local/
wget http://nginx.org/download/nginx-1.20.0.tar.gz
tar -zxvf nginx-1.20.0.tar.gz
cd nginx-1.20.0
# --prefix安装路径 默认就在/usr/local/nginx
./configure
make & make install
# nginx -V 可以看./configure 进行了啥配置,方便后续扩展
常用命令
启动nginx
/usr/local/nginx/sbin/nginx
./sbin/nginx -c /usr/local/nginx/conf/nginx.conf #指定配置文件启动
停止nginx
./sbin/nginx -s stop
./sbin/nginx -s quit
重新加载配置
./sbin/nginx -s reload
卸载
源码下 make uninstall,卸载掉之前make指定过的玩意