技术控

    今日:30| 主题:57959
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] Building Your Startup With PHP: Choosing and Configuring Production Hosting

[复制链接]
哼着哼着就走调了 投递于 2016-10-3 18:43:59
261 1

Building Your Startup With PHP: Choosing and Configuring Production Hosting

Building Your Startup With PHP: Choosing and Configuring Production Hosting-1-技术控-interested,especially,launching,business,choosing
      What You'll Be Creating       This tutorial is part of the Building Your Startup With PHP series on Envato Tuts+. In this series, I'm guiding you through launching a startup from concept to reality using my Meeting Planner app as a real-life example. Every step along the way, I'll release the Meeting Planner code as open-source examples you can learn from. I'll also address startup-related business issues as they arise.
  In this tutorial, I'll explore choosing an ideal hosting platform for Meeting Planner and the initial configuration of our server. I'll be guiding you through the process as I migrate the pre-launch website to a better production environment for our upcoming alpha launch.
   If you haven't tried out Meeting Planner yet, go ahead and schedule your first meeting . I do participate in the comment threads below, so tell me what you think! I'm especially interested if you want to suggest features or topics for future tutorials.
   As a reminder, all of the code for Meeting Planner is written in the Yii2 Framework for PHP. If you'd like to learn more about Yii2, check out our parallel series Programming With Yii2 .
  Selecting a Hosting Company

   For many companies, Amazon's AWS is the emerging go-to solution. When AWS goes down, so do many of the web's most well-known services. But AWS is also expensive, often overly complex, and run by a company that has a history of hostility towards employees , especially its female and warehouse workers. Additionally, Amazon has single-handedly pressed the rapid over-development of my hometown Seattle in such a way that has fundamentally changed the city forever , but not necessarily for good .
   Recently, I wrote a guide to alternatives to Amazon for cloud computing services. There are a lot of competitors, none as vast, but many better, more affordable, and easier to use. As Meeting Planner grows, I may consider AWS again, but for now I want to look elsewhere.
   In the near term, at most, I'll need a server or two running web and database services. For this, managed hosting companies such as Rackspace , Linode , and my favorite Digital Ocean work just fine.
  For now, Meeting Planner can run on one server, but as it grows, it's possible I'll need multiple web and database servers. Based on my experience, AWS makes it easier to implement this, but experienced system administrators can easily do this with the aforementioned cloud providers.
  This tutorial will guide you through launching a web and database server up in the Digital Ocean clouds.
  Working With Digital Ocean

   I've written a handful of tutorials about Digital Ocean at Envato Tuts+, including how to use their API for server configuration. I also recently wrote about my positive experience with the Digital Ocean affiliate program .  Full disclosure: when asked, Digital Ocean provided a small account credit to cover the droplet costs for this startup series for up to six months.
  Over the past two years that I've been a user there, they've consistently incrementally improved their quality of service, user experience, support and feature set. For a while now, it's been extremely rare to experience a slowdown or outage, common in the early cloud hosting market.
  Let's get started configuring the initial production server for Meeting Planner.
  Configuring a New Droplet

  Creating a New Droplet

   Digital Ocean instances are called droplets. I'm sure they thought of calling them tadpoles or fish, but we developers are often destroying them, so the non-sentient droplet is a better term.
   From the Droplets menu, we'll  Create a Droplet . First, we choose Ubuntu 14.04 for our image and the $10 per month server option:
     

Building Your Startup With PHP: Choosing and Configuring Production Hosting

Building Your Startup With PHP: Choosing and Configuring Production Hosting-2-技术控-interested,especially,launching,business,choosing
     Next, I chose the San Francisco region because it's closest to me:
     

Building Your Startup With PHP: Choosing and Configuring Production Hosting

Building Your Startup With PHP: Choosing and Configuring Production Hosting-3-技术控-interested,especially,launching,business,choosing
     I also asked Digital Ocean to reuse my public key for establishing the login; key login is more secure than password login. Then, I chose the hostname apps.meetingplanner.io for the server:
     

Building Your Startup With PHP: Choosing and Configuring Production Hosting

Building Your Startup With PHP: Choosing and Configuring Production Hosting-4-技术控-interested,especially,launching,business,choosing
     When you click Create , you'll see the droplet being formed:
     

