Ubuntu 14.04 安装 Nginx PHP5 MySQL

来源:互联网 发布:易语言游戏多开器源码 编辑:程序博客网 时间:2024/05/22 02:18

一、安装nginx

$ sudo apt-get update$ sudo apt-get install nginx

Fig.01: Download and Install Nginx on Ubuntu Linux
二、安装mysql

$ sudo apt-get install mysql-server php5-mysql

Fig.03: Ubuntu Linux Install MySQL to Manage Site Data with PHP
中间让你输入mysql-server的root的密码两次,两次都输入的同一个。安装完毕后使用以下命令测试一下是不是安装成功

mysql -u root -p 如果出现让你输入密码,就没有问题.

三、安装php

$ sudo apt-get install php5-fpm

Fig.12: Install PHP for Server Side Processing on Ubuntu

四、配置环境

1.配置php5

   vi /etc/php5/fpm/php.ini 
    找到:;cgi.fix_pathinfo=1 
    改为:cgi.fix_pathinfo=0 

2.配置nginx

(1)删除 /etc/nginx/sites-available/default

(2)/etc/php5/fpm/pool.d/www.conf

里面找到这样一段代码:

listen = 127.0.0.1:9000 

在这上面代码的下面添加一行:

listen = /var/run/php5-fpm.sock

(3)/etc/php5/fpm/pool.d/www.conf里面找到这样一段代码,取消注释

listen.owner = www-data  listen.group = www-data  listen.mode = 0660  

重启 service php5-fpm restart

3.插件wkhtmltopdf安装:

$ sudo apt-get install xfonts-75dpi$ wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2/wkhtmltox-0.12.2_linux-trusty-amd64.deb$ sudo dpkg -i wkhtmltox-0.12.2_linux-trusty-amd64.deb$ wkhtmltopdf http://www.google.com test.pdf

4.rsync配置:

1.ubuntu  14.04默认已安装rsync,rsync服务默认不是启动的,我们要修改下面的文件。

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. sudo vim /etc/default/rsync  
[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. RSYNC_ENABLE=true   #false改true  

2.修改配置文件

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. sudo cp /usr/share/doc/rsync/examples/rsyncd.conf /etc   #已默认安装的软件,默认不启动的似乎都要这么


# sample rsyncd.conf configuration file


# GLOBAL OPTIONS


#motd file=/etc/motd
log file=/var/log/rsyncd
# for pid file, do not use /var/run/rsync.pid if
# you are going to run rsync out of the init.d script.
pid file=/var/run/rsyncd.pid
syslog facility=daemon
#socket options=


# MODULE OPTIONS


[ftp]


        comment = public archive
        path = /var/www/bnqc/edusoho/edubnqc/web/files/rsync/UploadFiles    #(路径)
        use chroot = no
#       max connections=10
        lock file = /var/lock/rsyncd
# the default for read only is yes...
        read only = no

  list = yes
        uid = www-data             #(文件夹的项目主)
        gid = www-data            #(文件夹的项目组)
        charset = UTF-8
#       exclude = 
#       exclude from = 
#       include =
#       include from =
#       auth users = 
#       secrets file = /etc/rsyncd.secrets
        strict modes = yes
#       hosts allow =
#       hosts deny =
        ignore errors = no
        ignore nonreadable = yes
        transfer logging = no
#       log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes.
        timeout = 600
        refuse options = checksum dry-run
        dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz




然后重启各项服务、

sudo service php5-fpm restart 

sudo service nginx restart


sudo service rsync restart



五、项目部署

1.数据库配置文件修改:将项目源文件夹拷贝到 /var/www目录下面,修改源文件夹下面的edubnqc/app/config/parameters.yml 

parameters:
    database_driver: pdo_mysql
    database_host: 127.0.0.1      #(填写数据库的地址)
    database_port: null
    database_name: bnqc         #数据库名称
    database_user: root        #数据库的用户名
    database_password: 123456    #数据的密码
    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_user: null
    mailer_password: null
    locale: zh_CN
    secret: ThisTokenIsNotSoSecretChangeIt

2.数据库导入:将edubnqc/bnqc.sql  导入mysql数据库


3.服务器端口配置:将edubnqc/edubnqc 拷贝到/etc/nginx/sites-enabled 下面

   编辑文件edubnq  修改:

    listen:80    #端口

     # 程序的安装路径
    root /var/www/edubnqc/web;

 # 日志路径
    access_log /var/log/nginx/edubnqc.com.access.log;
    error_log /var/log/nginx/edubnqc.com.error.log;

 重启服务器 service nginx restart

   

0 0
原创粉丝点击