|
LNMP 的通用含义是:Linux 系统下 Nginx + MySQL + PHP 这种网站服务器架构。
LNMP 另方面是基于 CentOS/Debian 编写的 Nginx、MySQL、PHP、phpMyAdmin、eAccelerator 一键安装包。可以在 VPS、独立主机上轻松的安装 LNMP 生产环境。
LNMP 中的 4 个软件均为免费开源软件。组合在一起,形成了一个免费、高效、扩展性强的网站服务系统。
1、Linux 是类 Unix 计算机操作系统的统称,是目前最流行的免费操作系统。代表版本有:debian、centos、ubuntu、fedora、gentoo 等。
2、Nginx 是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服务器。
3、Mysql 是一个小型关系型数据库管理系统。
4、PHP 是一种在服务器端执行的嵌入 HTML 文档的脚本语言。
安装 Ubuntu Server 14.04
这里不再多说,请关注 “德云社区” 相关主题
安装 Nginx 1.4.6
1、apt-get 命令直接安装 Nginx
2、在 FireFox 或 IE 浏览器中键入 http://localhost/ 或 http://127.0.0.1/ (或服务器 IP 地址);若出现 “Welcome to nginx!” 信息,说明安装成功:
Welcome to nginx!
If you see this page, the nginx web server is successfully installed andworking. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx. 3、配置 Nginx
- vi /etc/nginx/sites-available/default
复制代码 修改前的配置文件内容:
修改后的配置文件内容:
4、重载、测试 Nginx 配置文件
- root:# /usr/sbin/nginx -s reload (或 service nginx reload)
- root:# /usr/sbin/nginx -t
- nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
- nginx: configuration file /etc/nginx/nginx.conf test is successful
- root:#
复制代码 5、重启 Nginx
- root:# /etc/init.d/nginx restart (或 service nginx restart)
- * Restarting nginx nginx [ OK ]
- root:#
复制代码 安装 MySQL Server 5.5.40
1、apt-get 命令直接安装 MySQL- root:# apt-get install mysql-server
- 正在读取软件包列表... 完成
- 正在分析软件包的依赖关系树
- 正在读取状态信息... 完成
- 下列软件包是自动安装的并且现在不需要了:
- linux-headers-3.13.0-37 linux-headers-3.13.0-37-generic
- linux-headers-3.13.0-39 linux-headers-3.13.0-39-generic
- linux-image-3.13.0-37-generic linux-image-3.13.0-39-generic
- linux-image-extra-3.13.0-37-generic linux-image-extra-3.13.0-39-generic
- Use 'apt-get autoremove' to remove them.
- 将会安装下列额外的软件包:
- libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
- libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
- mysql-server-5.5 mysql-server-core-5.5
- 建议安装的软件包:
- libmldbm-perl libnet-daemon-perl libplrpc-perl libsql-statement-perl
- libipc-sharedcache-perl tinyca mailx
- 下列【新】软件包将被安装:
- libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
- libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
- mysql-server mysql-server-5.5 mysql-server-core-5.5
- 升级了 0 个软件包,新安装了 12 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。
- 需要下载 9,064 kB 的软件包。
- 解压缩后会消耗掉 96.6 MB 的额外空间。
- 您希望继续执行吗? [Y/n] Y
- 获取:1 http://cn.archive.ubuntu.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6,364 B]
- 获取:2 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-common all 5.5.40-0ubuntu0.14.04.1 [14.1 kB]
- 获取:3 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main libmysqlclient18 amd64 5.5.40-0ubuntu0.14.04.1 [598 kB]
- 获取:4 http://cn.archive.ubuntu.com/ubuntu/ trusty/main libdbi-perl amd64 1.630-1 [879 kB]
- 获取:5 http://cn.archive.ubuntu.com/ubuntu/ trusty/main libdbd-mysql-perl amd64 4.025-1 [99.3 kB]
- 获取:6 http://cn.archive.ubuntu.com/ubuntu/ trusty/main libterm-readkey-perl amd64 2.31-1 [27.4 kB]
- 获取:7 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-client-core-5.5 amd64 5.5.40-0ubuntu0.14.04.1 [703 kB]
- 获取:8 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-client-5.5 amd64 5.5.40-0ubuntu0.14.04.1 [1,466 kB]
- 获取:9 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server-core-5.5 amd64 5.5.40-0ubuntu0.14.04.1 [3,215 kB]
- 获取:10 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server-5.5 amd64 5.5.40-0ubuntu0.14.04.1 [1,978 kB]
- 获取:11 http://cn.archive.ubuntu.com/ubuntu/ trusty/main libhtml-template-perl all 2.95-1 [65.5 kB]
- 获取:12 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server all 5.5.40-0ubuntu0.14.04.1 [12.4 kB]
- 下载 9,064 kB,耗时 32秒 (279 kB/s)
- 正在预设定软件包 ...
- Selecting previously unselected package libaio1:amd64.
- (正在读取数据库 ... 系统当前共安装有 310580 个文件和目录。)
- Preparing to unpack .../libaio1_0.3.109-4_amd64.deb ...
- Unpacking libaio1:amd64 (0.3.109-4) ...
- Selecting previously unselected package mysql-common.
- Preparing to unpack .../mysql-common_5.5.40-0ubuntu0.14.04.1_all.deb ...
- Unpacking mysql-common (5.5.40-0ubuntu0.14.04.1) ...
- Selecting previously unselected package libmysqlclient18:amd64.
- Preparing to unpack .../libmysqlclient18_5.5.40-0ubuntu0.14.04.1_amd64.deb ...
- Unpacking libmysqlclient18:amd64 (5.5.40-0ubuntu0.14.04.1) ...
- Selecting previously unselected package libdbi-perl.
- Preparing to unpack .../libdbi-perl_1.630-1_amd64.deb ...
- Unpacking libdbi-perl (1.630-1) ...
- Selecting previously unselected package libdbd-mysql-perl.
- Preparing to unpack .../libdbd-mysql-perl_4.025-1_amd64.deb ...
- Unpacking libdbd-mysql-perl (4.025-1) ...
- Selecting previously unselected package libterm-readkey-perl.
- Preparing to unpack .../libterm-readkey-perl_2.31-1_amd64.deb ...
- Unpacking libterm-readkey-perl (2.31-1) ...
- Selecting previously unselected package mysql-client-core-5.5.
- Preparing to unpack .../mysql-client-core-5.5_5.5.40-0ubuntu0.14.04.1_amd64.deb ...
- Unpacking mysql-client-core-5.5 (5.5.40-0ubuntu0.14.04.1) ...
- Selecting previously unselected package mysql-client-5.5.
- Preparing to unpack .../mysql-client-5.5_5.5.40-0ubuntu0.14.04.1_amd64.deb ...
- Unpacking mysql-client-5.5 (5.5.40-0ubuntu0.14.04.1) ...
- Selecting previously unselected package mysql-server-core-5.5.
- Preparing to unpack .../mysql-server-core-5.5_5.5.40-0ubuntu0.14.04.1_amd64.deb ...
- Unpacking mysql-server-core-5.5 (5.5.40-0ubuntu0.14.04.1) ...
- Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
- 正在设置 mysql-common (5.5.40-0ubuntu0.14.04.1) ...
- Selecting previously unselected package mysql-server-5.5.
- (正在读取数据库 ... 系统当前共安装有 310943 个文件和目录。)
- Preparing to unpack .../mysql-server-5.5_5.5.40-0ubuntu0.14.04.1_amd64.deb ...
- Unpacking mysql-server-5.5 (5.5.40-0ubuntu0.14.04.1) ...
- Selecting previously unselected package libhtml-template-perl.
- Preparing to unpack .../libhtml-template-perl_2.95-1_all.deb ...
- Unpacking libhtml-template-perl (2.95-1) ...
- Selecting previously unselected package mysql-server.
- Preparing to unpack .../mysql-server_5.5.40-0ubuntu0.14.04.1_all.deb ...
- Unpacking mysql-server (5.5.40-0ubuntu0.14.04.1) ...
- Processing triggers for ureadahead (0.100.0-16) ...
- ureadahead will be reprofiled on next reboot
- Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
- 正在设置 libaio1:amd64 (0.3.109-4) ...
- 正在设置 libmysqlclient18:amd64 (5.5.40-0ubuntu0.14.04.1) ...
- 正在设置 libdbi-perl (1.630-1) ...
- 正在设置 libdbd-mysql-perl (4.025-1) ...
- 正在设置 libterm-readkey-perl (2.31-1) ...
- 正在设置 mysql-client-core-5.5 (5.5.40-0ubuntu0.14.04.1) ...
- 正在设置 mysql-client-5.5 (5.5.40-0ubuntu0.14.04.1) ...
- 正在设置 mysql-server-core-5.5 (5.5.40-0ubuntu0.14.04.1) ...
- 正在设置 mysql-server-5.5 (5.5.40-0ubuntu0.14.04.1) ...
- 141229 11:38:52 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
- mysql start/running, process 8086
- 正在设置 libhtml-template-perl (2.95-1) ...
- Processing triggers for ureadahead (0.100.0-16) ...
- 正在设置 mysql-server (5.5.40-0ubuntu0.14.04.1) ...
- Processing triggers for libc-bin (2.19-0ubuntu6.4) ...
- root:#
复制代码 2、设置 MySQL 管理员 root 用户密码
安装过程中,会自动展示上述进程及出现以下窗口:
设置 MySQL 管理员 root 用户密码,并确认一次;该密码以后很多时候还要使用,不要忘啦。
3、检查 MySQL 服务器状态
- root:# service mysql status
- mysql start/running, process 8086
- root:#
复制代码 4、安装 MySQL Client 5.5.40- root:# apt-get install mysql-client (请选择性安装)
- 正在读取软件包列表... 完成
- 正在分析软件包的依赖关系树
- 正在读取状态信息... 完成
- 下列软件包是自动安装的并且现在不需要了:
- linux-headers-3.13.0-37 linux-headers-3.13.0-37-generic
- linux-headers-3.13.0-39 linux-headers-3.13.0-39-generic
- linux-image-3.13.0-37-generic linux-image-3.13.0-39-generic
- linux-image-extra-3.13.0-37-generic linux-image-extra-3.13.0-39-generic
- Use 'apt-get autoremove' to remove them.
- 下列【新】软件包将被安装:
- mysql-client
- 升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。
- 需要下载 12.3 kB 的软件包。
- 解压缩后会消耗掉 126 kB 的额外空间。
- 获取:1 [url]http://cn.archive.ubuntu.com/ubuntu/[/url] trusty-updates/main mysql-client all 5.5.40-0ubuntu0.14.04.1 [12.3 kB]
- 下载 12.3 kB,耗时 0秒 (27.9 kB/s)
- Selecting previously unselected package mysql-client.
- (正在读取数据库 ... 系统当前共安装有 311042 个文件和目录。)
- Preparing to unpack .../mysql-client_5.5.40-0ubuntu0.14.04.1_all.deb ...
- Unpacking mysql-client (5.5.40-0ubuntu0.14.04.1) ...
- 正在设置 mysql-client (5.5.40-0ubuntu0.14.04.1) ...
- root:#
复制代码 安装 PHP 5.5.9
1、apt-get 命令直接安装 php5-fpm 5.5.9- root:# apt-get install php5-fpm
- 正在读取软件包列表... 完成
- 正在分析软件包的依赖关系树
- 正在读取状态信息... 完成
- 下列软件包是自动安装的并且现在不需要了:
- linux-headers-3.13.0-37 linux-headers-3.13.0-37-generic
- linux-headers-3.13.0-39 linux-headers-3.13.0-39-generic
- linux-image-3.13.0-37-generic linux-image-3.13.0-39-generic
- linux-image-extra-3.13.0-37-generic linux-image-extra-3.13.0-39-generic
- Use 'apt-get autoremove' to remove them.
- 将会安装下列额外的软件包:
- php5-common php5-json
- 建议安装的软件包:
- php5-user-cache php-pear
- 下列【新】软件包将被安装:
- php5-common php5-fpm php5-json
- 升级了 0 个软件包,新安装了 3 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。
- 需要下载 2,667 kB 的软件包。
- 解压缩后会消耗掉 10.6 MB 的额外空间。
- 您希望继续执行吗? [Y/n] y
- 获取:1 [url]http://cn.archive.ubuntu.com/ubuntu/[/url] trusty/main php5-json amd64 1.3.2-2build1 [34.4 kB]
- 获取:2 [url]http://cn.archive.ubuntu.com/ubuntu/[/url] trusty-updates/main php5-common amd64 5.5.9+dfsg-1ubuntu4.5 [442 kB]
- 获取:3 [url]http://cn.archive.ubuntu.com/ubuntu/[/url] trusty-updates/universe php5-fpm amd64 5.5.9+dfsg-1ubuntu4.5 [2,191 kB]
- 下载 2,667 kB,耗时 3秒 (713 kB/s)
- Selecting previously unselected package php5-json.
- (正在读取数据库 ... 系统当前共安装有 311042 个文件和目录。)
- Preparing to unpack .../php5-json_1.3.2-2build1_amd64.deb ...
- Unpacking php5-json (1.3.2-2build1) ...
- Selecting previously unselected package php5-common.
- Preparing to unpack .../php5-common_5.5.9+dfsg-1ubuntu4.5_amd64.deb ...
- Unpacking php5-common (5.5.9+dfsg-1ubuntu4.5) ...
- Selecting previously unselected package php5-fpm.
- Preparing to unpack .../php5-fpm_5.5.9+dfsg-1ubuntu4.5_amd64.deb ...
- Unpacking php5-fpm (5.5.9+dfsg-1ubuntu4.5) ...
- Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
- Processing triggers for ureadahead (0.100.0-16) ...
- 正在设置 php5-common (5.5.9+dfsg-1ubuntu4.5) ...
- Creating config file /etc/php5/mods-available/pdo.ini with new version
- php5_invoke: Enable module pdo for fpm SAPI
- Creating config file /etc/php5/mods-available/opcache.ini with new version
- php5_invoke: Enable module opcache for fpm SAPI
- 正在设置 php5-fpm (5.5.9+dfsg-1ubuntu4.5) ...
- Creating config file /etc/php5/fpm/php.ini with new version
- php5_invoke opcache: already enabled for fpm SAPI
- php5_invoke pdo: already enabled for fpm SAPI
- php5-fpm start/running, process 10370
- 正在设置 php5-json (1.3.2-2build1) ...
- php5_invoke: Enable module json for fpm SAPI
- Processing triggers for ureadahead (0.100.0-16) ...
- root:#
复制代码 2、查看要安装哪些 php5 相关软件包,并安装
- root:# apt-cache search php5
- libapache2-mod-php5 - server-side, HTML-embedded scripting language (Apache 2 module)
- php5 - server-side, HTML-embedded scripting language (metapackage)
- php5-cgi - server-side, HTML-embedded scripting language (CGI binary)
- php5-cli - command-line interpreter for the php5 scripting language
- php5-common - Common files for packages built from the php5 source
- php5-curl - CURL module for php5
- php5-dbg - Debug symbols for PHP5
- php5-dev - Files for PHP5 module development
- php5-gd - GD module for php5
- php5-gmp - GMP module for php5
- php5-json - JSON module for php5
- php5-ldap - LDAP module for php5
- php5-mysql - MySQL module for php5
- php5-odbc - ODBC module for php5
- php5-pgsql - PostgreSQL module for php5
- php5-pspell - pspell module for php5
- php5-readline - Readline module for php5
- php5-recode - recode module for php5
- php5-snmp - SNMP module for php5
- php5-sqlite - SQLite module for php5
- php5-tidy - tidy module for php5
- php5-xmlrpc - XML-RPC module for php5
- php5-xsl - XSL module for php5
- cakephp - MVC rapid application development framework for PHP
- libapache2-mod-php5filter - server-side, HTML-embedded scripting language (apache 2 filter module)
- libexpect-php5 - expect module for PHP 5
- libgv-php5 - PHP5 bindings for graphviz
- libkohana2-modules-php - lightweight PHP5 MVC framework (extension modules)
- libkohana2-php - lightweight PHP5 MVC framework
- libkohana3.1-core-php - PHP5 framework core classes
- libkohana3.1-php - PHP5 framework metapackage
- libkohana3.2-core-php - PHP5 framework core classes
- libkohana3.2-php - PHP5 framework metapackage
- libow-php5 - Dallas 1-wire support: PHP5 bindings
- libphp-jpgraph - Object oriented graph library for php5
- libphp-jpgraph-examples - Object oriented graph library for php5 (examples)
- libphp5-embed - HTML-embedded scripting language (Embedded SAPI library)
- php-auth - Creating an authentication system
- php-codesniffer - PHP, CSS and JavaScript coding standard analyzer and checker
- php-doc - Documentation for PHP5
- php-http-request2 - Provides an easy way to perform HTTP requests
- php-imlib - PHP Imlib2 Extension
- php-letodms-lucene - Document management system - Fulltext search
- php5-adodb - Extension optimising the ADOdb database abstraction library
- php5-apcu - APC User Cache for PHP 5
- php5-enchant - Enchant module for php5
- php5-exactimage - fast image manipulation library (PHP bindings)
- php5-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
- php5-gdcm - Grassroots DICOM PHP5 bindings
- php5-gearman - PHP wrapper to libgearman
- php5-geoip - GeoIP module for php5
- php5-gnupg - wrapper around the gpgme library
- php5-imagick - ImageMagick module for php5
- php5-imap - IMAP module for php5
- php5-interbase - interbase/firebird module for php5
- php5-intl - internationalisation module for php5
- php5-lasso - Library for Liberty Alliance and SAML protocols - PHP 5 bindings
- php5-librdf - PHP5 language bindings for the Redland RDF library
- php5-mapscript - php5-cgi module for MapServer
- php5-mcrypt - MCrypt module for php5
- php5-memcache - memcache extension module for PHP5
- php5-memcached - memcached extension module for PHP5, uses libmemcached
- php5-midgard2 - Midgard2 Content Repository - PHP5 language bindings and module
- php5-ming - Ming module for php5
- php5-mongo - MongoDB database driver
- php5-msgpack - PHP extension for interfacing with MessagePack
- php5-mysqlnd - MySQL module for php5 (Native Driver)
- php5-mysqlnd-ms - MySQL replication and load balancing module for PHP
- php5-oauth - OAuth 1.0 consumer and provider extension
- php5-pinba - Pinba module for PHP 5
- php5-ps - ps module for PHP 5
- php5-radius - PECL radius module for PHP 5
- php5-redis - PHP extension for interfacing with Redis
- php5-remctl - PECL module for Kerberos-authenticated command execution
- php5-rrd - PHP bindings to rrd tool system
- php5-sasl - Cyrus SASL Extension
- php5-stomp - Streaming Text Oriented Messaging Protocol (STOMP) client module for PHP 5
- php5-svn - PHP Bindings for the Subversion Revision control system
- php5-sybase - Sybase / MS SQL Server module for php5
- php5-tokyo-tyrant - PHP interface to Tokyo Cabinet's network interface, Tokyo Tyrant
- php5-vtkgdcm - Grassroots DICOM VTK PHP bindings
- php5-xcache - Fast, stable PHP opcode cacher
- php5-xdebug - Xdebug Module for PHP 5
- php5-xhprof - Hierarchical Profiler for PHP5
- phpunit - Unit testing suite for PHP5
- root:#
复制代码 其中 其中 php5-cgi (CGI 通用网关接口)、php5-curl (客户端 URL)、php5-dev (开发支持)、php5-gd (GD 图像处理)、php5-mysql (MySQL 支持)、php5-pspell (拼写检查支持)、php5-recode (编码字符集支持)、php5-snmp (SNMP 简单网络管理协议支持)、php5-sqlite (SQLite 数据库支持)、php5-tidy (Tidy HTML 支持)、php5-xmlrpc (XML-RPC 支持)、php5-xsl (XLS 支持)、php5-imagick (ImageMagick 图像处理)、php5-imap (IMAP 邮件客户端支持)、php5-intl (国际化支持)、php5-mcrypt (Mcrypt 加密)、php5-memcache (memcache 客户端)、php5-memcached (memcache 服务器端)、php5-ming (swf 扩展支持)、php5-ps (PostScript 文档支持),这些都需要安装:
- root:#apt-get install php5 php5-cgi php5-curl php5-dev php5-gd php5-mysql php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-imagick php5-imap php5-intl php5-mcrypt php5-memcache php5-memcached php5-ming php5-ps php-pear php-apc
复制代码 3、配置 php.ini 将 ;cgi.fix_pathinfo=1 去掉注释并改为 cgi.fix_pathinfo=0
4、重载、重启 php5-fpm 5.5.9、nginx 1.4.6- root:# service php5-fpm reload
- root:# service php5-fpm restart
- stop: Unknown instance:
- php5-fpm start/running, process 3811
- root:# service nginx reload
- * Reloading nginx configuration nginx [ OK ]
- root:# service nginx restart
- * Restarting nginx
复制代码 5、创建名为 “info.php” 的 PHP 探针文件并测试
- vi /usr/share/nginx/html/info.php (或把 info.php 放到支持 php 的网站根目录下)
复制代码 文件内容:
在 FireFox 或 IE 浏览器中键入 http://localhost/info.php 或 http://127.0.0.1/info.php (或 http://服务器 IP 地址/info.php);若出现以下图片内容,说明 LNMP 安装成功:
版权声明:
本文为独家原创稿件,版权归 德云社区,未经许可不得转载;否则,将追究其法律责任。
|
|