配置檔案
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
keepalive_timeout 65;
include extra/blog.conf;
然後
#mkdir extra
#cd extra
#vi blog.conf
配置server
内容如下
1 server {
2 listen 80;
3 server_name blog.etiantian.org;
4 location / {
5 root html/blog;
6 index index.html index.htm;
7 }
8 location ~.*\.(php|php5)?$ {
9 root html/blog;
10 fastcgi_pass 127.0.0.1:9000;
11 fastcgi_index index.php;
12 include fastcgi.conf;
13 }
14 }
#cd /application/nginx/html
#mkdir blog
檢查nginx配置文法錯誤,重新開機服務
#/application/nginx/sbin/nginx -t
出現文法錯誤就改!ok和successful就重新開機
#/application/nginx/sbin/nginx -s reload
重新開機
⑥測試LNMP環境生效情況
#cd /application/nginx/html/blog
#echo "<?php_phpinfo(); ?>" >test_info.php
windows下配置host解析
host檔案在 C:\WINDOWS\system32\drivers\etc
添加 10.0.0.8 blog.etiantian.org
10.0.0.8替換為你linux主機的ip位址
打開浏覽器。輸入http://blog.etiantian.org/test_info.php
顯示php配置資訊頁面表示環境成功
下面貼圖,測試資料庫連接配接和部署blog程式服務的示例,搭建自己的blog網站。最後寫一個部署symfony項目到LNMP中的過程。
以上為部署wordpress個人部落格步驟
下面為在LNMP中部署sympony項目步驟
①在nginx.conf中添加新的伺服器,include extra/education.conf;
②編輯education.conf
填入
1 server {
2 listen 80;
3 server_name xy.education.com;
4 root html/education/web;
5 error_log /var/log/nginx/education.error.log;
6 access_log /var/log/nginx/education.access.log;
7 rewrite ^/app\.php/?(.*)$ /$1 permanent;
8 index index.php index.html index.htm;
9 location / {
10 index app.php;
11 try_files $uri @rewriteapp;
12 }
13 location @rewriteapp {
14 rewrite ^(.*)$ /app.php/$1 last;
15 }
16 location ~ ^/(app|app_dev)\.php(/|$) {
17 fastcgi_pass 127.0.0.1:9000;
18 fastcgi_split_path_info ^(.+\.php)(/.*)$;
19 include fastcgi_params;
20 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
21 fastcgi_param HTTPS off;
22 }
23 }
③項目檔案放在html/education下
④授權nginx使用者管理項目目錄,chown -R nginx.nginx /application/nginx/html/education
⑤此為http的配置,https的自行baidu nginx部署symfony項目