您好,登錄后才能下訂單哦!
安裝路徑:/application/nginx-1.12.0
安裝編譯需要的gcc和gcc-c++
yum install -y gcc gcc-c++
pcre-devel、openssl-devel、zlib-devel
yum install -y pcre pcre-devel openssl openssl-devel zlib zlib-devel
useradd -s /bin/false -M nginx
cd /tools wget http://nginx.org/download/nginx-1.12.0.tar.gz tar -zxf nginx-1.12.0.tar.gz
cd nginx-1.12.0 ./configure --user=nginx --group=nginx --prefix=/application/nginx-1.12.0/ --with-http_v2_module --with-http_ssl_module --with-http_sub_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre
make && make install
ln -s /application/nginx-1.12.0/ /application/nginx
創建nginx命令軟鏈接到環境變量
ln -s /application/nginx/sbin/* /usr/local/sbin/
cd /application/nginx vim conf/nginx.conf
找到如下內容,刪除注釋字符,并將倒數第二行的 /scripts 替換為 $document_root
修改前
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
修改后
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
該段代碼在server中的位置:
server {
listen 80;
server_name localhost;
location / {
root html;
index index.php index.html index.htm;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
注意:location ~ \.php$ {}塊中root的值和location / {}塊中root的值需要一致
nginx -t
nginx -c /application/nginx/conf/nginx.conf.bak
nginx
nginx -s stop
nginx -s reload
-s stop 快速停止nginx
-s quit 平滑停止nginx
-s reopen 重新打開日志文件
-s reload 平滑重載所有配置
[root@www nginx]# tree . ├── conf #配置文件目錄 │ ├── fastcgi.conf │ ├── fastcgi.conf.default │ ├── fastcgi_params │ ├── fastcgi_params.default #fastcgi *配合php │ ├── koi-utf │ ├── koi-win │ ├── mime.types #mime 媒體類型 │ ├── mime.types.default │ ├── nginx.conf #nginx主配置文件 │ ├── nginx.conf.default │ ├── scgi_params │ ├── scgi_params.default │ ├── uwsgi_params │ ├── uwsgi_params.default │ └── win-utf ├── html #默認站點目錄 │ ├── 50x.html │ └── index.html ├── logs #訪問日志、錯誤日志、pid文件目錄 │ ├── access.log #訪問日志 │ ├── error.log #錯誤日志 │ └── nginx.pid #pid文件 └── sbin #命令目錄 └── nginx #nginx命令文件
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。