Ubuntu16.04 install LAMP

Ubuntu16.04 install LAMP

In this tutorial I use the host with IP address 192.168.10.13

These settings may vary, so you must replace them where appropriate.

Imprint

  • Linux:Ubuntu 16.04
  • Apache:Apache 2.4.18
  • MySQL:MySQL 5.7.22
  • PHP:PHP 7.0.28

Configure ufw service

In this tutorial we shut down the ufw service, so we can do this:

$ ufw disable

If the site is not accessible from the Internet, you may have to go to the server provider's console to release the appropriate port

install apache 2.4.18

Ubuntu16.04 provides Apache2.4.18. So we can install it like this:

$ sudo apt -y install apache2
# 安装完成后系统会自动启动服务

Install MySQL 5.7.22

Ubuntu16.04 provides MySQL, and you will be prompted to set the database password during the installation process. So we can install it like this:

$ sudo apt -y install mysql-server mysql-client
# 安装过程中,根据提示设置数据库密码
# 安装完成后系统会自动启动服务

Execute the MySQL initialization script:

$ mysql_secure_installation

Note: For all MySQL servers used in production, it is recommended to run all parts of this script! Please read each step carefully!

Install PHP 7.0.28

Ubuntu16.04 provides PHP 7.0.28. So we can install it like this:

$ sudo apt -y install php libapache2-mod-php

After installing PHP we have to restart Apache:

$ systemctl restart apache2

Test if PHP7 is linked with Apache and get details about your PHP7 installation. We now create a small PHP file (index.php) and call it in the browser. This file will display a lot of useful information about our PHP installation:

$ vim /var/www/html/index.php
<?php
    phpinfo();
?>

Open http://192.168.10.13 in your browser to see the PHP information, as you can see, PHP7 is running and it is working through the Apache 2.0 Handler as shown in the Server API line. If you scroll down you will see all the modules that have been enabled in PHP7. MySQL is not listed there, which means we don't have MySQL support in PHP7 yet. To get MySQL support in PHP, we can install php-mysqlpackages. It's better to install some other PHP7 modules, as well as you might need them for your application. You can search for available PHP7 modules like this:

$ sudo apt search php-	# 搜索可用的php模块
## 选择你需要的,并像这样安装它们:
$ sudo apt install php-mysql
在下一步中,我将安装一些CMS系统需要的常见PHP模块,如Wordpress,Joomla和Drupal:
$ sudo apt install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl libcurl3

After the installation is complete, restart the httpd service, and then open http://192.168.10.13 again to see more extension information for PHP:

$ systemctl restart apache2

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325517691&siteId=291194637
Recommended