Install Apache+php+mysql under Ubuntu

Source: Internet
Author: User
Tags install php learn php mcrypt php server php web server phpmyadmin wordpress blog

In the movie "Social Network", Facebook founder Mark Zack broke into the Harvard University dormitory building server, stealing database data, and in two hours to complete a school female students scored interactive website, the site a day in the number of clicks over 10W, directly caused the school server crash ...
In fact, building such a site does not require a lot of advanced technology, anyone with a certain network programming foundation can do. Mark built the site using the Apache server and PHP Server scripting language, I used three days to learn PHP, and then spent two weeks to write a website for the school, see PHP is very simple, and the Facebook background is written in PHP, of course, Everyone now see my wordpress blog backstage is also php~~.

In other words, many people may have used Ubuntu, we may spend a lot of time on the beautification of Ubuntu, this is understandable, but, Ubuntu should give us the work and learning to bring more convenience and convenience. Ubuntu, as Linux, provides us with a powerful network-side feature in which server technology is particularly powerful and secure. If you do not learn the network technology of Linux, it is difficult to know that you have mastered Linux.

Today, I configured an Apache server under Ubuntu. Through Apache we can learn PHP network programming, you can use it to deploy their own local WordPress blog, so that further through the network and friends to communicate. From then on, you will have a deep understanding of the network with a magical power of our, at least I feel so ~ ~

Step One, install Apache2

sudo apt-get Install Apache2

Installation is complete.
Run the following command to restart:

Sudo/etc/init.d/apache2 restart

Enter http://localhost or http://127.0.0.1 in the browser, if you see the IT works!, it means that Apache installed successfully, Apache default installation, will be in/var under a directory called WWW, This is the Web directory, all Web files that can be accessed by the browser should be placed in this directory.

Step two, install PHP:

sudo apt-get install libapache2-mod-php5 php5

In addition, it is recommended to install the extension php5-gd Php5-mysql, the same way.

After installation, we will restart Apache and let it load the PHP module:

Sudo/etc/init.d/apache2 restart

Next, we'll create a new test.php file under the Web directory to test if PHP works properly, command:

sudo gedit/var/www/test.php

Then enter:

<?php echo "hello,world!! " ?>
then save the file, enter the http://127.0.0.1/test.php in the browser, if the hello,world!! is displayed in the Web page, it means that PHP is working properly.

Step three, install the MySQL database:

sudo apt-get install Mysql-server mysql-client

The Apt-get program will automatically download and install the latest MySQL version. At the end of the installation, it will require the root password to be entered, note that the root password here is not the root password of Ubuntu, it is the root password you want to set for MySQL.

Step four, install Phpmyadmin-mysql database management

sudo apt-get Install phpMyAdmin

phpMyAdmin settings:

During installation, you will be asked to select the Web server:apache2 or LIGHTTPD, use the SPACEBAR to choose Apache2, press the TAB key, and then OK. You will then be asked to enter the MySQL database password for the setup password password of the database ' s administrative user.

Then connect the phpMyAdmin with the apache2, in my case: the WWW directory is in/var/www,phpmyadmin in the/usr/share/phpmyadmin directory, so just use the command

sudo ln-s/usr/share/phpmyadmin/var/www

Establish a link.

phpMyAdmin test: Open Http://localhost/phpmyadmin in the browser address bar.

The basic components of the above ALMP are installed, let's look at some other settings:

Step five, set the Ubuntu file to perform read and write permissions

After the lamp is assembled and installed, the default settings for the PHP Web server root directory are:/var/www. Because of the security principle of Linux system, the file read and write permission in the directory is only allowed by root user, so we can't create a new php file in www folder or modify or delete it, we must first modify the read and write permission of the/var/www directory. In the interface manager through the right-click property cannot modify the file permissions, you have to execute the root terminal command:

777 /var/www

You can then write to the HTML or PHP file. 777 is the highest privilege in Linux, which means readable, writable, and executable.

Solve the problem of mcrypt extension under Phpadmin: cd /etc/php5/apache2/conf .d/sudo ln-s. /.. /mods-available/mcrypt.ini./20-mcrypt.ini sudo service apache2 restart

Install Apache+php+mysql under Ubuntu

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.