日期:2014-05-16  浏览次数:20987 次

yum安装nginx+mysql+php

命令准备

创建目录

mkdir 目录名

chmod 777 目录名 变更权限

加入开机启动项服务

chkconfig --add php-fpm

chkconfig nginx on 

查找文件位置 经常用于查找yum安装后各种配置文件及启动程序所在位置

find|grep php-fpm

服务启动

service nginx
start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help|configtest

service nginx  start

service php-fpm start

查看进程

ps -ef | grep java

查看进程

kill -9 进程id

1.安装

添加nginx源

http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm 

wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm

rpm -qa | grep nginx 检查nginx 是否加入源路径


安装 php mysql nginx

yum install mysql mysql-server php php-mysql php-fpm nginx


php组件库 选择安装 如果找不到源地址,请查找小技巧里面的更新第三方源库

yum install php-cli php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidy php-common php-devel


2.配置

2.1nginx 配置

配置文件位置 如果找不到相关配件,查找文件位置 命令
/etc/nginx/nginx.conf
/etc/nginx/conf.d/*.conf
 
多个站点放在conf.d目录,在nginx.conf用include语法包含
include /etc/nginx/conf.d/*.conf;


默认default.conf修改

server {
    listen       80;
    server_name  localhost;#自定义域名配置

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        root   /home/www;#自定义目录设置
        index  index.html index.htm index.php;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #错误页处理
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /home/www;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        #root           /home/www;
        #fastcgi_pass   127.0.0.1:9000;
	fastcgi_pass  unix:/tmp/php-cgi.sock;#这种方式听说性能提升比较多
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /home/www$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

类似

其他*.conf 可自定义添加

server
	{
		listen       80;
		server_name wx.vtz.cc;
		index index.html index.htm index.php;
		root  /home/wwwroot/weixin;

		location ~ .*\.(php|php5)?$
			{
				try_files $uri =404;
				fastcgi_pass  unix:/tmp/php-cgi.sock;
				fastcgi_index index.php;
				include fcgi.conf;
			}

		location /status {
			stub_status on;
			access_log   off;
		}

		location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
			{