標籤:

【Linux】Nginx 域名解析

接上篇文章

環境安裝成功之後,要配置域名解析

假設域名: www.test.com

1 命令輸入,查找nginx配置文件路徑

find / -name nginx.conf

2 打開這個目錄。

vim /etc/nginx/nginx.conf

插入以下

# 包含所有的虛擬主機的配置文件include /etc/nginx/vhosts/*.conf;

保存退出

3 在 /etc/nginx 下創建 vhosts 目錄

mkdir /etc/nginx/vhosts

4 創建名字為 www.test.com.conf 文件。並複製以下內容進去

server { listen 80; server_name www.test.com; location / { root /usr/share/nginx/html/www.test.com/; index index.php index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html/www.test.com; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/www.test.com/$fastcgi_script_name; include fastcgi_params; } location ~ /.ht { deny all; }}

保存並重啟nginx

service nginx restart

5 進入nginx目錄: /usr/share/nginx/html

創建名字為 www.test.com 的文件夾 並創建 index.php 文件。輸入測試內容

<?phpecho "test";?>

6 瀏覽器訪問你得域名

推薦閱讀:

為什麼C++ 程序員看不起php?
PHP 面試問哪些問題可以比較準確的反映出應聘者的開發水平?
kindeditor編輯器保存的文章帶html標籤,進行文章關鍵詞搜索如何排除標籤內容干擾?
php pconnect與單例模式連接資料庫,怎樣才能最高性能的連接資料庫?

TAG:Nginx | PHP |