淘先锋技术网

首页 1 2 3 4 5 6 7

ubuntu迁移到

Recently we've been presenting articles about development environments for Linux, Windows, Mac and the Cloud. In this article, Shaumik looks at moving from one to another.

最近,我们一直在介绍有关LinuxWindowsMacCloud开发环境的文章。 在这篇文章中,Shaumik着眼于从一种过渡到另一种。

Last year, I got myself a Macbook Air for two reasons: a powerful terminal and popular graphics software. I thought the transition would be smooth; but only when I started the process did I realize the complexity of the task.

去年,我买Macbook Air的原因有两个:强大的终端和流行的图形软件。 我认为过渡会很顺利; 但是只有当我开始该过程时,我才意识到任务的复杂性。

SitePoint recently published articles on setting up a development machine on Ubuntu and setting up a development machine on a Mac. In this post, I'll look at the subtle differences you might face when shifting your development environment from Ubuntu to OS X, or vice versa.

SitePoint最近发表了有关在Ubuntu设置开发计算机在Mac上设置开发计算机的文章 。 在本文中,我将探讨在将开发环境从Ubuntu迁移到OS X时可能遇到的细微差异,反之亦然。

安装软件的一般步骤 (General Procedure for Installing Software)

Let's first talk about what you can expect on OS X if you're used to Ubuntu.

首先,让我们讨论一下如果您习惯使用Ubuntu,在OS X上可以期待什么。

OS X, owing to its high market share, has a large developer base. Therefore, almost all pieces of software have an OS X installer. How you install them is interesting. An installer usually walks you through the installation (much like an installation wizard on Windows). Some packages might be available in the form of .dmg files, which are none other than compressed files. You need to move the extracted application to the Applications directory. Removing such packages just requires removal from the Applications directory. Here's a guide on installing downloaded software on a Mac.

OS X由于其较高的市场份额而拥有庞大的开发人员基础。 因此,几乎所有软件都具有OS X安装程序。 如何安装它们很有趣。 安装程序通常会引导您完成安装过程(非常类似于Windows上的安装向导)。 有些软件包可能以.dmg文件的形式提供,这些文件不过是压缩文件。 您需要将提取的应用程序移动到Applications目录。 删除此类软件包仅需要从“ Applications目录中删除。 这是在Mac安装下载的软件的指南。

Alternatively, the installation of applications might also be done through the App Store. However, not all applications are available there. Those that aren't — such as browsers like Chrome and Firefox, and text editors like Sublime Text — are easily downloaded from their respective websites and installed as described above.

另外,应用程序的安装也可以通过App Store完成。 但是,并非所有应用程序都在那里可用。 那些不是这样的浏览器,例如Chrome和Firefox等浏览器,以及Sublime Text这样的文本编辑器,可以轻松地从各自的网站下载并按上述方式安装。

终点站 (The Terminal)

Terminal on a Mac

Terminal on a Mac

Mac上的终端

In the terminal, most commands are similar (except those that are specifically package related). For instance, running the grep command to search for a phrase is exactly the same.

在终端中,大多数命令都是相似的(除了那些与软件包相关的命令之外)。 例如,运行grep命令搜索短语是完全相同的。

However, if you're interested in developing scripts that run across platforms (including old Mac versions), you may find this guide by Apple developers interesting.

但是,如果您对开发跨平台(包括旧Mac版本)运行的脚本感兴趣,则Apple开发人员可能会发现本指南很有趣。

Further, for the list of subtle differences in commands, visit A Sysadmin's Unixersal Translator, by Rosetta Stone, and select OS X and Linux from the list of operating systems on the top left corner. From the list, you can see that the usage of most commonly used commands is the same.

此外,有关命令细微差别的列表,请访问Rosetta Stone的A Sysadmin的Unixersal Translator ,然后从左上角的操作系统列表中选择OS X和Linux。 从列表中,您可以看到大多数常用命令的用法是相同的。

Homebrew:Mac的软件包管理器 (Homebrew: the Package Manager for Mac)

Ubuntu has apt-get as a package manager, whereas Fedora has yum.

Ubuntu具有apt-get作为软件包管理器,而Fedora具有yum

Unfortunately, there's no default package manager for Mac that magically installs every new piece of software you might wish to have. Although there are many alternatives like MacPorts and Fink, the best package manager for Mac is probably Homebrew. In case you're interested, here's a comparison between the three options.

