I. Installation
1. First Install SSH
Sudo apt-get install ssh
2. Install MySQL (although the latest version is 5.1, only MySQL 5.0 can be installed)
Sudo apt-get install mysql-server-5.0
3. install Apache
Sudo apt-get install apache2
4. install PHP
Sudo apt-get install php5 libapache2-mod-php5
5. Restart Apache
Sudo/etc/init. d/apache2 restart
6. Install phpMyAdmin
Sudo apt-get install phpmyadmin
Another method: Install LAMP
Select edit in the new software package manager -- mark the software package with the Task Group
In the displayed window, select lamp server and then confirm
In the main window, click the application button of red/Palladium
Well, the next step is to wait until the new version is automatically downloaded and installed.
You will be prompted to enter the mysql root User Password.
Ii. Test
1. Test Apache
Enter http: // localhost/to check whether the words It works appear.
2. Test MySQL
Input: sudo netstat-tap | grep mysql
You can see rows similar to the following:
Tcp 0 0 localhost. localdomain: mysql *: * LISTEN-
If the server cannot run properly, run the following command to start it: sudo/etc/init. d/mysql restart
3. Test PHP
The root directory of Ubuntu Apache is located in/var/www.
Add a test file test. php file to the file.
Phpinfo ();
?>
Enter http: // localhost/test. php again in the browser. If the php information page is displayed, the PHP installation is successful.
Iii. Configuration
1> apache configuration file path/etc/apache2/apache2.conf
2> php. ini path/etc/php5/apache2/php5.ini
3> mysql configuration file path/etc/mysql/my. cnf
4> phpmyadmin configuration file path/etc/phpmyadmin/apache. conf
5> website root directory/var/www
1. Configure PHP5
There is nothing to say about it. The default time zone is shown below as needed.
; Default. timezone = PRC (remove the semicolon above to represent China)
2. Configure mysql
Sudo gedit/etc/mysql/my. cnf
Note that only local access to the database is allowed by default.
Bind-address 127.0.0.1
This statement only allows local access. For example, if you need access from other machines, comment out this sentence #.
3. Configure phpmyadmin
Phpmyadmin is not installed under/var/www by default, but under/usr/share/phpmyadmin. You can copy phpmyadmin or create a link on the Internet, then copy the Link (not tried ). I personally think it is not necessary to copy it. If you do not copy the previous configuration, you do not need to change the next configuration.
Then run:
Sudo gedit/etc/phpmyadmin/apache. conf
Change the path of the following two names to/var/www/phpmyadmin
Alias/phpmyadmin/usr/share/phpmyadmin
4. Modify the Apache website root directory DocumentRoot in ubuntu
In the/etc/apache2/sites-enabled/directory, you can see a 000-default
Open such a sentence
DocumentRoot/var/www
Change path
Restart the Apache2 service.
Operator: Common commands
1. Restart apahce
Sudo/etc/init. d/apache2 restart
2. Restart mysql
Sudo/etc/init. d/mysql restart
Now, the LAMP environment is configured successfully.
Installing LAMP in ubuntu has always been smooth.
Select "edit" and "mark the software package with the task group" in the new plan"
Select "lamp server"
Wait .......
Download .......
Prompt for mysql password
Generally, it is okay to set it in the ubuntu Chinese wiki.
Later, the system was reinstalled and LAMP was configured again. The problem occurred frequently .... Maybe it's because the previous configuration is not cleaned up.
During this holiday, I finally set up a local server. I found some tutorials in China are different from those in other countries by referring to ubuntu official help. I will summarize these differences:
1. Preparations
If LAMP is not installed in the system, run
Code:
Sudo apt-get update
If LAMP has been installed in the system before, ensure that apache2, php5, and mysql in the system are completely deleted. Search php5, apache2, respectively in the new software package manager, mysql deletes the installed software package and dependency package.
You can also use the command line
Code:
Sudo apt-get remove-purge apache2 apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libdbd-mysql-perl libdbi-perl unzip libnet-daemon-perl libplrpc-perl libpq5 mysql-client-5.0 mysql-common mysql- server mysql-server-5.0 php5-common php5-mysql
Sudo rm-R/etc/php5
Run:
Code:
Sudo apt-get autoremove
Sudo apt-get autoclean
2. Install LAMP
You can select lamp server in the new version or install it step by step.
Code:
Sudo apt-get install apache2
Sudo apt-get install php5
Sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
3. troubleshooting
1. apache2: cocould not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Code:
Sudo gedit/etc/apache2/conf. d/fqdn
Add:
Code:
ServerName localhost
Save and exit. Run the following command:
Code:
Echo "ServerName localhost" | sudo tee/etc/apache2/conf. d/fqdn
Terminal display:
Code:
ServerName localhost
Indicates that the setting is successful.
2. Set other folders to the local server.
In apache2, the default folder is/var/www.
This folder is owned by a Super User and cannot be written by normal users. You can modify the permissions of this folder.
Code:
Sudo chmod-R 777/var/www
You can also reset a folder:
Code:
Sudo cp/etc/apache2/sites-available/default/etc/apache2/sites-available/mysite
Edit configuration file
Code:
Sudo gedit/etc/apache2/sites-available/mysite
Modify the DocumentRoot in the configuration file to the new location you need, such as/home/username/www/
Replace
Save and exit
Run:
Code:
Sudo a2dissite default & sudo a2ensite mysite
Restart apache2
Code:
Sudo/etc/init. d/apache2 restart
Enter http: // localhost in the browser
3. The php file cannot be parsed. the browser prompts you to download the PHP file to be opened.
Run:
Code:
Sudo apt-get install libapache2-mod-php5
Sudo a2enmod php5
Code:
This module does not exist!
Then you need to completely delete the libapache2-mod-php5, and then reinstall it
Code:
Sudo apt-get remove-purge libapache2-mod-php5
Sudo apt-get install libapache2-mod-php5
Restart apache2
Code:
Sudo/etc/init. d/apache2 restart
Clear the browser cache and enter http: localhost
4. Install phpmyadmin
We recommend that you do not install it from the source.
Download the software package from the phpmyadmin website and decompress it to the local directory/var/www/phpmyadmin (/home/user/www/phpmyadmin)
Run the following command on the terminal:
Code:
Sudo cp/var/www/phpmyadmin/config. sample. inc. php/var/www/phpmyadmin/config. inc. php
Sudo gedit/var/www/phpmyadmin/config. inc. php
Find blowfish_secret and fill in any letter
$ Cfg ['servers'] [$ I] ['auth _ type'] = 'cooker ';
$ Cfg ['servers'] [$ I] ['host'] = 'localhost ';
$ Cfg ['servers'] [$ I] ['connect _ type'] = 'tcp ';
$ Cfg ['servers'] [$ I] ['compus'] = 'false ';
$ Cfg ['servers'] [$ I] ['extension'] = 'mysql ';
Save and exit
Install php5-mcrypt
Code:
Sudo apt-get install php5-mcrypt
Edit the php configuration file
Code:
Sudo gedit/etc/php5/apache2/php. ini
Add
Code:
Extension = php5-mcrypt.so
Save and restart apache2
Enter http://www.bkjia.com/phpmyadmin in your browser