配置文件
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项目