So I was tasked to set up a LEMP Stack with PHP7 on a Google Compute Engine and to install a new Magento 1.9 install on it, for further development of things. This is my story (that is to say this isn’t as much a tutorial as it is just a notebook of the things I did to get it to work):
Step 1: Set up Compute Engine
This is all fairly straightforward stuff, and not really in the scope if this article.
I set up an account and created a VM with Ubuntu 14.04 image.
Once the VM is ready, logon via SSH.
Step 2: Install LEMP on server
Firstly we install the basic LEMP package on the server. Starting with Nginx
sudo apt-get update
sudo apt-get install nginx
To install MySQL some more steps are needed
sudo apt-get install mysql-server
You will be asked to set a password for the root user of the database.
enter the password you set earlier, it will ask you to change it again; not necessary. It will then ask you to set some security rules, I said Yes to all of ’em.
To install PHP7 we have to add the repo for it first, get it’s contents and install it.
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0 php7.0-fpm php7.0-mysql php7.0-mcrypt php7.0-curl php7.0-gd php7.0-soap php7.0-mbstring
sudo phpenmod -v 7.0 0-mcrypt
Most of these modules are required by Magento, so we’re already installing them now, while we’re at it. We enable mcrypt specifically to prevent errors down the road.
For security reasons, edit the php.ini file
sudo nano /etc/php/7.0/fp,/php.ini
.. and find
Uncomment the line (remove the semicolon) and set to 0.
Restart PHP7 for the changes to take effect
sudo service php7.0-fpm restart
Step 3: Configure NGINX for PHP7
Now we configure NGINX to use PHP7 for web rendering
sudo nano /etc/nginx/sites-available/default
This is my copy
Save and close the config, and restart nginx to apply changes
sudo service nginx restart
Step 4: Install PHPMyAdmin
sudo apt-get install phpmyadmin
sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/html/
That last command is to make a symbolic link to access phpmyadmin from [DOMAIN]/phpmyadmin/
Step 5: Install n98-magerun
Because it speeds up development, we install n98-magerun.
Set rights to the file
chmod +x ./n98-magerun.phar
Copy the file to /usr/local/bin/ for system-wide usage
sudo cp ./n98-magerun.phar /usr/local/bin/
For the ease of use set an alias for the filename, and source the edit
sudo nano ~/.bash_aliases
Step 6: Install SASS
For more ease of use, we install SASS.
sudo apt-get install ruby # install ruby
\curl -sSL https://get.rvm.io | bash -s stable # install Ruby Version Manager
source it to use
sudo su -c "gem install sass" # install sass gem
rvm use 2.2 # update ruby to 2.2.6.
At this point my terminal seemed to crash, but this answer clued me in to the answer. I had an error in the
apt-get update. So I ran the command to see where it went wrong, and the answer was given to me:
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
So I did, ran the
rvm install ruby-2.2.6 again, and voila.
There ye go.
Step X: The permissions
The biggest bitch in this whole story, every time, are the server permissions.
This saved my day
sudo chown -R "$USER":www-data /usr/share/nginx/html/*
sudo chmod -R 0755 /usr/share/nginx/html/*
After install I saw that the thumbs weren't generated properly, so I figured it was php7.0-md, but it turns out I missed the /media/tmp/ folder, and reset all the permissions in the media/ folder.
sudo chown -R alextimmer:www-data .
Got a 500 error on PHPMyAdmin export function, due to a code error in the module. This is due a code-error for which PHP7 is more strict.
sudo nano +864 /usr/share/phpmyadmin/export.php
remove the '2', to fix the error.