CentOS6.x 下 LNMP环境搭建(准备篇)
CentOS6.x 下LNMP环境搭建(一、安装 MySQL)
-- LNMP 服务安装目录
# mkdir -p /lnmp/server /lnmp/www /lnmp/log/MysqL /lnmp/log/Nginx /lnmp/log/PHP
注:安装好的目录结构类似如下
/lnmp/
├── log
│├── MysqL
│├── Nginx
│└── PHP
├── server
│├── MysqL -> /lnmp/server/MysqL-5.x.xx
│├── MysqL-5.x.xx
│├── Nginx -> /lnmp/server/Nginx-1.4.4
│├── Nginx-1.4.4
│├── PHP -> /lnmp/server/PHP-5.x.xx
│└── PHP-5.x.xx
├── info.log
└── www
# chown -R www:www /lnmp/log # chmod -R 755 /lnmp/log # chown -R www:www /lnmp/www # chmod -R 755 /lnmp/www
-- 下载软件包
# mkdir -p /root/src && cd /root/src <------- 源码包下载存放目录 # wget http://dev.MysqL.com/get/Downloads/MysqL-5.5/MysqL-5.5.50-linux2.6-x86_64.tar.gz # wget http://Nginx.org/download/Nginx-1.6.3.tar.gz # wget http://cn2.PHP.net/distributions/PHP-5.5.36.tar.gz
注:其它版本及备用下载地址参见附录
-- 追加防火墙规则,开放80/3306端口
# /etc/init.d/iptables status <------- 查看当前防火墙状态 # vim /etc/sysconfig/iptables ..... -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT <------- 开放80 -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT <------- 开放3306 -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT # /etc/init.d/iptables restart <------- 重启防火墙
-- 关闭 SELinux
# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config # shutdown -r now
-- 安装编译所需软件包
# yum -y install gcc gcc-c++ kernel-devel
----------------------------------------------------------------------------------------
附录:
----------------------------------------------------------------------------------------
MysqL
----------
- 5.1:
http://dev.MysqL.com/get/Downloads/MysqL-5.1/MysqL-5.1.73-linux-x86_64-glibc23.tar.gz
http://mirrors.sohu.com/MysqL/MysqL-5.1/MysqL-5.1.73-linux-x86_64-glibc23.tar.gz
- 5.5:
http://dev.MysqL.com/get/Downloads/MysqL-5.5/MysqL-5.5.50-linux2.6-x86_64.tar.gz
http://mirrors.sohu.com/MysqL/MysqL-5.5/MysqL-5.5.50-linux2.6-x86_64.tar.gz
- 5.6:
http://dev.MysqL.com/get/Downloads/MysqL-5.6/MysqL-5.6.31-linux-glibc2.5-x86_64.tar.gz
http://mirrors.sohu.com/MysqL/MysqL-5.6/MysqL-5.6.31-linux-glibc2.5-x86_64.tar.gz
Apache
----------
- 2.2.x:
http://mirrors.hust.edu.cn/apache/httpd/httpd-2.2.31.tar.gz
http://mirrors.sohu.com/apache/httpd-2.2.31.tar.gz
- 2.4.x:
http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.20.tar.gz
http://mirrors.sohu.com/apache/httpd-2.4.20.tar.gz
Nginx
----------
- 1.4.x
http://Nginx.org/download/Nginx-1.4.7.tar.gz
http://mirrors.sohu.com/Nginx/Nginx-1.4.7.tar.gz
- 1.6.x
http://Nginx.org/download/Nginx-1.6.3.tar.gz
http://mirrors.sohu.com/Nginx/Nginx-1.6.3.tar.gz
- 1.8.x
http://Nginx.org/download/Nginx-1.8.1.tar.gz
http://mirrors.sohu.com/Nginx/Nginx-1.8.1.tar.gz
PHP ---------- - 5.4.x http://cn2.PHP.net/distributions/PHP-5.4.45.tar.gz http://mirrors.sohu.com/PHP/PHP-5.4.45.tar.gz - 5.5.x http://cn2.PHP.net/distributions/PHP-5.5.36.tar.gz http://mirrors.sohu.com/PHP/PHP-5.5.36.tar.xz - 5.6.x http://cn2.PHP.net/distributions/PHP-5.6.22.tar.gz http://mirrors.sohu.com/PHP/PHP-5.6.22.tar.gz