上周架設(shè)了一個(gè)簡(jiǎn)單的服務(wù)器,流程如下:
1.安裝并更新apt;
2.使用apt-get安裝nginx,mysql,php及相關(guān)拓展;
3.nginx服務(wù)器配置文件默認(rèn)位置: /etc/nginx/sites-available/
4.nginx默認(rèn)root位置: /usr/share/nginx/html
5.nginx默認(rèn)網(wǎng)站根目錄: /var/www
6.nginx服務(wù)器配置:
sudo vim /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
}
- 其中root,index 银伟,server_name和location這幾行需要稍微修改一下,
- root:代表網(wǎng)站的目錄,
- index:表示Nginx的訪問首頁(yè),
- server_name:表示服務(wù)器的公網(wǎng)IP或域名.
7.最后修改如下:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/separes/public;
index index.php index.html index.htm;
server_name xxx.xx.xx.xxx;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
8.重啟nginx試運(yùn)行;