您的位置:首页 > 运维架构 > Nginx

linux-php-yii2-nginx项目配置

2016-04-21 10:34 549 查看
工作环境配置

操作系统linux ubuntu14

系统操作常用命令

sudo root权限

chmod 权限控制

cd 跳转目录  ../返回上级

rm 删除

vi 编辑文件 :w :q :!w :!wq 写入 退出 !强制标记

1安装php (后台)

sudo add-apt-repository ppa:ondrej/php5

sudo apt-get update

安装php扩展

sudo apt-get install php5-cgi php5-fpm php5-curl php5-mcrypt php5-gd php5-dev

查看php配置确认扩展的安装(mongo,redis...) http://localhost/phpinfo.php
<?php

phpinfo();

?>

php状态操作管理命令

sudo service php5-fpm {start|stop|quit|restart|reload|logrotate}

2安装Redis (用于启动job 管理resque)

sudo apt-get install redis-server

redis php扩展

sudo apt-get install php5-redis

3安装nginx服务器

sudo apt-get install nginx

安装成功查看http://localhost/index.html

修改服务器配置信息

vi /etc/nginx/conf.d/wm.conf

例如以下后台和前台的配置(yii2框架配置)

server {

     listen 8080;

     server_name localhost;

     root /usr/share/nginx/html/project/XX/src/backend/web/;

     index index.html index.htm index.php;

     access_log /var/log/nginx/localhost-access.log;

     error_log  /var/log/nginx/localhost-error.log;

     location / {

         proxy_pass http://localhost:8081/;
     }

     location ~ .*\.(php|php5)?$ {

         fastcgi_pass   unix:/var/run/php5-fpm.sock;

         include        fastcgi_params ;

     }

     location ~ /\.(ht|svn|git) {

             deny all;

     }

}

server {

     listen       8081;

     server_name localhost;

     root /usr/share/nginx/html/project/XX/src/frontend/web/;

     index index.html index.htm index.php;

     access_log /var/log/nginx/localhost-access.log;

     error_log  /var/log/nginx/localhost-error.log;

     location / {

         try_files $uri $uri/ /index.php?$args;

     }

     location /vendor/ {

         alias /usr/share/nginx/html/project/XX/src/vendor/;

     }

     location ~ .*\.(php|php5)?$ {

         fastcgi_pass   unix:/var/run/php5-fpm.sock;

         include        fastcgi_params;

     }

     location ~ /\.(ht|svn|git) {

             deny all;

     }
}

4安装mongo数据库 (robomongo)

php-mongo扩展

sudo pecl install mongo 

修改配置/etc/php5/mods-available

最后添加extension=mongo.so

重启php 
sudo service php5-fpm restart

5安装ruby

sudo apt-get install ruby

设置下载的淘宝镜像

gem sources --remove http://rubygems.org/
gem sources -a https://ruby.taobao.org/
gem sources -l

*** CURRENT SOURCES *** https://ruby.taobao.org
6安装SASS
gem install sass

7安装nodejs(服务器处理并发)

curl https://raw.githubusercontent.com/creationix/nvm/v0.25.1/install.sh | bash

. ~/.profile
nvm install v0.10.24

8安装grunt全局(自定义执行任务,项目部署,初始化,coffee转换成js)
npm install -g grunt-cli

9安装bower全局(前段开发包管理工具)
npm install -g bower

10安装supervisor管理定时resque JOB

sudo apt-get install supervisor

配置sudo vi /etc/supervisor/conf.d/supervisor.conf

[program:scheduler]

process_name=%(program_name)s_%(process_num)02d

directory=/home/user/XX

command=php /home/user/XX/src/backend/modules/resque/components/bin/resque-scheduler

numprocs=1

redirect_stderr=True

autostart=True

autorestart= True

environment=QUEUE='global',LOGGING='1',APP_INCLUDE='/home/user/XX/src/backend/modules/resque/components/lib/Resque/RequireFile.php'

stdout_logfile=/var/log/supervisor/%(program_name)s-stdout.log

stderr_logfile=/var/log/supervisor/%(program_name)s-stderr.log

[program:global]

process_name=%(program_name)s_%(process_num)02d

directory=/home/user/XX

command=php /home/user/XX/src/backend/modules/resque/components/bin/resque

numprocs=5

redirect_stderr=True

autostart=True

autorestart= True

environment=QUEUE='global',LOGGING='1',APP_INCLUDE='/home/user/XX/src/backend/modules/resque/components/lib/Resque/RequireFile.php'

stdout_logfile=/var/log/supervisor/%(program_name)s-stdout.log

stderr_logfile=/var/log/supervisor/%(program_name)s-stderr.log
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  configure project