Build a Lamp (linux + apache + mysql + php) environment
1. install apache2: sudo apt-get installapache2
After the installation is complete, run the following command to restart apache: sudo/etc/init. d/apache2 restart: enter http: // localhost or http: // 127.0.0.1 in the browser and you will see "It works! "Indicates that apache is successfully installed.
2. install php: sudoapt-get install libapache2-mod-php5 php5;
Install extension php5-gd: sudo apt-get installlibapache2-mod-php5 php5-gd
Php5-mysql: sudo apt-get install libapache2-mod-php5 php5-mysql
After installation, restart apache to load the PHP module: sudo/etc/init. d/apache2 restart.
Next, create a PHP file under the Web directory to test whether PHP can run normally:
Sudo gedit/var/www/phpinfo. php, input and save the file, and enter http: // localhost/phpinfo in the browser. php. if a page displays php running parameters, PHP can run normally.
Phpinfo ();
? Php>
3. install mysql: sudo apt-get installmysql-server mysql-client. enter the root password at the end of the installation. the root password here refers to setting the root password of MySQL.
4. install phpmyadmin-Mysql database management:
Sudo apt-get installlibapache2-mod-auth-mysql php5-mysql phpmyadmin, this installation with php5 phpmyadmin. After phpmyadmin is installed, configure phpmyadmin and apache2:
Cp/etc/phpmyadmin/apache. conf/etc/apache2/sites-available/phpmyadmin. copy the conf (apache configuration file) to The phpmyadmin file under apache2/sites-available, and enter the sites-enabled folder:
Cd/etc/apache2/sites-enabled to create a link to the configuration file: sudo ln-s .. /sites-available/phpmyadmin, restart apache2: sudo/etc/init. d/apache2restart. Finally, you can enable http: // localhost/phpmyadmin for verification. In this way, the basic components of LAMP are installed.
/*************************************** **************************************** */
Next, perform some other settings:
1. by default, the root directory of the PHP network server is set to/var/www. due to the security principle of the Linux system, only the root user can perform operations to change the file read/write permissions under the Directory, therefore, you can use the root terminal command: sudo chmod 777/var/www to modify the read and write permissions of the/var/www directory, and then you can write the html or php file.
2. configure apahce: enable the mod_rewrite module sudo a2enmod rewrite and restart the apache server sudo/etc/init. d/apache2 restart: create the file test in the/var/www directory. php, write code Save and enter http: // 127.0.0.1/test. php in the browser. if the php configuration information appears, it indicates that LAMP Apache is working properly (restart the apache server and test ).
Set apacheto support .htm. html. php: sudo gedit/etc/apache2/apache2.conf
Add AddType application/x-httpd-php. php. htm. html to the open file.