1. Install and test apache package 1.1 install the apache package sudoapt-getinstallapache21.2. Start and test the apache environment sudo/etc/init. d/apache2start access http: // localhost, you can see that the page has "Itw
1. Install and test the apache package
1.1 install the apache package
- Sudo apt-get install apache2
1.2. Start and test the apache Environment
- Sudo/etc/init. d/apache2 start
Visit http: // localhost and you will see "It works!" on the page !" .
2. Install and test related php packages
2.1 install php-related packages
- Sudo apt-get install php5-cli php5-dev libapache2-mod-php5
2.2. test the apache + php environment and create a test. php file in the/var/www/directory. The content is as follows:
-
- Phpinfo ();
- ?>
2.3 restart apache2
- Sudo/etc/init. d/apache2 restart
Access http: // localhost/test. php to view the environment information of apache and php.
3. Install and test mysql and related packages
3.1 install mysql-related packages
- Sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
3.2 Test mysql. Run the following command to log on to mysql
- $ Mysql-u -P
3.3 test apache + php + mysql
3.3.1 restart apache2
- Sudo/etc/init. d/apache2 restart
3.3.2 create a testdb. php file in the/var/www/directory. The content is as follows:
-
- $ Conn= Mysql_connect ("Localhost","Root","Mysql","Mysql");
- If(!$ Conn){
- Echo("Unable to connect to database .");
- }Else{
- Echo("Connect to database successful .");
- }
- Mysql_close ($ Conn);
- ?>
3.3.3 access http: // localhost/testdb. php. If "Connect to database successful." is displayed, the apache + php + mysql environment is successfully set up.