不幸的是,没有用于Mac的默认软件包管理器可以神奇地安装您可能希望拥有的每个新软件。 尽管有许多其他选择,例如MacPorts和Fink,但Mac的最佳软件包管理器可能是Homebrew 。 如果您有兴趣,这里是这三个选项之间的比较

Installing Homebrew is easy: you just need to run a single command, as mentioned on their website:

安装Homebrew很容易:您只需运行一个命令即可,如其网站上所述:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

The installation script is in Ruby. Ruby comes pre-installed on a Mac. During installation on a fresh machine, you're prompted to install components of XCode Command Line Tools, which you need to approve. To verify that Homebrew has been installed, you can run brew info.

安装脚本在Ruby中。 Ruby已预装在Mac上。 在新计算机上安装期间,系统会提示您安装需要批准的XCode命令行工具组件。 要验证是否已安装Homebrew,您可以运行brew info

Installing packages through Homebrew is similar to other package managers. Homebrew installs packages for the local user, and therefore doesn't require any root privileges. We'll look at the process of installing packages on Homebrew later in this post. Meanwhile, make sure Homebrew is updated by running the following commands:

通过Homebrew安装软件包与其他软件包管理器类似。 Homebrew为本地用户安装软件包,因此不需要任何root特权。 我们将在本文后面的部分中介绍在Homebrew上安装软件包的过程。 同时,通过运行以下命令确保更新了Homebrew:

brew update
brew doctor
brew upgrade

版本控制 (Version Control)

Using SourceTree on a Mac

Using SourceTree on a Mac

在Mac上使用SourceTree

Almost all developers today — especially those working in teams — need to use version control to collaborate. The most popular version control tool is Git, although many prefer Mercurial or Subversion.

如今,几乎所有开发人员,尤其是团队中的开发人员,都需要使用版本控制进行协作。 最受欢迎的版本控制工具是Git ,尽管许多人更喜欢MercurialSubversion

Matthew explained his choices for version control in his post, such as GUI tools like SourceTree or GitX. These GUI tools come with their own version of Git. SourceTree supports both Git and Mercurial.

马修(Matthew)在文章中解释了他对版本控制的选择,例如GUI工具如SourceTreeGitX 。 这些GUI工具带有其自己的Git版本。 SourceTree同时支持Git和Mercurial。

If you prefer using version control through the command line, you need to install your version control system separately. Git has a package for Mac, but if you need the latest development version, you'll have to build from the source.

如果您更喜欢通过命令行使用版本控制,则需要单独安装版本控制系统。 Git有一个Mac软件包 ,但是如果您需要最新的开发版本,则必须从源代码进行构建

Note: if there's a separate version of Git/Mercurial present in your system when you install SourceTree, you'll be asked whether you want to use the version in your system or the version bundled with SourceTree.

注意:如果在安装SourceTree时系统中存在单独的Git / Mercurial版本,则会询问您是要使用系统中的版本还是与SourceTree捆绑在一起的版本。

