Install Apache + PHP + Mysql in ubuntu

Source: Internet
Author: User
Tags php server wordpress blog
In the movie "Social Network", facebook's founder Mark Zach broke into the server of the Harvard University dormitory building after he fell in love, stole database information, and completed the process within two hours.

Reprinted from: http://www.comflag.com/2011/05/01/apache-web.htm

Facebook founder Mark in the movie social network. after losing love, Zach intruded into the server of the dormitory building of Harvard University, stole database information, and completed an interactive website scoring girls in the school within two hours. The website hits over 10 million in a day, directly causes the school server to crash ......
In fact, building such a website does not require many advanced technologies. Anyone with a certain network programming Foundation can do this. Mark used Apache server and PHP server scripting language to build a website. I used three days to study PHP and wrote a website for the school for two weeks, it can be seen that PHP is very simple, and the facebook background is also written in php. of course, the background of my wordpress blog is also php ~~.

In other words, many people may already use ubuntu, and they may spend a lot of time beautifying ubuntu, ubuntu should bring more convenience and convenience to our work and study. As a linux operating system, ubuntu provides us with powerful network functions. the server technology is particularly powerful and secure. If you do not learn linux network technology, it is hard to say that you have mastered linux.

Today, I configured an Apache server in ubuntu. Through Apache, we can learn php network programming and use it to deploy our local wordpress blog to further communicate with friends through the network. From then on, you will have a deep understanding of the magical power of the network, at least I think so ~~

Step 1: install apache2

?
1 Sudo apt-get install apache2

Installation is complete.
Run the following command to restart the instance:

?
1 Sudo/etc/init. d/apache2 restart

Enter http: // localhost or http: // 127.0.0.1 in the browser. if It works is displayed !, It means that Apache is successfully installed. by default, Apache will create a directory named www under/var, which is the Web directory, all Web files that can be accessed through a browser must be placed in this directory.

Step 2: install php:

?
1 Sudo apt-get install libapache2-mod-php5 php5

In addition, it is recommended to install the extension php5-gd php5-mysql, the installation method is the same as above.

After installation, restart Apache to load the PHP module:

?
1 Sudo/etc/init. d/apache2 restart

Next, we will create a test. PHP file under the Web directory to test whether PHP can run normally. command:

?
1 Sudo gedit/var/www/test. php

Then enter:

?
12

Save the file and enter http: // 127.0.0.1/test. php in the browser. If hello, world! is displayed on the webpage !!, It indicates that PHP is running normally.

Step 3: install the mysql database:

?
1 Sudo apt-get install mysql-server mysql-client

The apt-get program automatically downloads and installs the latest mysql version. At the end of the installation, it will require you to enter the root password. Note that the root password here is not the Ubuntu root password. it is the root password you want to set for MySQL.

Step 4: install phpmyadmin-Mysql database management

?
1 Sudo apt-get install phpmyadmin

Phpmyadmin settings:

During installation, you must select Web server: apache2 or lighttpd, use the space key to select apache2, press the tab key, and then click OK. Then, you are required to enter the Mysql database Password of the database's administrative user.

Then, establish a connection between phpmyadmin and apache2. take my example: the www directory is in the/var/www directory, and The phpmyadmin directory is in the/usr/share/phpmyadmin Directory. Therefore, run the following command:

?
1 Sudo ln-s/usr/share/phpmyadmin/var/www

Create a link.

Phpmyadmin test: open http: // localhost/phpmyadmin in the address bar of the browser.

The basic components of the above ALMP are installed. Next let's take a look at some other settings:

Step 5: Set the Ubuntu file read and write permissions

After LAMP is installed, the default root directory of the PHP network server is/var/www. Due to the security principle of Linux, only root users are allowed to change the file read and write permissions under the Directory. Therefore, you cannot create or delete php files in the www folder, you must first modify the read and write permissions of the/var/www directory. You cannot modify the file permission by right-clicking the attribute in the interface manager. you must run the root terminal command:

?
1 Sudo chmod 777/var/www

. Then you can write html or PHP files. 777 is the highest permission in linux, which indicates readable, writable, and executable.

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.