Centos 安装nginx + php + mysql
一.更新最快的源
yum -y update
添加源,在/etc/yum.repo.d目录(centos 6.*为/etc/yum.repos.d目录)下创建一个文件alt.ru.repo,添加如下内容:
name=CentALT Packages for Enterprise Linux 5 - $basearch
baseurl=http://centos.alt.ru/repository/centos/5/$basearch/
enabled=1
gpgcheck=0
二.安装mysql
yum -y install mysql mysql-server mysql-devel
三.安装php
如出现以下错误:
Error: Missing Dependency: libt1.so.5()(64bit) is needed by package ***
运行如下命令:
如出现:
The program package-cleanup is found in the yum-utils package.
运行如下命令
yum install yum-utils
打开/etc/php.ini,将cgi.fix_pathinfo=1前的注释去掉,并将值改为0:
四.安装nginx
yum -y install nginx
配置多域名:
在/etc/nginx目录下新建文件夹vhosts
新建 www.domain.com
粘贴以下内容:
server {
listen 80;
server_name www.domain.com;
access_log /var/log/domain.access.log main;
location / {
root /wwwroot/www.domain.com;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /wwwroot/www.domain.com/$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.ht {
deny all;
}
}
在nginx.conf中加入以下语句
include /etc/nginx/vhosts/*;
重启nginx
五.将服务加入启动项,并启动各个服务
chkconfig php-fpm on
chkconfig nginx on