1. 程式人生 > >搭建LNMP之安裝nginx

搭建LNMP之安裝nginx

環境:Ubuntu

1, suso aot-get install nginx
2,開啟 /etc/nginx/sites_available/default 將該檔案備份,然後修改檔案
為
server{  
      listen 80;
      server_name your_site_name.com; 
      root /usr/share/nginx/html; index index.php index.html; location
       / { 
              try_files $uri $uri/ =404;
         } 
         error_page 404 /404.html;
error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/html; } location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; ##根據安裝情況而定 fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }

修改完Nginx配置,
需要重啟Nginx

      sudo service nginx restart

在/usr/share/nginx/html/目錄建立info.php檔案,
輸入以下內容 <?php phpinfo(); ?>
在瀏覽器開啟http://本地IP/info.php
例如http://10.102.7.193/info.php.
即可驗證是否成功