Build and configure LAMP (Linux + Apache + MySQL + PHP) In Ubuntu. 1. Install SSH: sudoapt-getinstallssh2. install Apache: sudoapt-getinstallapache2 and then run the setup and configuration process of LAMP (Linux + Apache + MySQL + PHP) in Apache: Ubuntu.
1. Install SSH:
- Sudo apt-get install ssh
2. install Apache:
- Sudo apt-get install apache2
Then run Apache:
- Sudo/etc/init. d/apache2 restart
Apache creates a directory/var/www, which is the root directory for storing documents and can be accessed using http: // localhost.
3. Install MySQL:
- Sudo apt-get install mysql-server-5.1 mysql-client-5.1
During installation, you will be prompted to set the root password.
4. install PHP:
- Sudo apt-get install php5 libapache2-mod-php5
5. Install phpMyAdmin
- Sudo apt-get install phpmyadmin
Configuration:
1. Path of the configuration file:
Apache:/etc/apache2/apache2.conf
PHP:/etc/php5/apache2/php5.ini
MySQL:/etc/mysql/my. cnf
PhpMyAdmin:/etc/phpmuadmin/apache. conf
Website root directory:/var/www
2. Configure Apache:
Sudo gedit/etc/apache2/apache2.conf
Supported file types are added:
AddType application/x-httpd-php. php. html. htm
Default character set:
Adddefacharcharset UTF-8
3. Configure PHP:
Sudo gedit/etc/php5/apache2/php. ini
Change the local time zone as needed:
Date. timezone = PRC
4. Configure MySQL:
Sudo gedit/etc/mysql/my. cnf
5. Configure phpMyAdmin:
Transfer the default directory to/var/www:
Cd/var/www
Sudo ln-s/usr/share/phpmyadmin
Then:
Sudo gedit/etc/phpmyadmin/apache. conf
Change/usr/share/phpmyadmin to/var/www/phpmyadmin.
6. sudo chmod-R 777/var/www
Test:
1. http: // localhost has It works! Words
2. sudo netstat-tap | grep mysql
If it cannot be started properly, it runs:
Sudo/etc/init. d/mysql restart
3. sudo vi/var/www/test. php
Input content:
-
- Phpinfo ();
- ?>
Http: // localhost/test. php outputs the PHP parameter.
4. http: // localhost/phpmyadmin. the root user name and password are set just now.