Ubuntu 下 nginx , php , mysql 和 golang 的简单安装
我是搞php出身,自然安装lnmp是常规技能。以前的手段还是lnmp安装包,比如军哥的lnmp1.0。随着php和mysql的更新,大多数一键安装都开始版本老化,更新困难的问题。因此,重新研究了一下Ubuntu下lnmp的安装,发现现在简单的多,记录一下。 另外最近在学习gola
我是搞php出身,自然安装lnmp是常规技能。以前的手段还是lnmp安装包,比如军哥的lnmp1.0。随着php和mysql的更新,大多数一键安装都开始版本老化,更新困难的问题。因此,重新研究了一下Ubuntu下lnmp的安装,发现现在简单的多,记录一下。
另外最近在学习golang,Ubuntu下安装自然也是必须的过程。不过golang的安装也有一些奥妙。当然,不是源码安装的啦。
Nginx Stable/Development
Ubuntu下的包管理器是apt-get
或者说dpkg
。常规的安装命令apt-get install
(注意权限sudo apt-get install
)。Nginx是这几个软件里最友好的,直接可以添加stable源:
<code>add-apt-repository ppa:nginx/stable </code>
或者development源:
<code>add-apt-repository ppa:nginx/development </code>
如果没有安装命令add-apt-repository
,安装:
<code>apt-get install python-software-properties </code>
之后常规的操作:
<code>apt-get update apt-get install nginx service nginx start </code>
PHP 5.4+
PHP的ppa源有个老兄专门在做,Ondrej Sury。有php5.4,php5.5和php5.6的源,具体的可以看官方页面。
为什么没有5.3?你落伍啦!5.4+性能提高很多,5.5还有内置的ZendOpCache
。安装php5.5:
<code>add-apt-repository ppa:ondrej/php5 apt-get update apt-get install php5 php5-fpm service php5-fpm start </code>
还有些必要的包,安装一下,记得重启php5-fpm:
<code>apt-get install php5-gd php5-curl php5-sqlite php5-mysqlnd php5-mcrypt service php5-fpm restart </code>
至于nginx怎么配置php-fpm,一搜一大把,不多说。
MySQL 5.5+ & MariaDB
还是这个老兄,维护着mysql5.5, mysql5.6 和 MariaDB5.5。所以,很简单,比如安装MariaDB(不喜欢mysql,被oracle摧残了):
<code>add-apt-repository ppa:ondrej/mariadb-5.5 apt-get update apt-get install mariadb-server-5.5 service mysql start </code>
这里注意,安装会提示InnoDB Plugin Disabled
。不要紧,MariaDB把InnoDB内置进去了,其实是已经启动的。具体的可以:
<code>mysql SHOW ENGINE INNODB STATUS; </code>
Golang
重头戏是golang啦。我搜寻了半天ppa源,只找到一个可以安装golang1.1.1的源,很不爽。其实可以golang官方下载已经编译好的linux.tar.gz。但是需要自己手动设置GOROOT
,有点麻烦啊。
终于还是发现了个好工具Godeb。实际上这就是一个deb包构建器。先把官方编译好的tar.gz下载,打包成deb然后执行安装。
以64位安装为例:
<code>wget https://godeb.s3.amazonaws.com/godeb-amd64.tar.gz tar -zxvf godeb-amd64.tar.gz ./godeb install </code>
就开始安装最新版本。还可查看支持的版本,并安装特定版本:
<code>./godeb list 1.2 1.2rc5 1.2rc4 1.2rc3 1.2rc2 1.2rc1 1.1.2 1.1.1 1.1 (...) ./godeb install 1.1 </code>
安装好后,可以用go env
查看,是否安装完成。
剩下的设置GOPATH
,GOBIN
就不赘述了。我是修改在/etc/profile
里面的。
写在最后
Ubuntu下很多东西都有源,容易安装,也是好事啊。
原文地址:Ubuntu 下 nginx , php , mysql 和 golang 的简单安装, 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



There are many reasons why MySQL startup fails, and it can be diagnosed by checking the error log. Common causes include port conflicts (check port occupancy and modify configuration), permission issues (check service running user permissions), configuration file errors (check parameter settings), data directory corruption (restore data or rebuild table space), InnoDB table space issues (check ibdata1 files), plug-in loading failure (check error log). When solving problems, you should analyze them based on the error log, find the root cause of the problem, and develop the habit of backing up data regularly to prevent and solve problems.

MySQL uses shared locks and exclusive locks to manage concurrency, providing three lock types: table locks, row locks and page locks. Row locks can improve concurrency, and use the FOR UPDATE statement to add exclusive locks to rows. Pessimistic locks assume conflicts, and optimistic locks judge the data through the version number. Common lock table problems manifest as slow querying, use the SHOW PROCESSLIST command to view the queries held by the lock. Optimization measures include selecting appropriate indexes, reducing transaction scope, batch operations, and optimizing SQL statements.

In MySQL database operations, string processing is an inevitable link. The SUBSTRING_INDEX function is designed for this, which can efficiently extract substrings based on separators. SUBSTRING_INDEX function application example The following example shows the flexibility and practicality of the SUBSTRING_INDEX function: Extract specific parts from the URL For example, extract domain name: SELECTSUBSTRING_INDEX('www.mysql.com','.',2); Extract file extension to easily get file extension: SELECTSUBSTRING_INDEX('file.pdf','.',-1); Processing does not exist

MySQL can run without network connections for basic data storage and management. However, network connection is required for interaction with other systems, remote access, or using advanced features such as replication and clustering. Additionally, security measures (such as firewalls), performance optimization (choose the right network connection), and data backup are critical to connecting to the Internet.

MySQL and MariaDB can coexist, but need to be configured with caution. The key is to allocate different port numbers and data directories to each database, and adjust parameters such as memory allocation and cache size. Connection pooling, application configuration, and version differences also need to be considered and need to be carefully tested and planned to avoid pitfalls. Running two databases simultaneously can cause performance problems in situations where resources are limited.

The MySQL primary key cannot be empty because the primary key is a key attribute that uniquely identifies each row in the database. If the primary key can be empty, the record cannot be uniquely identifies, which will lead to data confusion. When using self-incremental integer columns or UUIDs as primary keys, you should consider factors such as efficiency and space occupancy and choose an appropriate solution.

For production environments, a server is usually required to run MySQL, for reasons including performance, reliability, security, and scalability. Servers usually have more powerful hardware, redundant configurations and stricter security measures. For small, low-load applications, MySQL can be run on local machines, but resource consumption, security risks and maintenance costs need to be carefully considered. For greater reliability and security, MySQL should be deployed on cloud or other servers. Choosing the appropriate server configuration requires evaluation based on application load and data volume.

MySQL can return JSON data. The JSON_EXTRACT function extracts field values. For complex queries, you can consider using the WHERE clause to filter JSON data, but pay attention to its performance impact. MySQL's support for JSON is constantly increasing, and it is recommended to pay attention to the latest version and features.
