1. 程式人生 > >Centos6.5搭建LNMP

Centos6.5搭建LNMP

lnmp環境

1.編輯iptables策略
vi /etc/sysconfig/iptables
添加下面兩條參數
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
2.關閉SELINUX
vi /etc/selinux/config
更改為SELINUX=disabled
3.重啟系統
shutdown -r now
4.安裝下載工具
yum install wget
5.下載
wget http://www.atomicorp.com/installers/atomic

6.安裝
sh ./atomic
7.更新yum源
yum check-update
8.安裝nginx
yum install -y nginx
9.設置nginx開機啟動
chkconfig nginx on
10.重啟nginx
service nginx restart
11.安裝yum源
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
12.安裝php
yum -y install php56w.x86_64
13.安裝php組件
yum install php56w-tidy php56w-common php56w-devel php56w-fpm php56w-mysql
14.將配置文件改為備份文件
mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
15.由於原配置文件要自己去寫因此可以使用默認的配置文件作為配置文件
cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf
16.修改nginx配置文件,添加fastcgi支持
vi /etc/nginx/nginx.conf
index index.php index.html index.htm;
//加入index.php

location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME$ document_root$fastcgi_script_name;
include fastcgi_params;
將以上代碼註釋去掉,並修改成nginx默認路徑
17.修改php的配置文件
vi /etc/php.ini
在末行添加cgi.fix_pathinfo = 1
18.重啟服務
service php-fpm restart 如果出現失敗 可以重復
service nginx restart
19.在Nginx目錄裏創建測試頁
vi /usr/share/nginx/html/index.php
<?php
phpinfo();
?>
20.搭建完成

本文出自 “12830710” 博客,請務必保留此出處http://gpj1997.blog.51cto.com/12830710/1940328

Centos6.5搭建LNMP