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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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











In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

SQL is a standard language for managing relational databases, while MySQL is a database management system that uses SQL. SQL defines ways to interact with a database, including CRUD operations, while MySQL implements the SQL standard and provides additional features such as stored procedures and triggers.

NGINX and Apache each have their own advantages and disadvantages, and the choice should be based on specific needs. 1.NGINX is suitable for high concurrency scenarios because of its asynchronous non-blocking architecture. 2. Apache is suitable for low-concurrency scenarios that require complex configurations, because of its modular design.

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

MySQL and phpMyAdmin can be effectively managed through the following steps: 1. Create and delete database: Just click in phpMyAdmin to complete. 2. Manage tables: You can create tables, modify structures, and add indexes. 3. Data operation: Supports inserting, updating, deleting data and executing SQL queries. 4. Import and export data: Supports SQL, CSV, XML and other formats. 5. Optimization and monitoring: Use the OPTIMIZETABLE command to optimize tables and use query analyzers and monitoring tools to solve performance problems.

AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

To safely and thoroughly uninstall MySQL and clean all residual files, follow the following steps: 1. Stop MySQL service; 2. Uninstall MySQL packages; 3. Clean configuration files and data directories; 4. Verify that the uninstallation is thorough.
