CentOS 通過yum指令安裝nginx 1.創建nginx安裝來源 將$releasever替換為7,將$basearch替換成x86_64,這兩個指令可以自動獲取系統屬性。 2.安裝 3.啟動 4.本地測試是否啟動服務 Ubuntu 通過apt-get安裝Nginx 1.卸載預設安裝 2.安裝 ...
CentOS 通過yum指令安裝nginx
1.創建nginx安裝來源
vi /etc/yum.repos.d/nginx.repo
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/x86_64/ gpgcheck=0 enabled=1
將$releasever替換為7,將$basearch替換成x86_64,這兩個指令可以自動獲取系統屬性。
rpm -qa | grep centos-release
2.安裝
yum install nginx
3.啟動
service nginx start
4.本地測試是否啟動服務
curl -i localhost
Ubuntu 通過apt-get安裝Nginx
1.卸載預設安裝
sudo apt-get remove nginx
2.安裝
sudo apt-get install software-properties-common sudo add-apt-repository ppa:nginx/stable sudo apt-get update sudo apt-get install nginx
3.啟動
service nginx start
4.本地測試是否啟動服務
curl -i localhost
Nginx常用指令:
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives] Options: -?,-h : this help -v : show version and exit -V : show version and configure options then exit -t : test configuration and exit -T : test configuration, dump it and exit -q : suppress non-error messages during configuration testing -s signal : send signal to a master process: stop, quit, reopen, reload -p prefix : set prefix path (default: /usr/share/nginx/) -c filename : set configuration file (default: /etc/nginx/nginx.conf) -g directives : set global directives out of configuration file