Ubuntu 16.04 Build Web server (mysql+php+apache) tutorial

Source: Internet
Author: User
Tags chmod file info mysql in phpmyadmin

1. Start the description

Many of the following may be referred to the Internet as a predecessor, but some improvements. These settings may vary, and you will need to modify them according to different circumstances.

Installing Apache2

2. Switch Administrator status

You need to use root in Ubuntu, so make sure to log in as root with the following command:

sudo su

3. Start the installation of MYSQL5

Apt-get Install Mysql-server mysql-client

You will be asked to provide a password for the root user of MySQL and we need to set the password in the red zone.

New password for the MySQL root user:repeat password for the MySQL root user:

4. Installing Apache2

Apache2 is a software package for Ubuntu, so we can install it directly with the following command:

Apt-get Install Apache2

Now, your browser to http://localhost, you should see the APACHE2 test page:

If it goes well, it will appear:

It worke!

And then a little later.

The default document root directory for Apache is the/var/www directory on Ubuntu and the config file is/etc/apache2/apache2.conf. Configure the subdirectories stored in the/etc/apache2 directory.

Installing PHP5

5. Installing php7.0

We can install the PHP7 and Apache PHP7 modules directly, as follows:

Apt-get Install php7.0 libapache2-mod-php7.0

Restart required after installation

/etc/init.d/apache2 restart

6. Test the PHP5 and get php5 installation of Detailed Letter Interest

The default Web site's file root directory is under/var/www. Now we will create a small php file (info.php) in the directory to invoke it in the browser. The file will display a lot about our PHP installation, such as the installed PHP version and some useful details.

vi/var/www/info.php

Here is the explanation, if the command line operation is not possible (of course, since you should be accustomed to using Linux to learn to use the command line). Can be set up manually, that is, in the system file/var/www/under the establishment of the file info.php, written inside

123 <?phpphpinfo()?>

Here is the following: It is also my problem, I started to install the Ubuntu 12.04, I found here I do not have permission to operate, although the root authority has been obtained, here to tell you,
How should we set the read and write permissions for the file and file directories?
Everyone knows, we use the virtual host know set 777 what, in fact, here is the same, there are many ways to use, I will tell one of them.
Here we use chmod, for example we want to set up our WWW directory read and write, is chmod 777/var/www/. Specifically, we can refer to the use of the Baidu Encyclopedia command
Http://baike.baidu.com/view/1229012.htm.
Now we can use a browser to access such as http://localhost/info.php


As you can see, php5 works properly, it passes the Apache 2.0 handler in the Server API line. If you continue scrolling down, you will see all the modules that have been enabled in PHP5. MySQL is not listed, which means we do not support MySQL in PHP5.

PHP5 to get MySQL support

7.PHP5 to get MySQL support

Let PHP get support in MySQL, we can install the Php-mysql package. It is a good idea to install some other PHP5 modules, as well as the applications you may need:

Apt-cache Search PHP5

Also installs the required installation

Apt-get Install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming Php5-ps Php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

Now restart the apache2:

/etc/init.d/apache2 restart

Now, reload the http://localhost/info.php in your browser and scroll down to the module section again. Now you should find many new modules, including the MySQL module:

Installing phpMyAdmin

8. Installing phpMyAdmin

phpMyAdmin is a network interface through which you can manage your MySQL database.

Apt-get Install phpMyAdmin

At this time I have to correct the shortcomings of the predecessor, he did not speak clearly here. This should be: it will be installed automatically under/usr/share/phpmyadmin, then copy the phpMyAdmin to the/var/www directory or create a link: sudo ln-l/usr/share/phpmyadmin/var/www, You can run http://localhost/phpmyadmin/index.html

Note that the above user name is root, password is everyone in front of the database password set!

All right, now we're finished!

Ubuntu 16.04 Build Web server (mysql+php+apache) tutorial

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.