让我们开始编码 (Let's Get Coding)

If you're one of those who can't wait to get started, this is the section that starts the coding. Thankfully, most of the important stuff comes pre-installed on the latest version of Mac OS X — El Capitan. In addition to Python, Ruby and PHP, El Capitan also has Apache 2.4 pre-installed! In OS X, the apachectl command runs Apache, as compared to apache on ubuntu.

如果您是迫不及待想要开始的人之一,那么这是开始编码的部分。 值得庆幸的是,大多数重要的东西都预装在最新版本的Mac OS X上— El Capitan 。 除了Python,Ruby和PHP, El Capitan还预先安装了Apache 2.4! 在OS X中,与ubuntu上的apache相比, apachectl命令运行Apache。

For those running OS X, Python, Node.js and Ruby have installers, or you can compile them by getting your desired version. PHP doesn't have an installer for OS X, though, but can be compiled from its source. All of them can also be installed through Homebrew. For instance, you can run the following command to install PHP 5.6:

对于运行OS X的用户, PythonNode.jsRuby都有安装程序,或者您可以通过获取所需的版本进行编译。 但是,PHP没有OS X的安装程序,但可以从其源代码进行编译 。 所有这些都可以通过Homebrew安装。 例如,您可以运行以下命令来安装PHP 5.6:

brew install php56

Similarly, run the following to install Python 3:

同样,运行以下命令安装Python 3:

brew install python3

You can use MAMP stack (Mac, Apache, MySQL, PHP) to get the bundle (similar to LAMP for Linux and WAMP for Windows). This lets you start development quickly, without worrying about individual installations. MAMP has a specific installer, which you can run every time you want to start the development environment. Working with MAMP is similar to using WAMP or LAMP.

您可以使用MAMP堆栈 ( M ac, A pache, M ySQL, P HP)来获取捆绑包(类似于Linux的LAMP和Windows的WAMP )。 这使您可以快速开始开发,而不必担心单个安装。 MAMP具有特定的安装程序,您可以在每次要启动开发环境时运行。 使用MAMP类似于使用WAMP或LAMP。

资料库 (Databases)

List of tables in a database in MySQL

List of tables in a database in MySQL

MySQL中数据库的表列表

Although using MAMP would eliminate the need to install a database, the database can't be used by an external application. Let's now see how to install MySQL on Mac OS X. The easiest way is to use Homebrew (yet again!):

尽管使用MAMP可以消除安装数据库的需要,但是外部应用程序无法使用该数据库。 现在让我们看一下如何在Mac OS X上安装MySQL。最简单的方法是使用Homebrew(再次!):

brew install mysql

MySQL comes with an installer for Mac. Installing it is a simple process, as explained on the MySQL website.

MySQL随附Mac的安装程序。 如MySQL网站所述 ,安装它是一个简单的过程。

Similarly, PostgreSQL can be installed on Mac OS X through an installer or through Homebrew.

同样, 可以通过安装程序或Homebrew 在Mac OS X上安装PostgreSQL

If you prefer a NoSQL database like MongoDB, Homebrew has a recipe for that, too:

如果您喜欢像MongoDB这样的NoSQL数据库,那么Homebrew也有相应的配方:

brew install mongodb

MongoDB doesn't have an installer for Mac. In the absence of a package manager, you would need to compile MongoDB from the source if you don't use a package manager.

MongoDB没有适用于Mac的安装程序。 在没有包管理器的情况下,如果不使用包管理器,则需要从源代码编译MongoDB

有用的应用 (Useful Applications)

Useful applications for developers

Over the last year, I've realized that a Mac boosts your productivity — if used the right way. There's a number of productivity apps for Mac that one must use.

在过去的一年中,我已经意识到,如果使用正确的方式,Mac可以提高您的生产率。 Mac必须使用许多生产力应用程序。

Caffeine is a useful app, which, when activated, prevents the screen saver, screen dimming, or the system going to sleep. It's just perfect for running scripts that might take a long time to execute.

咖啡因是一个有用的应用程序,当激活时,它可以防止屏幕保护程序,屏幕变暗或系统进入睡眠状态。 对于运行可能需要很长时间才能执行的脚本,它是完美的选择。

Google Drive and Dropbox are essential too, for keeping your local files synced with the cloud. Drive and Dropbox sync files in their special folders, but MacDropAny lets you drop any normal folder and covert into a Drive or Dropbox folder.

Google云端硬盘Dropbox对于保持本地文件与云同步也至关重要。 Drive和Dropbox同步文件位于其特殊文件夹中,但是MacDropAny允许您任何普通文件夹拖放到Drive或Dropbox文件夹中。

SuperDuper is a data loss prevention app that one must definitely try. Finally, Jumpcut is like an extended clipboard that remembers all the stuff that you copied.

SuperDuper是一款绝对必须尝试的数据丢失防护应用程序。 最后, Jumpcut就像一个扩展的剪贴板,可以记住您复制的所有内容。

最后的想法 (Final Thoughts)

In this post, I looked at the process of shifting your development environment from Ubuntu to Mac OS X. Although I've described the manual process, there are services like Vagrant and Docker that help you make portable development environments that make setting it up on a new system fast.

在这篇文章中,我研究了将开发环境从Ubuntu迁移到Mac OS X的过程。尽管我已经描述了手动过程,但是VagrantDocker之类的服务可以帮助您构建可移植的开发环境,并在其上进行设置。快速的新系统。

Do you agree with my development environment? Is there anything important that I missed out? Please speak up in the comments below.

您是否同意我的开发环境? 我错过了什么重要的事情吗? 请在下面的评论中说出来。

翻译自: https://www.sitepoint.com/shifting-your-development-environment-from-ubuntu-to-os-x/

ubuntu迁移到