------- 安裝Nginx ------
1.上傳安裝包
2.解壓安裝包
3.進入Nginx目錄
4.安裝依賴環境
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum -y install openssl openssl-devel
yum -y install gcc
5.安裝Nginx
./configure
make
make install
安裝后在/usr/local下就會有一個nginx目錄
6.啟動Nginx
cd /usr/local/nginx/sbin
啟動
./nginx
停止
./nginx -s stop
重啟
./nginx -s reload
7.查看服務狀態
ps -ef | grep nginx
8.測試Nginx服務是否成功啟動
http://ip地址:80
------- 發布項目 ------
1.創建一個toutiao目錄
cd /home
mkdir toutiao
2.將項目上傳到toutiao目錄
3.解壓項目
unzip web.zip
4.編輯Nginx配置文件nginx-1.17.5/conf/nginx.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /home/toutiao;
index index.html index.htm;
}
5.關閉nginx服務
./nginx -s stop
6.啟動服務並加載配置文件
/usr/local/nginx/sbin/nginx -c /home/nginx-1.17.5/conf/nginx.conf
7.瀏覽器打開網址
http://192.168.203.138
1.將安裝包放到usr/local文件夾下
3.進入 nginx目錄
cd nginx-1.17.5
4.安裝依賴環境 yum -y install pcre pcre-devel yum -y install zlib zlib-devel yum -y install openssl openssl-devel yum -y install gcc
5.安裝Nginx ./configure make make install 安裝后在/usr/local下就會有一個nginx目錄
./configure #執行這一步的時候可能會報錯:error C compliler cc is not found #解決:yum -y install gcc gcc-c++ autoconf automake make
6.啟動Nginx cd /usr/local/nginx/sbin 啟動 ./nginx 停止 ./nginx -s stop 重啟 ./nginx -s reload
7.查看服務狀態 ps -ef | grep nginx
發布項目 方式
1.在home下新建項目文件夾頭條
2..將項目上傳到新建的項目文件夾目錄頭條下
3.解壓該項目
unzip 項目名
4.編輯配置文件
vim /nginx帶版本號的位置/conf/nginx.conf
5.編輯80端口的root路徑
root /項目位置
6.關閉nginx服務
./nginx -s stop
7.啟動並加載配置
/nginx的路徑/sbin/nginx -c /nginx-1.17.5的路徑/conf/nginx.conf
8.測試