Centos下配置nginx和php环境

yum安装
1.安装EPEL插件
2.安装mysql,完成后’service mysqld start’然后’mysqladmin -u root password “这里输入新密码”‘来添加密码(mysql默认无密码)然后’service mysqld restart’重启
3.让nginx和php-fpm相关联
‘service nginx configtest’然后
‘cat /etc/nginx/nginx.conf’
获取nginx默认配置文件的位置。
vi /etc/nginx/conf.d/default.conf
webroot要给777权限
sudo chmod 777 /usr/share/nginx/html

添加防火墙规则:
iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 9000 -j ACCEPT
service iptables restart

4.安装php依赖
yum install php-gd php-mysql php-mbstring php-xml php-mcrypt

更改默认的apache用户组为nginx
vi /etc/php-fpm.d/*.conf

5.多域名绑定设置(默认文件夹下的话,需要注意有个index.html的优先级在index.php之前)
virtul.conf下添加server设置。
‘’’
server {
listen 80;
listen ww1.example.com:80;
server_name ww1.example.com alias another.alias;

location / {
    root   html/web;
    index  index.html index.htm index.php;
}

location ~ \.php$ {
    root           html/web;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

}
‘’’
两个root文件夹下的路径需要注意。

mysql编译安装:
http://www.cnblogs.com/xiongpq/p/3384681.html
php: