lnmp 环境搭建

lnmp环境就是在linux系统下安装mysql、nginx、php.
===============
第一步安装nginx:
===============
到nginx.org官网下载nginx(1.2.6)包解压之后执行./configure

生成makefile。
然后make 编译
make install安装
默认安装目录

cd /usr/local/nginx/
cd /usr/local/ngigx/sbin
./nginx 运行 可以从浏览器测试如图

55.jpg

=============
第二步安装PHP
=============
到官网下载PHP减压编译安装
./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/ –with-iconv-dir –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-discard-path –enable-magic-quotes –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fastcgi –enable-fpm –enable-force-cgi-redirect –enable-mbstring –with-mcrypt –enable-ftp –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –without-pear –with-gettext–with-mime-magic
报错提示
提示没有安装mysql
yum -y install mysql mysql-sever mysql-devel
再运行./configure
make make install
安装成功
从源码复制PHP配置文件
cp php.ini-production /usr/local/php/etc/php.ini
cp php-fpm.conf.default php-fpm.conf
=====================
第三步nginx 对PHP的支持
=====================

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
修改为fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
最后用phpinfo()测试成功

标签: linux