美文网首页vagrant
Vargant Ubuntu 15.04安装LNMP

Vargant Ubuntu 15.04安装LNMP

作者: 舒落浅 | 来源:发表于2015-12-26 22:30 被阅读286次

    Vargant Ubuntu 15.04安装LNMP

    环境
    Mac Os 10.11.1
    1.Vagrant 1.7.4
    2.VirtualBox 5.0.4
    3.Ubuntu 15.4 amd64
    http://uec-images.ubuntu.com/vagrant/vivid/current/vivid-server-cloudimg-amd64-vagrant-disk1.box

    • 配置Vagrant
    cd dev
    mkidr project_name 
    vagrant init
    vagrant box add ubuntu15 /Users/you/Iwork/vbox/vivid-server-cloudimg-amd64-vagrant-disk1.box //绝对路径
    
    vim Vagrantfile
    onfig.vm.box = "ubuntu15"
    config.vm.network "private_network", ip: "192.168.33.20"
    config.vm.synced_folder "project_name", "/var/www/html/project_name"
    //可以配置更多项目
    config.vm.synced_folder "project_name1", "/var/www/html/project_name1"
    config.vm.synced_folder "project_name2", "/var/www/html/project_name2"
    
    vagrant up  #stops the vagrant machine
    vagrant ssh #connects to machine via SSH user vagrant passowd vagrant
    vagrant halt #starts the vagrant machine
    
    • 更新ubuntu源
    sudo apt-get update
    
    • 安装Nginx [/etc/nginx/nginx.conf]
    sudo apt-get install nginx
    
    • 安装mysql
    sudo apt-get install mysql-server 
    The following extra packages will be installed:
      libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18 libterm-readkey-perl 
      mysql-client-5.6 mysql-client-core-5.6 mysql-common mysql-server-5.6 mysql-server-core-5.6
    
    • Starting and Stopping the MySQL Server

    The MySQL server is started automatically after installation. You can check the status of the MySQL server with the following command:

    sudo service mysql status

    Stop the MySQL server with the following command:

    sudo service mysql stop

    To restart the MySQL server, use the following command:

    sudo service mysql start

    • 安装PHP(php-fpm) [/etc/php5/fpm/php-fpm.conf ] [/etc/php5/fpm/php.ini]
    sudo apt-get install php5-fpm php5-mysql php5-curl php5-gd
    
    The following NEW packages will be installed:
      php5-cli php5-common php5-fpm php5-json php5-mysql php5-readline php5-curl php5-gd
     
    
    • mysql远程连接
     sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
     # bind-address           = 127.0.0.1
     //设置mysql访问权限
     GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '要设置的密码' WITH GRANT OPTION;
    FLUSH PRIVILEGES;
    
    • 配置PHP
    ;cgi.fix_pathinfo=1
     cgi.fix_pathinfo=0
     
     sudo service php5-fpm restart
    
    • 修改php-fpm用户配置 事关目录权限
    user = vagrant
    group = vagrant
     
    sudo service php5-fpm restart
    
    • 配置Nginx default /etc/nginx/sites-available
    root /var/www/html;#根目录
     # Add index.php to the list if you are using PHP
    index.php index index.html index.htm index.nginx-debian.html;
    
            #location ~ \.php$ {
            #       include snippets/fastcgi-php.conf;
            #
            #       # With php5-cgi alone:
            #       fastcgi_pass 127.0.0.1:9000;
            #       # With php5-fpm:
            #       fastcgi_pass unix:/var/run/php5-fpm.sock;
            #}
            
            #location ~ /\.ht {
            #      deny all;
            #}
            
            location ~ \.php$ {
                   include snippets/fastcgi-php.conf;
            
                   # With php5-cgi alone:
                   #fastcgi_pass 127.0.0.1:9000;
                   # With php5-fpm:
                   fastcgi_pass unix:/var/run/php5-fpm.sock;
            }
            
            location ~ /\.ht {
                    deny all;
            }
            sudo nginx -c /etc/nginx/nginx.conf  #start up
            sudo nginx  -s reload #reload
    

    相关文章

      网友评论

        本文标题:Vargant Ubuntu 15.04安装LNMP

        本文链接:https://www.haomeiwen.com/subject/gyrbhttx.html