翻译完成 (#4049)

This commit is contained in:
jianbo.lu 2016-06-10 23:12:08 +08:00 committed by Ezio
parent 465d5f834a
commit f2eae7b83e
2 changed files with 162 additions and 160 deletions

View File

@ -1,160 +0,0 @@
lujianbo
LAMP Stack Installation Guide on Ubuntu Server 16.04 LTS
=========================================================
LAMP stack is a collection of free and open source softwares like **Linux**, Web Server (**Apache**), Database server (**MySQL / MariaDB**) and **PHP** (Scripting Language). LAMP is the platform which is required to install and build dynamic web sites and application like WordPress, Joomla, OpenCart and Drupal.
In this article i will describe how to install LAMP on Ubuntu Server 16.04 LTS, As We know that Ubuntu is a Linux based Operating system, so it provides the first component of LAMP and i am assuming Ubuntu Server 16.04 is already installed on your system.
### Installation of Web Server (Apache2) :
In Ubuntu Linux Web server comes with the name Apache2, Use the beneath apt command to install it.
```
linuxtechi@ubuntu:~$ sudo apt update
linuxtechi@ubuntu:~$ sudo apt install apache2 -y
```
When Apache2 package is installed then its service is automatically started and enabled across the reboot, In case it is not started and enabled, use the following command :
```
linuxtechi@ubuntu:~$ sudo systemctl start apache2.service
linuxtechi@ubuntu:~$ sudo systemctl enable apache2.service
linuxtechi@ubuntu:~$ sudo systemctl status apache2.service
```
If Ubuntu firewall (ufw) is active, then allow the Web Server ports (80 and 443) in firewall using below commands.
```
linuxtechi@ubuntu:~$ sudo ufw status
Status: active
linuxtechi@ubuntu:~$ sudo ufw allow in 'Apache Full'
Rule added
Rule added (v6)
linuxtechi@ubuntu:~$
```
### Access Web Server now :
Open the Web browser and type the IP Address or Host name of your server (http://IP_Address_OR_Host_Name), In my Case my server IP is 192.168.1.13
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/Apache2-Ubuntu-server-16.04-1024x955.jpg)
### Installation of Data Base Server (MySQL Server 5.7) :
MySQL and MariaDB are the database servers in Ubuntu 16.04. MySQL Server and MariaDB Servers packages are available in the default repositories and we can install either of the database. Run the following apt command to install MySQL Server from terminal.
```
linuxtechi@ubuntu:~$ sudo apt install mysql-server mysql-client
```
During the installation, it will prompt us to set the root password of mysql server.
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/Enter-root-password-mysql-server-ubuntu-16-04.jpg)
Confirm root password and click on OK
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/confirm-root-password-mysql-server-ubuntu-16-04.jpg)
Installation of MySQL Server is completed Now. MySQL Service will be started and enabled automatically.We can verify the MySQL Servers service using below systemcl command :
```
linuxtechi@ubuntu:~$ sudo systemctl status mysql.service
```
### Installation of MariaDB Server :
Use the beneath command to install MariaDB Server 10.0 from the terminal.
```
linuxtechi@ubuntu:~$ sudo apt install mariadb-server
```
Run the following command to set root password of mariadb and disable other options like disable remote login.
```
linuxtechi@ubuntu:~$ sudo mysql_secure_installation
```
### Installation of PHP ( Scripting Language ) :
PHP 7.0 is available in the Ubuntu repositories. Execute the beneath command from the terminal to install PHP 7 :
```
linuxtechi@ubuntu:~$ sudo apt install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7.0
```
Create a sample php page and place it in apache document root (/var/ww/html)
```
linuxtechi@ubuntu:~$ vi samplepage.php
<?php
phpinfo();
?>
```
Save and exit the file.
```
linuxtechi@ubuntu:~$ sudo mv samplepage.php /var/www/html/
```
Now Access the sample PHP page from the Web Browser, type : “http://<Server_IP>/samplepage.php” , You should get the page like below.
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/Sample-PHP-Page-Ubuntu-Server-16-04.jpg)
Above Page shows that our PHP installation is completed successfully.
### Installation of phpMyAdmin :
phpMyAdmin allows us to perform all the database related administrative and other DB operation task from its web interface. Its package is already listed in the Ubuntu server repositories.
Use the below commands to Install phpMyAdmin on Ubuntu server 16.04 LTS.
```
linuxtechi@ubuntu:~$ sudo apt install php-mbstring php7.0-mbstring php-gettext
linuxtechi@ubuntu:~$ sudo systemctl restart apache2.service
linuxtechi@ubuntu:~$ sudo apt install phpmyadmin
```
During its installation it will prompt us to choose the Web server to be configured for phpMyAdmin.
Select Apache2 and Click on OK.
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/Web-Server-for-phpMyAdmin-Ubuntu-Server-16-04.jpg)
Click on Yes to Configure database for phpMyAdmin.
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/configure-database-for-phpmyadmin-ubuntu-server-16-04.jpg)
Specify the password for phpMyAdmin to register with Database Server.
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/Select-Password-for-phpMyadmin-ubuntu-16-04-1024x433.jpg)
Confirm the password for phpMyAdmin and then click on OK
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/confirm-password-for-phpmyadmin-ubuntu-server-16-04.jpg)
Now try to access the phpMyAdmin, open the browser type : “http://Server_IP_OR_Host_Name/phpmyadmin”
Use the user name as root and password that we set during the installation.
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/phpMyAdmin-Ubuntu-Server-16-04-1024x557.jpg)
When we click on Go, it will redirect the page to phpMyAdmin Web interface as shown below.
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/phpMyAdmin-portal-overview-ubuntu-server-16-04-1024x557.jpg)
Thats it, LAMP stack is successfully installed and is ready for use 🙂 . Please share your feedback and comments.
--------------------------------------------------------------------------------
via: http://www.linuxtechi.com/lamp-stack-installation-on-ubuntu-server-16-04/
作者:[Pradeep Kumar][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: http://www.linuxtechi.com/author/pradeep/

View File

@ -0,0 +1,162 @@
在 Ubuntu Server 16.04 LTS 上安装 LAMP
=========================================================
LAMP方案是一系列自由和开源软件的集合包含了 **Linux**, web服务器 (**Apache**), 数据库服务器 (**MySQL / MariaDB**) 和 **PHP** (脚本语言). LAMP是那些需要安装和构建动态网页应用的基础平台比如WordPress, Joomla, OpenCart and Drupal。
在这篇文章中我将描述如何在Ubuntu Server 16.04 LTS 上安装LAMP众所周知Ubuntu是一个基于linux的操作系统因此它构成了LAMP的第一个部分在接下来的操作中我将默认你已经安装了 Ubuntu Server 16.04。
### Apache2 web服务器的安装 :
在Ubuntu linux中web 服务器称之为 Apache2我们可以利用下面的命令来安装它
```
linuxtechi@ubuntu:~$ sudo apt update
linuxtechi@ubuntu:~$ sudo apt install apache2 -y
```
当安装Apache2包之后Apache2相关的服务将会在重启后变成可用状态和自动运行在某些情况下如果你的Apache2服务并没有自动可用和启动你可以利用如下命令来启用它。
```
linuxtechi@ubuntu:~$ sudo systemctl start apache2.service
linuxtechi@ubuntu:~$ sudo systemctl enable apache2.service
linuxtechi@ubuntu:~$ sudo systemctl status apache2.service
```
如果你开启了Ubuntu的防火墙ufw那么你可以使用如下的命令来解除web服务器的端口(80和443)限制
```
linuxtechi@ubuntu:~$ sudo ufw status
Status: active
linuxtechi@ubuntu:~$ sudo ufw allow in 'Apache Full'
Rule added
Rule added (v6)
linuxtechi@ubuntu:~$
```
### 现在开始访问你的web服务器 :
打开浏览器并输入服务器的IP地址或者主机名
(http://IP_Address_OR_Host_Name),在我的例子中我的服务器IP是192.168.1.13
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/Apache2-Ubuntu-server-16.04-1024x955.jpg)
### 数据库服务器的安装r (MySQL Server 5.7) :
MySQL 和 MariaDB 都是 Ubuntu 16.04 中的数据库服务器. MySQL Server 和 MariaDB Server的安装包都可以在Ubuntu的默认软件源中找到我们可以选择其中的一个来安装.通过下面的命令来在终端中安装mysql服务器
```
linuxtechi@ubuntu:~$ sudo apt install mysql-server mysql-client
```
在安装过程中它会要求你设置mysql服务器root帐户的密码.
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/Enter-root-password-mysql-server-ubuntu-16-04.jpg)
确认root帐户的密码并点击确定
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/confirm-root-password-mysql-server-ubuntu-16-04.jpg)
Mysql 服务器的安装到此已经结束了, MySQL 服务会自动变成可用状态和自动启动.我们可以通过如下的命令来校验Mysql服务的状态
```
linuxtechi@ubuntu:~$ sudo systemctl status mysql.service
```
### MariaDB Server的安装 :
在终端中利用如下的命令来安装 Mariadb 10.0 服务器。
```
linuxtechi@ubuntu:~$ sudo apt install mariadb-server
```
运行如下的命令来设置mariadb root帐户的密码还可以用来关闭某些选项比如关闭远程登录功能。
```
linuxtechi@ubuntu:~$ sudo mysql_secure_installation
```
### PHP脚本语言的安装:
PHP 7 已经存在于Ubuntu的软件源中了在终端中执行如下的命令来安装PHP 7:
```
linuxtechi@ubuntu:~$ sudo apt install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7.0
```
创建一个简单的php页面并且将它移动到 apache的文档根目录下 (/var/ww/html)
```
linuxtechi@ubuntu:~$ vi samplepage.php
<?php
phpinfo();
?>
```
在vi中编辑之后保存并退出该文件。
```
linuxtechi@ubuntu:~$ sudo mv samplepage.php /var/www/html/
```
现在你可以从web浏览器中访问这个页面,
输入 : “http://<Server_IP>/samplepage.php” ,你可以看到如下页面.
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/Sample-PHP-Page-Ubuntu-Server-16-04.jpg)
以上的页面向我们展示了PHP已经完全安装成功了
### phpMyAdmin的安装:
phpMyAdmin可以让我们通过它的web界面来执行所有和数据库管理和其他数据库操作相关的任务这个安装包已经存在于Ubuntu的软件源中
利用如下的命令来在Ubuntu server 16.04 LTS中安装phpMyAdmin
```
linuxtechi@ubuntu:~$ sudo apt install php-mbstring php7.0-mbstring php-gettext
linuxtechi@ubuntu:~$ sudo systemctl restart apache2.service
linuxtechi@ubuntu:~$ sudo apt install phpmyadmin
```
在以下的安装过程中它会提示我们选择phpMyAdmin运行的目标服务器
选择 Apache2 并点击确定
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/Web-Server-for-phpMyAdmin-Ubuntu-Server-16-04.jpg)
点击确定来配置phpMyAdmin管理的数据库
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/configure-database-for-phpmyadmin-ubuntu-server-16-04.jpg)
指定phpMyAdmin向数据库服务器注册时所用的密码
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/Select-Password-for-phpMyadmin-ubuntu-16-04-1024x433.jpg)
确认phpMyAdmin所需的密码并点击确认
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/confirm-password-for-phpmyadmin-ubuntu-server-16-04.jpg)
现在可以开始尝试访问phpMyAdmin, 打开浏览器并输入 : “http://Server_IP_OR_Host_Name/phpmyadmin”
利用我们安装时设置的 root帐户和密码
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/phpMyAdmin-Ubuntu-Server-16-04-1024x557.jpg)
当我们点击“Go”的时候将会重定向到如下所示的 phpMyAdminweb界面
![](http://www.linuxtechi.com/wp-content/uploads/2016/05/phpMyAdmin-portal-overview-ubuntu-server-16-04-1024x557.jpg)
到现在LAMP方案已经被成功安装和使用了欢迎分享你的反馈和评论。
--------------------------------------------------------------------------------
via: http://www.linuxtechi.com/lamp-stack-installation-on-ubuntu-server-16-04/
作者:[Pradeep Kumar][a]
译者:[陆建波](https://github.com/lujianbo)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: http://www.linuxtechi.com/author/pradeep/