A simple tutorial for beginners to install LAMP environment package under Ubuntu 16.04

888u

Last update at :2024-05-18,Edit by888u

First of all, the LAMP environment has always been very popular for website building; secondly, the Ubuntu system has always been famous for its fast updates and complete components. Here we use the long-term support version of Ubuntu 16.04 to demonstrate to novices How to manually install the LAMP environment.

Basic requirements for installing LAMP environment:

A VPS or a dedicated server, and the Ubuntu16.04 system has been installed by default

Secondly, you need to have an account with sudo permissions

Prepare a client such as putty or Xshell

We install in 3 steps:

  • Install Apache
  • Install MySQL
  • Install PHP
  • A common action before installation to ensure that our system is up to date:

    apt-get update && apt-get upgrade

    Install Apache

    After the update is completed, install Apache using the following command:

    sudo apt-get install apache2

    Don't forget to enter "Y" when asked for confirmation during the run!

    After installing Apache, we check whether the following Apache is running normally:

    sudo service apache2 status

    If you find that Apache is not running normally after installing Apache successfully, please enter the following command:

    sudo service apache2 stop

    sudo service apache2 start

    Now we directly enter the IP address through the browser to access directly and verify whether it is successful:

    http://IP/

    If you don’t know the IP address, you can use the following command to find it:

    ip addr show

    ifconfig -a

    Generally speaking, after the Apache installation is completed, the following interface will appear when accessing through the IP address:

    Install MySQL

    Install MySQL directly with the following command:

    sudo apt-get install mysql-server

    If you are asked to confirm, just enter "Y" directly.

    Of course, you will be asked to enter MySQL’s default root highest-privilege password during this period. Remember, this is the highest-privilege password for MySQL. Please set it more complicatedly. It is best not to be consistent with the highest-privilege password of your Ubuntu system.

    Use the following commands to remove some of MySQL’s default security settings;

    sudo mysql_secure_installation

    When encountering some inquiries, enter "Y" directly, as follows:

    Then let’s check whether MySQL is running normally after installing it:

    sudo service mysql status

    To stop and start MySQL, you can use the following commands:

    sudo service mysql stop

    sudo service mysql start

    Install PHP

    Next we will install the latest version of PHP and install the following components: libcurl3, librtmp1, php, php-cgi, php-common, php-curl, php-json, php-mysql, php7. 0,php7.0-cgi,php7.0-cli,php7.0-common,php7.0-curl,php7.0-fpm,php7.0-json,php7.0-mysql,php7.0-opcache, php7.0-readline

    The command is as follows:

    sudo apt-get install php-mysql php-curl php-json php-cgi libapache2-mod-php php

    If your environment requires it, you can install the following Php modules and libraries with the following command:

    apt-cache search php- | less

    apt-cache show Packagename

    sudo apt-get install packagename

    When installing multiple packages, you can use one command + the names of multiple packages, for example:

    sudo apt-get install package1 package2 package3

    Check the current PHP version number:

    php -v

    Test whether PHP is running normally on Ubuntu. Under normal circumstances, Ubuntu will not tell us whether PHP is running normally. The default path for outputting PHP text is:

    /var/www/html

    We only need to put a PHP test file under the path above:

    sudo vi /var/www/html/phptest.php

    Write in the file:

    phpinfo();

    ?>

    Next, in the browser, enter the absolute path of the PHP file just now to access:

    http://ipaddress/phptest.php

    Finally, don’t forget to delete this file for security reasons:

    sudo rm /var/www/html/phptest.php

    Recommended site searches: Hong Kong server rental, Ministry of Industry and Information Technology website registration system IP segment query, Hengtian host, website space registration-free, Korean website domain name, website space registration-free, the cheapest dual-line space, free virtual host, domain name query ,

    A simple tutorial for beginners to install LAMP environment package under Ubuntu 16.04

    All copyrights belong to 888u unless special state
    取消
    微信二维码
    微信二维码
    支付宝二维码