Lnmp环境搭建

LNMP安装

Nginx
yum install nginx
service nginx start
chkconfig --levels 235 nginx on
MySQL
yum install mysql mysql-server mysql-devel
service mysqld start
chkconfig --levels 235 mysqld on
mysqladmin -u root password 'newpassword'
PHP
yum install php  php-fpm
service php-fpm start
chkconfig --levels 235 php-fpm on
wget http://cn2.php.net/get/php-5.6.17.tar.gz/from/this/mirror
tar zxf php-5.6.17.tar.gz
cd php-5.6.17
./configure  --prefix=/usr/local/php  --with-config-file-path=/usr/local/php/etc  --enable-fpm --with-mysql  --with-fpm-user=www --with-fpm-group=www   --enable-mbstring  --with-iconv --disable-fileinfo
make & make install
cp php.ini-development  /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp sapi/fpm/php-fpm /usr/local/bin
cp sapi/fpm/init.d.php-fpm  /etc/init.d/php-fpm
service php-fpm restart

LNMP 配置

Nginx
#添加index.php
index index.php index.html index.htm;

#去掉以下代码的注释
location ~ \.php$ {
    root           /usr/share/nginx/html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;
    include        fastcgi_params;
}

location ~ \.php$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name2;
    set $fastcgi_script_name2 $fastcgi_script_name;
    if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
            set $fastcgi_script_name2 $1;
            set $path_info $2;
    }
    fastcgi_param PATH_INFO $path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2;
    include        fastcgi_params;
}
PHP
#去掉以下代码的注释
cgi.fix_pathinfo = 1

重启

service nginx restart
service php-fpm restart

补充

#常用PHP扩展
php-cli php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidy php-common php-devel

暂无评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注