Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP and Apache PROBLEM!

Options
2»

Comments

  • Registered Users Posts: 6,150 ✭✭✭Talisman


    What virtualization software are you using? My recommendation would be to use VirtualBox and Vagrant.

    The beauty of Vagrant is that the folder you launch the VM from is mapped in the VM so you can edit the files within the folder structure on your local machine and not have to rely on using nano.


  • Closed Accounts Posts: 147 ✭✭Stanlex


    Talisman wrote: »
    What virtualization software are you using? My recommendation would be to use VirtualBox and Vagrant.

    The beauty of Vagrant is that the folder you launch the VM from is mapped in the VM so you can edit the files within the folder structure on your local machine and not have to rely on using nano.

    I'm using VMWare player. Free for non-commercial use. Sounds like a handy feature to have. Will give it a go. Is it free?


  • Registered Users Posts: 241 ✭✭fcrossen


    Stanlex wrote: »
    What made things really difficult was the fact that I was running a Ubuntu server on a VM so the interface was constantly the terminal.

    Download something like Komodo Edit. It will allow you to set up a SFTP connection to your VM allowing you to edit files on it.


  • Registered Users Posts: 6,150 ✭✭✭Talisman


    I'm using VMWare player. Free for non-commercial use. Sounds like a handy feature to have. Will give it a go. Is it free?
    VirtualBox and Vagrant are both free and cross platform.

    Here is a bash script that I use to automatically setup the Ubuntu VM for me. It contains the commands to install MariaDB (MySQL), PHP5.5, Nginx/Apache, Node.js, MongoDB, Git and Ruby on Rails - you just need the relevant lines uncommented to install the required software.

    install.sh:
    #!/usr/bin/env bash
    
    ## MySQL credentials
    sudo debconf-set-selections <<< 'mariadb-server mariadb-server/root_password password root'
    sudo debconf-set-selections <<< 'mariadb-server mariadb-server/root_password_again password root'
    
    ## Update Ubuntu sources
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.old
    sudo sed -i -e 's/us.archive.ubuntu.com/archive.ubuntu.com/g' /etc/apt/sources.list
    sudo apt-get -y update
    
    ## Install Base packages
    sudo apt-get install -y python-software-properties curl vim
    
    ## Node.js repository
    #sudo add-apt-repository -y ppa:chris-lea/node.js
    #sudo apt-get -y update
    ## Install Node
    #sudo apt-get -y install nodejs
    
    ## How to find the fastest Ubuntu sources mirror
    ## sudo npm install -g ffum
    ## ffum
    
    ## MongoDB repository
    #sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
    #echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | sudo tee -a /etc/apt/sources.list.d/10gen.list
    #sudo apt-get -y update
    ## Install MongoDB
    #sudo apt-get -y install mongodb-10gen
    
    ## MariaDB repository
    sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
    sudo add-apt-repository 'deb http://ftp.heanet.ie/mirrors/mariadb/repo/5.5/ubuntu precise main'
    sudo apt-get -y update
    ## Install MariaDB
    sudo apt-get install -y mariadb-server
    
    ## Nginx repository
    echo "deb http://ppa.launchpad.net/nginx/stable/ubuntu $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/nginx.list
    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C
    sudo apt-get -y update
    sudo apt-get -y install nginx
    
    ## Install Git
    sudo apt-get install -y git-core
    
    ## PHP5 repository
    sudo add-apt-repository -y ppa:ondrej/php5
    sudo apt-get update
    
    ## Install PHP5 packages
    sudo apt-get install -y php5 php5-mcrypt php5-gd php5-curl php5-mysql php5-fpm php5-cli php5-cgi php5-common php5-xcache php5-json
    ## Xdebug
    #sudo apt-get install -y php5-xdebug
    
    #cat << EOF | sudo tee -a /etc/php5/mods-available/xdebug.ini
    #xdebug.scream=1
    #xdebug.cli_color=1
    #xdebug.show_local_vars=1
    #EOF
    
    ## Install Apache
    #sudo apt-get install -y apache2 libapache2-mod-php5
    ## Enable Apache mod-rewrite
    #sudo a2enmod rewrite
    
    ## Set the document root to the shared vagrant folder
    rm -rf /var/www
    ln -fs /vagrant /var/www
    
    ## Enable errors
    #sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/apache2/php.ini
    #sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/apache2/php.ini
    
    ## Restart  Apache
    #sudo service apache2 restart
    
    ## Composer
    curl -sS https://getcomposer.org/installer | php
    sudo mv composer.phar /usr/local/bin/composer
    
    ## Ruby on Rails : Development
    #curl -L get.rvm.io | bash -s stable
    #source ~/.rvm/scripts/rvm
    #rvm install ruby
    #gem install rails
    
    ## Ruby on Rails : Production
    ## See https://github.com/joshfng/railsready
    #wget --no-check-certificate https://raw.github.com/joshfng/railsready/master/railsready.sh && bash railsready.sh
    
    You'll see there is a section where I remove /var/www and replace it with a symbolic link to /vagrant. /vagrant is the link to the folder where the VM was launched with the "vagrant up" command. The install.sh file goes in the same folder that the Vagrant VM is launched from.

    When you initialise Vagrant in a folder it creates a text file named "Vagrantfile" which you can edit. It comes with a warning not to edit it unless you know what you're doing so I've included my copy of the file so you can see how it's done, the file will then instruct Vagrant to run the install.sh script when the VM is launched.

    Vagrantfile:
    # -*- mode: ruby -*-
    # vi: set ft=ruby :
    
    # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
    VAGRANTFILE_API_VERSION = "2"
    
    Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    
      config.vm.box = "precise64"
    
      config.vm.box_url = "http://files.vagrantup.com/precise64.box"
    
      #config.vm.network :hostonly, "33.33.33.10"
    
      config.vm.network :forwarded_port, guest: 80, host: 8080
    
      # MySQL port forward
      config.vm.network :forwarded_port, guest: 3306, host: 8306
    
      # Provision the system
      config.vm.provision :shell, :path => "install.sh"
    
      # www-root requirement
      config.vm.synced_folder ".", "/vagrant", owner: "www-data", group: "www-data", :nfs => false, :mount_options => ["dmode=777","fmode=666"]
    
    end
    
    You can see the file is for an Ubuntu Precise64 VM (64-bit Ubuntu 12.04 LTS Server). The additions I made to the file:

    MySQL port forward: This will allow you to access the MySQL database port (3306) on the local machine via the forwarded port (8306).

    Provision the system: This is the instruction to run the install.sh script.

    www-root requirement: By default the VM will set the ownership of the /vagrant directory structure to vagrant:vagrant, this can lead to permissions problems in development. The additional line tells the VM to set the owner and group of the share /vagrant structure to www-root:www-root which will get you around any permissions problems that might occur because you will be editing the files locally.

    If you encounter any issues let me know.


  • Registered Users Posts: 6,464 ✭✭✭MOH


    If you're not going the Vagrant route, Notepad++ also has decent remote editing over FTP.

    Or you might find CodeLobster useful, it's a free IDE. The remote editing used to be a bit flaky but I haven't used it in a couple of years since I switched to linux, and they've apparently improved it since then.


  • Advertisement
  • Closed Accounts Posts: 147 ✭✭Stanlex


    Thanks for the suggestions, I really like the idea of having a shell script to download things automatically. Never thought of it really.

    I'm working on a script to download YouTube videos at the moment. Since YouTube changes their ways every year, last years stuff won't work this year.


Advertisement