Debian 6.0.4安装配置lnmp(Nginx+MySQL+PHP)

准备篇:

1、配置防火墙,开启80端口、3306端口

说明:debian默认安装是没有开启任何防火墙的,为了服务器的安全,建议大家安装启用防火墙设置,

这里推荐使用iptables防火墙。


#####################################################
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
#####################################################


##################################################################################################
*filter
# Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn’t use lo0
-A INPUT -i lo -j ACCEPT
# Accepts all established inbound connections
-A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
# Allows all outbound traffic
# You could modify this to only allow certain traffic
-A OUTPUT -j ACCEPT
# Allows HTTP and MySQLconnections from anywhere (the normal ports for websites)
-A INPUT -p tcp –dport 80 -j ACCEPT
-A INPUT -p tcp –dport 3306 -j ACCEPT
# Allows SSH connections for script kiddies
# THE -dport NUMBER IS THE SAME ONE YOU SET UP IN THE SSHD_CONFIG FILE
-A INPUT -p tcp -m state –state NEW –dport 22 -j ACCEPT
# Now you should read up on iptables rules and consider whether ssh access
# for everyone is really desired. Most likely you will only allow access from certain IPs.
# Allow ping
-A INPUT -p icmp -m icmp –icmp-type 8 -j ACCEPT
# log iptables denied calls (access via ‘dmesg’ command)
-A INPUT -m limit –limit 5/min -j LOG –log-prefix “iptables denied: ” –log-level 7
# Reject all other inbound – default deny unless explicitly allowed policy:
-A INPUT -j REJECT
-A FORWARD -j REJECT
COMMIT
##################################################################################################
ctrl+o  #保存
ctrl+x  #退出

备注:80是指web服务器端口、3306是指MySQL数据库链接端口、22是指SSH远程管理端口


##########################################################
#!/bin/bash
/sbin/iptables-restore </etc/iptables.default.rules
##########################################################

2、添加debian第三方apt-get源

     说明:debian 6.0.4的apt标准源中提供的nginx版本太低(只有nginx0.7.67)

安装篇

一、安装Nginx

二、安装MySQL


安装过程中,会跳出输入root密码的界面
输入2次密码,继续自动安装

三、安装phpPHP以及组件,使PHP支持 MySQL、FastCGI模式


配置篇

一、配置nginx支持php


#######################################################################################

二、配置php

三、配置php-fpm

测试篇


在客户端浏览器输入服务器IP地址,可以看到相关的配置信息!
#############################################################################
      
备注:

nginx默认站点目录是:/usr/share/nginx/www/

权限设置:chown www-data.www-data -R  /usr/share/nginx/www/ -R

MySQL数据库目录是:/var/lib/mysql

权限设置:chown mysql.mysql -R  /var/lib/mysql

您可能还喜欢...

2 条回复

  1. 有志竟成说道:

    [/鼓掌]

  2. 如尘般染指流年说道:

    [/酒][/玫瑰]

发表回复

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