centos6.5使用yum安装nginx+mysql+php

系统环境: CentOS release 6.5_2.6.32-431.el6.x86_64
关闭防火墙: service iptables stop
禁止开机启动:chkconfig iptables off
关闭selinux: sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
本机IP地址: 192.168.199.xxx


由于centos 认源没有Nginx包,先替换为国内阿里云的源也比较快,再添加epel源(安Nginx 需要)!
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.BAK
wget -O /etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-6.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

开始安装
yum -y install gcc
yum -y install Nginx*
yum -y install MysqL*
yum -y install PHP-fpm*

启动
service Nginx start
service PHP-fpm start
service MysqLd start

修改Nginx 支持PHP
vim /etc/Nginx/conf.d/default.conf #红色部分为添加部分

#
# The default server
#

server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/Nginx/html;
index index.html index.PHP;

# Load configuration files for the default server block.
include /etc/Nginx/default.d/*.conf;

location / {
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}

location ~ \.PHP$ {
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;
}

}
重新加载配置文件
service Nginx reload

添加测试文件
vim /usr/share/Nginx/html/index.PHP
<?PHP
PHPinfo ();
?>

访问测试是否ok
测试Nginx访问:

ng-ok-1024x405.png

测试是否支持PHP

ng-php-ok-1024x422.png

MysqL设置root密码
MysqLadmin -uroot password "root"

加入开机自启动chkconfig Nginx onchkconfig MysqLd onchkconfig PHP-fpm on

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native