未加星标

Wordpress on a Google Compute Engine f1-micro

字体大小 | |
[开发(php) 所属分类 开发(php) | 发布者 店小二03 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

The cheapest offering on Google's cloud platform is the f1-micro instance. The f1-micro is a shared core machine which provides access to a single, virtualised CPU core (with burst capability to help with sudden load spikes) and a meagre 0.6GB of memory: these specs don't sound great, but it turns out you can just about cram a moddest-traffic Wordpress instance on it with a little tweaking - and here's the good news, it'll only set you back 50 a year!

Creating a new Instance

Head on over to the Google Cloud Console and sign up (Google currently offer a 60 day free trial to sweeten the deal). Battle your way through the onboarding guide and then head over to the Google Compute Engine control panel .

Click create Instance Select the region closest to you (ie: US or EU) Select your machine type (micro 1 shared vCPU) Choose which distro you want to boot into (I am using Debian Jessie) and change the Boot disk size if desired (although the default, 10GB, is plenty) Make sure you check the Allow HTTP and Allow HTTPS Traffic checkboxes under Firewall settings. Click create and wait for Goolge to provision your instance.

Once your machine has been provisioned (should only take a couple of minutes) you can connect direct from your browser by clicking the SSH button from the Compute Engine VM Instance Control Panel .


Wordpress on a Google Compute Engine f1-micro

You can also click this drop down to setup SSH access from the command line by adding an SSH KeyPair or by using gcloud command line interface .

Obtaining a Static IP

By default, Compute Engine instances are assigned an ephemeral IP (meaning that it may change should the instance shutdown); for production websites you need to assign a static IP to your instance so you can point your doman at it; this can be done through the Networking External IP Addresses Control Panel - you can select a the 'Regional' type selecting the same region where your instance is running (eg: europe-west-1 ).

Base LEMP Setup

The following is based off a stock Debian Jessie install; I make use of Nginx (less CPU and memory intensive then Apache),php-FPM (connects Nginx and PHP), PHP 5 and mysql. The following command will install all of the required dependencies:

$ sudo apt-get install mysql-server nginx php5-fpm php5-mysql php-apc \ pwgen python-setuptools curl git unzip php5-curl php5-gd php5-intl \ php-pear php5-imagick php5-mcrypt php5-ps php5-pspell php5-recode \ php5-sqlite php5-xmlrpc php5-xsl

Once installed; you will need to tweak your php-fpm settings, and change the cgi.fix_pathinfo setting from 1 to 0 :

$ sudo sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php5/fpm/php.ini

You may also want to increase the max upload filesize from the 2MB default:

$ sudo sed -i "s/upload_max_filesize =.*/upload_max_filesize = 50/g" /etc/php5/fpm/php.ini $ sudo sed -i "s/post_max_size =.*/post_max_size = 50M/g" /etc/php5/fpm/php.ini

Now configure Nginx's default site by editing /etc/nginx/sites-available/default :

server { listen 80; listen [::]:80 default ipv6only=on; root /usr/share/nginx/www; index index.php; location / { try_files $uri $uri/ /index.php?q=$uri&$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; include fastcgi_params; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; } }

When you make changes to your configuration, you will need to restart the associated services:

$ sudo service nginx restart $ sudo service php5-fpm restart

This configuration will serve php from /usr/share/nginx/www - drop an index.php file there which invokes phpinfo() and visit your Compute Engine instance's IP address in your browser to confirm that everything has been configured - make sure you delete that file once you're done.

Wordpress Install

Now the easy bit :) Start by grabbing wordpress:

$ cd /usr/share/nginx $ wget https://wordpress.org/latest.tar.gz $ tar xvf latest.tar.gz && rm latest.tar.gz $ mv wordpress www $ chown -R www-data:www-data $ chmod -R 766 ./www/wp-content/uploads

You can now visit your Compute Engine instance's IP address in your browser and the Wordpress installation script should start; you may want to consider creating a MySQL user for wordpress without GRANT and ALTER permissions.

Enabling Automatic Updates

Wordpress will automatically install security patches if it has a way to write to the local filesystem; one option is to configure the FS-METHOD constant in your wp-config.php to use direct and grant the permissive permissions on your /usr/share/nginx/www folder; generally speaking this is fine if you only have a single Wordpress installation running on the server, however you may wish to consider setting FS-METHOD to ssh2 and setting up an SSH key/pair .

Sending Email

If you need your Wordpress instance to be able to send email (eg: for a contact form); then you may wish to consider installing the WP Mail SMTP Plugin which will reconfigure Wordpress to route all mail through an SMTP server (ie: a GMail account ).

Backups

If you care about your content, it's essential that you back up both the database and the wp-content folder on a regular basis. I've personally found the BackupWordPress plugin does a great job for creating local archives on the sever; these can then be shipped over to Google Drive by using gdrive and cron: don't forget to restore from your backup from time-to-time.

Additionally, you can make use of the Compute Engine Snapshot

本文开发(php)相关术语:php代码审计工具 php开发工程师 移动开发者大会 移动互联网开发 web开发工程师 软件开发流程 软件开发工程师

主题: NginxPHPCPUDebianSQLMySQLWordETHGMHead
分页:12
转载请注明
本文标题:Wordpress on a Google Compute Engine f1-micro
本站链接:http://www.codesec.net/view/480797.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 开发(php) | 评论(0) | 阅读(41)