Install Apache, MySQL, and PHP In Debian

Source: Internet
Author: User

This article is from DigitalOcean. I translated it and tested and installed it successfully.

Installation environment: Debian7 64-bit

First, update your source:

$ sudo apt-get update
Step 1-install Apache

Apache is an open-source software that runs on more than 50% of servers worldwide and is part of LAMP (Linux, Apache, MySQL, and PHP.

Install Apache:

$ sudo apt-get install apache2

After the installation is complete, you can enter http: // localhost/in the address bar of the browser. After the installation is successful, an It works page is displayed.

You can use the following command to find the IP address of your server:

$ sudo ifconfig eth0 | grep inet | awk '{ print $2 }'
Step 2 -- install MySQL
MySQL is a widely deployed database management system for organizing and retrieving data.

Install MySQL:

$ sudo apt-get mysql-server
During the installation process, MySQL requires you to set a root password, but if you forget to set it, You can also set it through MySQL shell after installation.

After installing MySQL, You need to perform initial MySQL settings by using the following command:

# mysql_secure_installation
This step requires your root password.

The input will look like this:

Enter current password for root (enter for none): OK, successfully used password, moving on...
Then you will be prompted if you want to change the root password, Enter N, and Enter to go to the next step.

The subsequent steps are all Yes, and MySQL will reload to complete the settings, as follows:

By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem.  This is intended only for testing, and to make the installationgo a bit smoother.  You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] y                                             ... Success!Normally, root should only be allowed to connect from 'localhost'.  Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] y... Success!By default, MySQL comes with a database named 'test' that anyone canaccess.  This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] y ... Success!Cleaning up...
After completing the above steps, you can start to install PHP.

Step 3-install PHP
PHP is an open-source Web scripting language and is widely used to create dynamic Web pages.

Install PHP (less than Debian 7 ):

# apt-get install php5 php-pear php5-suhosin php5-mysql
Install PHP (Debian 7 ):

# apt-get install php5 php-pear php5-mysql
There will be two inquiries, all of which are yes.

After installing PHP, reload Apache:

# service apache2 restart
Congratulations! You have successfully installed LAMP!
Step 4: view the PHP version and other information on your server

Although we have installed LAMP, we still need to view the installed LAMP more intuitively.

First, create a file:

# nano /var/www/info.php
Write down in the new file:
<?phpphpinfo();?>
Save and exit.

Now you can enter http: // localhost/info. php in your browser to view the PHP version and other information, as shown in the following figure:









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.