1.LAMP环境搭建
LNMP=Linux+Nginx+Mysql+PHP,即使用Linux作为操作系统,Nginx作为Web服务器,MySQL作为数据库,PHP作为服务器端脚本解释器,要搭建L NMP环境,首先到官方网站下载相应的最新安装包。
LNMP和LAMP不同点是所使用的Web服务器不同,故Mysql、PHP的安装在此部分不详细介绍,请参考LAMP环境搭建相应部分搭建。
1.1安装Nginx
下载nginx-1.2.2.tar.gz和所依赖的包, pcre-8.30.tar.gz, zlib-1.2.3.tar,
首先分别安装依赖包, pcre和zlib;
然后,安装Nginx:
tar zxvf nginx-1.2.2.tar.gz ./configure &&make && make install |
1.2安装Mysql
参考LAMP中Mysql安装
1.3PHP安装
参考LAMP中PHP安装
1.4配置Nginx
将nginx.conf文件修改如下:
user www; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; client_max_body_size 8192m; sendfile on; keepalive_timeout 65; server { listen 5000; server_name localhost; root /srv/www/demo; index index.php; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~* \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; include fastcgi_params; } } } |
重启nginx服务,使配置生效。
1.5测试LNMP环境是否配置成功
在目录/srv/www/demo下新建index.php文件,
<html> <body> <?php phpinfo(); ?> </body> </html> |
保存后,然后在浏览器中输入 http://ip/index.php,看是否能看到php的相关配置信息,如果能看到,说明配置成功。
参考资料:
http://leezqang.blog.51cto.com/1525874/922500
http://blog.youkuaiyun.com/rainysia/article/details/6740875
http://blog.youkuaiyun.com/qzier_go/article/details/7720137
http://jinlong.sinaapp.com/?p=75
http://blog.youkuaiyun.com/fm0517/article/details/7299144/
http://www.sungyism.com/blog/post/80/