Building Your Startup With PHP: Choosing and Configuring Production Hosting

Building Your Startup With PHP: Choosing and Configuring Production Hosting-5-技术控-interested,especially,launching,business,choosing
    Once it's ready, you'll be given an IP address, to which I mapped meetingplanner.io domain records for the initial configuration:
     

Building Your Startup With PHP: Choosing and Configuring Production Hosting

Building Your Startup With PHP: Choosing and Configuring Production Hosting-6-技术控-interested,especially,launching,business,choosing
    I'll wait until later to map the root meetingplanner.io domain to the new server.
  Configuring the Server

  Here's what you'll see when you log in to the server the first time:
  1. $ ssh -i ~/.ssh/id_lookahead [email protected]
  2. You are required to change your password immediately (root enforced)
  3. Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-85-generic x86_64)

  4. * Documentation:  https://help.ubuntu.com/

  5.   System information as of Wed May 18 15:59:01 EDT 2016

  6.   System load: 0.0               Memory usage: 5%   Processes:       54
  7.   Usage of /:  4.2% of 29.40GB   Swap usage:   0%   Users logged in: 0

  8.   Graph this data and manage this system at:
  9.     https://landscape.canonical.com/

  10. 0 packages can be updated.
  11. 0 updates are security updates.


  12. The programs included with the Ubuntu system are free software;
  13. the exact distribution terms for each program are described in the
  14. individual files in /usr/share/doc/*/copyright.

  15. Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
  16. applicable law.

  17. Changing password for root.
  18. (current) UNIX password:
  19. Enter new UNIX password:
  20. Retype new UNIX password:
复制代码
  Digital Ocean offers a wide variety of helpful guides. I created a new user for my primary non-root account and deployment accounts using this explainer .  
  I also edited the SSH configuration to eliminate the root login and customize the default SSH port away from 22.
   Then, I installed the typical UAMP server (Ubuntu, Apache, PHP and MySQL) on the server. It is possible that I just created a new child acronym of LAMP.
  1. $ sudo apt-get install mysql-server php5-mysql php5 php5-memcached memcached php5-mcrypt
  2. Reading package lists... Done
  3. Building dependency tree      
  4. Reading state information... Done
  5. The following extra packages will be installed:
  6.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  7.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  8.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  9.   libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
  10.   mysql-server-5.5 mysql-server-core-5.5 php-pear php5-cli php5-common
  11.   php5-json php5-readline ssl-cert
  12. Suggested packages:
  13.   apache2-doc apache2-suexec-pristine apache2-suexec-custom apache2-utils
  14.   libclone-perl libmldbm-perl libnet-daemon-perl libplrpc-perl
  15.   libsql-statement-perl libipc-sharedcache-perl libcache-memcached-perl
  16.   libmemcached tinyca mailx php5-dev php5-user-cache openssl-blacklist
  17. The following NEW packages will be installed:
  18.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  19.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  20.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  21.   libterm-readkey-perl memcached mysql-client-5.5 mysql-client-core-5.5
  22.   mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php-pear
  23.   php5 php5-cli php5-common php5-json php5-memcached php5-mysql php5-readline
  24.   ssl-cert
  25. 0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded.
  26. Need to get 15.7 MB of archives.
  27. After this operation, 126 MB of additional disk space will be used.
  28. Do you want to continue? [Y/n] y
  29. Get:1 http://mirrors.digitalocean.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6,364 B]
  30. Get:2 http://mirrors.digitalocean.com/ubuntu/ trusty/main libapr1 amd64 1.5.0-1 [85.1 kB]
  31. ...
  32. Enabling module mpm_prefork.
  33. apache2_switch_mpm Switch to prefork
  34. * Restarting web server apache2                                                                             [ OK ]
  35. apache2_invoke: Enable module php5
  36. * Restarting web server apache2                                                                             [ OK ]
  37. Setting up php5 (5.5.9+dfsg-1ubuntu4.16) ...
  38. Processing triggers for libc-bin (2.19-0ubuntu6.7) ...
复制代码
  Then, I configured my default timezone. Meeting Planner runs internally on Pacific Standard Time (PST). I edited php.ini :
  1. sudo nano /etc/php5/apache2/php.ini
复制代码
And, I added this:
  1. date.timezone = 'America/Los_Angeles'
复制代码
  Now it's time to get our codebase on the server.  
  Migrating the Code Base and Assets

  Installing Git

   First, I installed git :
  1. sudo apt-get install git
复制代码
Then, as my code deployment user, I created a new SSH key to establish a secure connection with GitHub:
  1. ssh-keygen -t rsa -C "[email protected]"
  2. Generating public/private rsa key pair.
  3. Enter file in which to save the key (/home/deploy/.ssh/id_rsa):
  4. Created directory '/home/deploy/.ssh'.
  5. Enter passphrase (empty for no passphrase):
  6. Enter same passphrase again:
  7. Your identification has been saved in /home/deploy/.ssh/id_rsa.
  8. Your public key has been saved in /home/deploy/.ssh/id_rsa.pub.
  9. The key fingerprint is:
  10. f7:84:37:b3:e4:7b:d3:9c:0c:60:b4:b7:4c:86:53:cb [email protected]
  11. The key's randomart image is:
  12. +--[ RSA 2048]----+
  13. |                 |
  14. |           . .   |
  15. |          . = .  |
  16. |           Z A   |
  17. |        + & dd.  |
  18. |         . * X   |
  19. |            +ooo.|
  20. |             .ooo|
  21. |            .. . |
  22. +-----------------+
  23. [email protected]:/var/www$ eval `ssh-agent -s`
  24. Agent pid 7827
  25. [email protected]:/var/www$ ssh-add ~/.ssh/id_rsa
  26. Identity added: /home/deploy/.ssh/id_rsa (/home/deploy/.ssh/id_rsa)
  27. [email protected]:/var/www$ cat < ~/.ssh/id_rsa.pub
  28. ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDM8JCAg7aPbB7The4Lmk42BpwPv9Eoc/k7As+N7nh5/JUVKK47AjxqvqeHvtntl8vbsaucNmuIM71OzH+36rbypqskfm2bbUk/bJk2qoqZK9V8Qc931Tj5i4IU9t90UOi55vwdZN0/xeEoJtzrerZn9l7xmJX2Ubarb4yKQSlSgiPHYQWYqD7QEGDtE4iUaqwwDWts/u1eajU/I+SubAyxbnT8WwwaqqA2Pm/N7PakKXgQdSquAdjh3mkvYxtL1kyTm/kFRi5tE/K3PIYfh0aLWhNiXEYnh6fQ2iXYRqT40F1IWEHF0Lv1ig5nTgFEUz2xaqzS18JDXw0lpwvZa3Sp [email protected]
  29. [email protected]:/var/www$ ssh -T [email protected]
  30. The authenticity of host 'github.com (192.30.252.122)' can't be established.
  31. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
  32. Are you sure you want to continue connecting (yes/no)? yes
  33. Warning: Permanently added 'github.com,192.30.252.122' (RSA) to the list of known hosts.
  34. Hi newscloud! You've successfully authenticated, but GitHub does not provide shell access.
复制代码
You also have to paste the key into your Git account settings.
  Installing Composer

  Next, I installed Composer:
  1. $ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
  2. composer
复制代码
  I absolutely love composer because it saves so much time, but there are days when I get annoyed with it, when it stops working out of nowhere—such as how the Yii Framework requires you install the fxp/composer-asset-plugin for proper use:
  1. $ composer global require "fxp/composer-asset-plugin:^1.0"
  2. $ composer update
复制代码
Installing the Meeting Planner Code

   Admittedly, I used GitHub to sync the latest code until I remembered that actually Yii2 configures a lot of files that GitHub ignores, including index.php. There are also local key files and uploaded user profile images. So, I used tar to compress the active codebase:
  1. tar czf mp_may2016.tar.gz mp
复制代码
Then, I used SCP to move the files to the new server, and then I extracted it:
  1. scp -i ~/.ssh/id_lookahead -P 3327 ~/mpmigrate/mp_may2016.tar.gz [email protected]:~
  2. tar -xzf mp_may2016.tar.gz
复制代码
Ultimately, there was also some work in reviewing the local database keys (which I updated on the new server) and reviewing my file permissions.
  Now, let's move the database.
  Moving the MySQL Database

  First, I dumped the existing database to a file:
  1. $ sudo apt-get install mysql-server php5-mysql php5 php5-memcached memcached php5-mcrypt
  2. Reading package lists... Done
  3. Building dependency tree      
  4. Reading state information... Done
  5. The following extra packages will be installed:
  6.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  7.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  8.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  9.   libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
  10.   mysql-server-5.5 mysql-server-core-5.5 php-pear php5-cli php5-common
  11.   php5-json php5-readline ssl-cert
  12. Suggested packages:
  13.   apache2-doc apache2-suexec-pristine apache2-suexec-custom apache2-utils
  14.   libclone-perl libmldbm-perl libnet-daemon-perl libplrpc-perl
  15.   libsql-statement-perl libipc-sharedcache-perl libcache-memcached-perl
  16.   libmemcached tinyca mailx php5-dev php5-user-cache openssl-blacklist
  17. The following NEW packages will be installed:
  18.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  19.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  20.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  21.   libterm-readkey-perl memcached mysql-client-5.5 mysql-client-core-5.5
  22.   mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php-pear
  23.   php5 php5-cli php5-common php5-json php5-memcached php5-mysql php5-readline
  24.   ssl-cert
  25. 0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded.
  26. Need to get 15.7 MB of archives.
  27. After this operation, 126 MB of additional disk space will be used.
  28. Do you want to continue? [Y/n] y
  29. Get:1 http://mirrors.digitalocean.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6,364 B]
  30. Get:2 http://mirrors.digitalocean.com/ubuntu/ trusty/main libapr1 amd64 1.5.0-1 [85.1 kB]
  31. ...
  32. Enabling module mpm_prefork.
  33. apache2_switch_mpm Switch to prefork
  34. * Restarting web server apache2                                                                             [ OK ]
  35. apache2_invoke: Enable module php5
  36. * Restarting web server apache2                                                                             [ OK ]
  37. Setting up php5 (5.5.9+dfsg-1ubuntu4.16) ...
  38. Processing triggers for libc-bin (2.19-0ubuntu6.7) ...0
复制代码
Then, I moved it to the new server with scp:
  1. $ sudo apt-get install mysql-server php5-mysql php5 php5-memcached memcached php5-mcrypt
  2. Reading package lists... Done
  3. Building dependency tree      
  4. Reading state information... Done
  5. The following extra packages will be installed:
  6.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  7.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  8.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  9.   libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
  10.   mysql-server-5.5 mysql-server-core-5.5 php-pear php5-cli php5-common
  11.   php5-json php5-readline ssl-cert
  12. Suggested packages:
  13.   apache2-doc apache2-suexec-pristine apache2-suexec-custom apache2-utils
  14.   libclone-perl libmldbm-perl libnet-daemon-perl libplrpc-perl
  15.   libsql-statement-perl libipc-sharedcache-perl libcache-memcached-perl
  16.   libmemcached tinyca mailx php5-dev php5-user-cache openssl-blacklist
  17. The following NEW packages will be installed:
  18.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  19.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  20.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  21.   libterm-readkey-perl memcached mysql-client-5.5 mysql-client-core-5.5
  22.   mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php-pear
  23.   php5 php5-cli php5-common php5-json php5-memcached php5-mysql php5-readline
  24.   ssl-cert
  25. 0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded.
  26. Need to get 15.7 MB of archives.
  27. After this operation, 126 MB of additional disk space will be used.
  28. Do you want to continue? [Y/n] y
  29. Get:1 http://mirrors.digitalocean.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6,364 B]
  30. Get:2 http://mirrors.digitalocean.com/ubuntu/ trusty/main libapr1 amd64 1.5.0-1 [85.1 kB]
  31. ...
  32. Enabling module mpm_prefork.
  33. apache2_switch_mpm Switch to prefork
  34. * Restarting web server apache2                                                                             [ OK ]
  35. apache2_invoke: Enable module php5
  36. * Restarting web server apache2                                                                             [ OK ]
  37. Setting up php5 (5.5.9+dfsg-1ubuntu4.16) ...
  38. Processing triggers for libc-bin (2.19-0ubuntu6.7) ...1
复制代码
On the new server, I created a new database with new details and configured some permissions for Apache:
  1. $ sudo apt-get install mysql-server php5-mysql php5 php5-memcached memcached php5-mcrypt
  2. Reading package lists... Done
  3. Building dependency tree      
  4. Reading state information... Done
  5. The following extra packages will be installed:
  6.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  7.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  8.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  9.   libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
  10.   mysql-server-5.5 mysql-server-core-5.5 php-pear php5-cli php5-common
  11.   php5-json php5-readline ssl-cert
  12. Suggested packages:
  13.   apache2-doc apache2-suexec-pristine apache2-suexec-custom apache2-utils
  14.   libclone-perl libmldbm-perl libnet-daemon-perl libplrpc-perl
  15.   libsql-statement-perl libipc-sharedcache-perl libcache-memcached-perl
  16.   libmemcached tinyca mailx php5-dev php5-user-cache openssl-blacklist
  17. The following NEW packages will be installed:
  18.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  19.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  20.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  21.   libterm-readkey-perl memcached mysql-client-5.5 mysql-client-core-5.5
  22.   mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php-pear
  23.   php5 php5-cli php5-common php5-json php5-memcached php5-mysql php5-readline
  24.   ssl-cert
  25. 0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded.
  26. Need to get 15.7 MB of archives.
  27. After this operation, 126 MB of additional disk space will be used.
  28. Do you want to continue? [Y/n] y
  29. Get:1 http://mirrors.digitalocean.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6,364 B]
  30. Get:2 http://mirrors.digitalocean.com/ubuntu/ trusty/main libapr1 amd64 1.5.0-1 [85.1 kB]
  31. ...
  32. Enabling module mpm_prefork.
  33. apache2_switch_mpm Switch to prefork
  34. * Restarting web server apache2                                                                             [ OK ]
  35. apache2_invoke: Enable module php5
  36. * Restarting web server apache2                                                                             [ OK ]
  37. Setting up php5 (5.5.9+dfsg-1ubuntu4.16) ...
  38. Processing triggers for libc-bin (2.19-0ubuntu6.7) ...2
复制代码
Finally, I imported the sql file into the new database:
  1. $ sudo apt-get install mysql-server php5-mysql php5 php5-memcached memcached php5-mcrypt
  2. Reading package lists... Done
  3. Building dependency tree      
  4. Reading state information... Done
  5. The following extra packages will be installed:
  6.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  7.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  8.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  9.   libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
  10.   mysql-server-5.5 mysql-server-core-5.5 php-pear php5-cli php5-common
  11.   php5-json php5-readline ssl-cert
  12. Suggested packages:
  13.   apache2-doc apache2-suexec-pristine apache2-suexec-custom apache2-utils
  14.   libclone-perl libmldbm-perl libnet-daemon-perl libplrpc-perl
  15.   libsql-statement-perl libipc-sharedcache-perl libcache-memcached-perl
  16.   libmemcached tinyca mailx php5-dev php5-user-cache openssl-blacklist
  17. The following NEW packages will be installed:
  18.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  19.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  20.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  21.   libterm-readkey-perl memcached mysql-client-5.5 mysql-client-core-5.5
  22.   mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php-pear
  23.   php5 php5-cli php5-common php5-json php5-memcached php5-mysql php5-readline
  24.   ssl-cert
  25. 0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded.
  26. Need to get 15.7 MB of archives.
  27. After this operation, 126 MB of additional disk space will be used.
  28. Do you want to continue? [Y/n] y
  29. Get:1 http://mirrors.digitalocean.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6,364 B]
  30. Get:2 http://mirrors.digitalocean.com/ubuntu/ trusty/main libapr1 amd64 1.5.0-1 [85.1 kB]
  31. ...
  32. Enabling module mpm_prefork.
  33. apache2_switch_mpm Switch to prefork
  34. * Restarting web server apache2                                                                             [ OK ]
  35. apache2_invoke: Enable module php5
  36. * Restarting web server apache2                                                                             [ OK ]
  37. Setting up php5 (5.5.9+dfsg-1ubuntu4.16) ...
  38. Processing triggers for libc-bin (2.19-0ubuntu6.7) ...3
复制代码
Then it was time to configure Apache.
  Configuring the Web Server

  I created a .conf file on the new server:
  1. $ sudo apt-get install mysql-server php5-mysql php5 php5-memcached memcached php5-mcrypt
  2. Reading package lists... Done
  3. Building dependency tree      
  4. Reading state information... Done
  5. The following extra packages will be installed:
  6.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  7.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  8.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  9.   libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
  10.   mysql-server-5.5 mysql-server-core-5.5 php-pear php5-cli php5-common
  11.   php5-json php5-readline ssl-cert
  12. Suggested packages:
  13.   apache2-doc apache2-suexec-pristine apache2-suexec-custom apache2-utils
  14.   libclone-perl libmldbm-perl libnet-daemon-perl libplrpc-perl
  15.   libsql-statement-perl libipc-sharedcache-perl libcache-memcached-perl
  16.   libmemcached tinyca mailx php5-dev php5-user-cache openssl-blacklist
  17. The following NEW packages will be installed:
  18.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  19.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  20.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  21.   libterm-readkey-perl memcached mysql-client-5.5 mysql-client-core-5.5
  22.   mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php-pear
  23.   php5 php5-cli php5-common php5-json php5-memcached php5-mysql php5-readline
  24.   ssl-cert
  25. 0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded.
  26. Need to get 15.7 MB of archives.
  27. After this operation, 126 MB of additional disk space will be used.
  28. Do you want to continue? [Y/n] y
  29. Get:1 http://mirrors.digitalocean.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6,364 B]
  30. Get:2 http://mirrors.digitalocean.com/ubuntu/ trusty/main libapr1 amd64 1.5.0-1 [85.1 kB]
  31. ...
  32. Enabling module mpm_prefork.
  33. apache2_switch_mpm Switch to prefork
  34. * Restarting web server apache2                                                                             [ OK ]
  35. apache2_invoke: Enable module php5
  36. * Restarting web server apache2                                                                             [ OK ]
  37. Setting up php5 (5.5.9+dfsg-1ubuntu4.16) ...
  38. Processing triggers for libc-bin (2.19-0ubuntu6.7) ...4
复制代码
I was able to derive much of it from the existing .conf file:
  1. $ sudo apt-get install mysql-server php5-mysql php5 php5-memcached memcached php5-mcrypt
  2. Reading package lists... Done
  3. Building dependency tree      
  4. Reading state information... Done
  5. The following extra packages will be installed:
  6.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  7.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  8.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  9.   libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
  10.   mysql-server-5.5 mysql-server-core-5.5 php-pear php5-cli php5-common
  11.   php5-json php5-readline ssl-cert
  12. Suggested packages:
  13.   apache2-doc apache2-suexec-pristine apache2-suexec-custom apache2-utils
  14.   libclone-perl libmldbm-perl libnet-daemon-perl libplrpc-perl
  15.   libsql-statement-perl libipc-sharedcache-perl libcache-memcached-perl
  16.   libmemcached tinyca mailx php5-dev php5-user-cache openssl-blacklist
  17. The following NEW packages will be installed:
  18.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  19.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  20.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  21.   libterm-readkey-perl memcached mysql-client-5.5 mysql-client-core-5.5
  22.   mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php-pear
  23.   php5 php5-cli php5-common php5-json php5-memcached php5-mysql php5-readline
  24.   ssl-cert
  25. 0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded.
  26. Need to get 15.7 MB of archives.
  27. After this operation, 126 MB of additional disk space will be used.
  28. Do you want to continue? [Y/n] y
  29. Get:1 http://mirrors.digitalocean.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6,364 B]
  30. Get:2 http://mirrors.digitalocean.com/ubuntu/ trusty/main libapr1 amd64 1.5.0-1 [85.1 kB]
  31. ...
  32. Enabling module mpm_prefork.
  33. apache2_switch_mpm Switch to prefork
  34. * Restarting web server apache2                                                                             [ OK ]
  35. apache2_invoke: Enable module php5
  36. * Restarting web server apache2                                                                             [ OK ]
  37. Setting up php5 (5.5.9+dfsg-1ubuntu4.16) ...
  38. Processing triggers for libc-bin (2.19-0ubuntu6.7) ...5
复制代码
Then, I activated the site and reloaded Apache:
  1. $ sudo apt-get install mysql-server php5-mysql php5 php5-memcached memcached php5-mcrypt
  2. Reading package lists... Done
  3. Building dependency tree      
  4. Reading state information... Done
  5. The following extra packages will be installed:
  6.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  7.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  8.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  9.   libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
  10.   mysql-server-5.5 mysql-server-core-5.5 php-pear php5-cli php5-common
  11.   php5-json php5-readline ssl-cert
  12. Suggested packages:
  13.   apache2-doc apache2-suexec-pristine apache2-suexec-custom apache2-utils
  14.   libclone-perl libmldbm-perl libnet-daemon-perl libplrpc-perl
  15.   libsql-statement-perl libipc-sharedcache-perl libcache-memcached-perl
  16.   libmemcached tinyca mailx php5-dev php5-user-cache openssl-blacklist
  17. The following NEW packages will be installed:
  18.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  19.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  20.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  21.   libterm-readkey-perl memcached mysql-client-5.5 mysql-client-core-5.5
  22.   mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php-pear
  23.   php5 php5-cli php5-common php5-json php5-memcached php5-mysql php5-readline
  24.   ssl-cert
  25. 0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded.
  26. Need to get 15.7 MB of archives.
  27. After this operation, 126 MB of additional disk space will be used.
  28. Do you want to continue? [Y/n] y
  29. Get:1 http://mirrors.digitalocean.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6,364 B]
  30. Get:2 http://mirrors.digitalocean.com/ubuntu/ trusty/main libapr1 amd64 1.5.0-1 [85.1 kB]
  31. ...
  32. Enabling module mpm_prefork.
  33. apache2_switch_mpm Switch to prefork
  34. * Restarting web server apache2                                                                             [ OK ]
  35. apache2_invoke: Enable module php5
  36. * Restarting web server apache2                                                                             [ OK ]
  37. Setting up php5 (5.5.9+dfsg-1ubuntu4.16) ...
  38. Processing triggers for libc-bin (2.19-0ubuntu6.7) ...6
复制代码
As I mentioned earlier, I had to make sure that the local files with keys and environment paths were correct on the new server.
  While there were definitely bumps, ultimately, everything came together.
  Migrating the DNS

  Finally, I re-mapped the DNS for the core Meeting Planner URL. Soon after, the new server was live:
     

Building Your Startup With PHP: Choosing and Configuring Production Hosting

Building Your Startup With PHP: Choosing and Configuring Production Hosting-7-技术控-interested,especially,launching,business,choosing
     You may notice that I used myrecent tutorialabout the amazingly awesome Let's Encrypt : I installed  https for Meeting Planner before taking the above screenshot.
  Updating cron Tasks

  Meeting Planner and Let's Encrypt rely on cron for running key processes in the background. So, I moved my crontab settings over from the old server:
  1. $ sudo apt-get install mysql-server php5-mysql php5 php5-memcached memcached php5-mcrypt
  2. Reading package lists... Done
  3. Building dependency tree      
  4. Reading state information... Done
  5. The following extra packages will be installed:
  6.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  7.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  8.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  9.   libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
  10.   mysql-server-5.5 mysql-server-core-5.5 php-pear php5-cli php5-common
  11.   php5-json php5-readline ssl-cert
  12. Suggested packages:
  13.   apache2-doc apache2-suexec-pristine apache2-suexec-custom apache2-utils
  14.   libclone-perl libmldbm-perl libnet-daemon-perl libplrpc-perl
  15.   libsql-statement-perl libipc-sharedcache-perl libcache-memcached-perl
  16.   libmemcached tinyca mailx php5-dev php5-user-cache openssl-blacklist
  17. The following NEW packages will be installed:
  18.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  19.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  20.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  21.   libterm-readkey-perl memcached mysql-client-5.5 mysql-client-core-5.5
  22.   mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php-pear
  23.   php5 php5-cli php5-common php5-json php5-memcached php5-mysql php5-readline
  24.   ssl-cert
  25. 0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded.
  26. Need to get 15.7 MB of archives.
  27. After this operation, 126 MB of additional disk space will be used.
  28. Do you want to continue? [Y/n] y
  29. Get:1 http://mirrors.digitalocean.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6,364 B]
  30. Get:2 http://mirrors.digitalocean.com/ubuntu/ trusty/main libapr1 amd64 1.5.0-1 [85.1 kB]
  31. ...
  32. Enabling module mpm_prefork.
  33. apache2_switch_mpm Switch to prefork
  34. * Restarting web server apache2                                                                             [ OK ]
  35. apache2_invoke: Enable module php5
  36. * Restarting web server apache2                                                                             [ OK ]
  37. Setting up php5 (5.5.9+dfsg-1ubuntu4.16) ...
  38. Processing triggers for libc-bin (2.19-0ubuntu6.7) ...7
复制代码
  1. $ sudo apt-get install mysql-server php5-mysql php5 php5-memcached memcached php5-mcrypt
  2. Reading package lists... Done
  3. Building dependency tree      
  4. Reading state information... Done
  5. The following extra packages will be installed:
  6.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  7.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  8.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  9.   libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
  10.   mysql-server-5.5 mysql-server-core-5.5 php-pear php5-cli php5-common
  11.   php5-json php5-readline ssl-cert
  12. Suggested packages:
  13.   apache2-doc apache2-suexec-pristine apache2-suexec-custom apache2-utils
  14.   libclone-perl libmldbm-perl libnet-daemon-perl libplrpc-perl
  15.   libsql-statement-perl libipc-sharedcache-perl libcache-memcached-perl
  16.   libmemcached tinyca mailx php5-dev php5-user-cache openssl-blacklist
  17. The following NEW packages will be installed:
  18.   apache2 apache2-bin apache2-data libaio1 libapache2-mod-php5 libapr1
  19.   libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl
  20.   libdbi-perl libhtml-template-perl libmemcached10 libmysqlclient18
  21.   libterm-readkey-perl memcached mysql-client-5.5 mysql-client-core-5.5
  22.   mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php-pear
  23.   php5 php5-cli php5-common php5-json php5-memcached php5-mysql php5-readline
  24.   ssl-cert
  25. 0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded.
  26. Need to get 15.7 MB of archives.
  27. After this operation, 126 MB of additional disk space will be used.
  28. Do you want to continue? [Y/n] y
  29. Get:1 http://mirrors.digitalocean.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6,364 B]
  30. Get:2 http://mirrors.digitalocean.com/ubuntu/ trusty/main libapr1 amd64 1.5.0-1 [85.1 kB]
  31. ...
  32. Enabling module mpm_prefork.
  33. apache2_switch_mpm Switch to prefork
  34. * Restarting web server apache2                                                                             [ OK ]
  35. apache2_invoke: Enable module php5
  36. * Restarting web server apache2                                                                             [ OK ]
  37. Setting up php5 (5.5.9+dfsg-1ubuntu4.16) ...
  38. Processing triggers for libc-bin (2.19-0ubuntu6.7) ...8
复制代码
  Read this if you're wondering why I refer to cron in all lowercase .
  What's Next?

   Meeting Planner's made tremendous progress the past few months. I've scheduled business meetings, and a couple of personal dates chose to schedule second dates with me using the app. Yet there are still a lot of shortcomings—and feedback from early users is vital. So, in the next tutorial, I'm going to be setting up a system for collecting feedback from users, helping them get answers to common questions and learning as much as I can to make the service better before declaring MVP and an alpha launch.
   I hope you've enjoyed this episode. Watch for upcoming tutorials in our Building Your Startup With PHP series —there's also lots of polish work and a few more big features coming up.
   Please feel free to add your questions and comments below; I generally participate in the discussions. You can also reach me on Twitter @reifman directly.



上一篇:Find the minimum value of m that satisfies ax + by = m and all values after m al
下一篇:在 Laravel 5 中使用 Laravel Excel 实现 Excel/CSV 文件导入导出功能
刘旻芯 投递于 2016-10-3 21:26:58
支持一下!
回复 支持 反对

使用道具 举报

我要投稿

推荐阅读


回页顶回复上一篇下一篇回列表
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 | 粤公网安备 44010402000842号 )

© 2001-2017 Comsenz Inc.

返回顶部 返回列表