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


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)$
			{
				expires      30d;
			}

		location ~ .*\.(js|css)?$
			{
				expires      12h;
			}

		access_log  /home/wwwlogs/weixin_access.log  access;
	}

2.2  php-fpm.conf配置

include=/etc/php-fpm.d/*.conf  //因为包含其他文件,/etc/php-fpm.d查找到www.conf 修改

[www] 

#设置监听 修改项

#listen = 127.0.0.1:9000
listen = /tmp/php-cgi.sock


3.添加服务自启动

nginx 服务
chkconfig --add nginx 
chkconfig nginx on
service nginx start

php-fpm
chkconfig --add php-fpm 
chkconfig php-fpm on
service php-fpm start

到此配置结束 

yum安装nginx+mysql+php,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。