Reprinted from: http://www.comflag.com/2011/05/01/apache-web.htm
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
1 |
sudo apt-get install apache2 |
Installation is complete.
Run the following command to restart:
1 |
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:
1 |
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:
1 |
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:
1 |
sudo gedit /var/www/test.php |
Then enter:
12 |
<?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:
1 |
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
1 |
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 phpMyAdmin with Apache2, in my case: the WWW directory is in the/var/www,phpmyadmin directory in/usr/share/phpmyadmin, so just use the command:
1 |
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:
1 |
sudo chmod 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.
Install Apache+php+mysql under Ubuntu