Installing LAMP in Linux and environment configuration and troubleshooting

Source: Internet
Author: User
Tags mcrypt fully qualified domain name
I. & nbsp; there is a very simple method to install LAMP in Linux: select "edit"> "use task group Edit software package" in the new Settings, select "LAMPSERVER" & nbsp;, and click "Apply" in the main window, now, the new version is automatically downloaded and installed.

1. installing LAMP in Linux has a very simple method:

Select "edit"> "use task group Edit software package" in the new IDE. select "lamp server" and click "Apply" in the main window, now, the new version will automatically download and install it. a prompt will be prompted to enter the mysql root user password.

2. after the installation is complete, it will be tedious testing and configuration:
1. test Apache input: http: // localhost/to see if It works appears

2. test MySQL input: sudo netstat-tap | grep mysql. the following line is displayed: tcp 0 0 localhost. localdomain: mysql *: * LISTEN-if the server cannot run normally, you can run the following command to start it: sudo/etc/init. d/mysql restart

3. test the PHP Ubuntu Apache root directory and add a test file test. php file in/var/www. Save and enter http: // 127.0.0.1/test in the address bar. php or http: // localhost/test. php. if the correct php configuration information appears, it indicates that LAMP Apache is working properly (remember to restart the Apache server before testing ).

III. configuration

1. configure PHP5

This configuration is not required.

2. configure mysql sudo gedit/etc/mysql/my. cnf has a major note here, because it only allows local access to the database by default. if necessary, you can enable bind-address 127.0.0.1 to restrict local access only, if you need access from other machines, comment out this sentence #.

3. in Ubuntu, if you modify the Apache website root directory DocumentRoot, you can see a 000-default file in the/etc/apache2/sites-enabled/Directory. if you open this file, DocumentRoot/var/www changes the path. restart the Apache2 service.

Now the LAMP configuration is complete.

4. install LAMP and install phpmyadmin after Configuration. phpMyAdmin is written in PHP and can be used to control and operate MySQL databases on the web. You can use phpMyAdmin to perform database operations, such as creating, copying, and deleting data. after installing phpMyAdmin, you do not need to use commands to operate mysql on the terminal.

Install phpmyadmin: download the software package from the phpmyadmin website, decompress it to the local directory/var/www/phpmyadmin, modify the configuration file, and run the following code on the terminal: sudo cp/var/www/phpmyadmin/config. sample. inc. php/var/www/phpmyadmin/config. inc. php sudo gedit/var/www/phpmyadmin/config. inc. php changes the following content in the configuration file (the content is not continuous and you can add the vacant content yourself ):

$ Cfg [blowfish_secret] = 123456;

$ Cfg [PmaAbsoluteUri] = http: // localhost/phpmyadmin;

Save and exit.

Then install the php5-mcrypt code: sudo apt-get install php5-mcrypt edit php configuration file code: sudo gedit/etc/php5/apache2/php. ini add code under extension: extension = php5-mcrypt.so save, restart apache2 input http: // localhost/phpmyadmin in the browser

5. 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 in this file: Code: ServerName localhost save, exit, execute the 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 super users and cannot be written by normal users. you can modify the code of this folder as follows: sudo chmod-R 777/var/www can also reset a folder: Code:

Sudo cp/etc/apache2/sites-available/default/etc/apache2/sites-available/mysite edit the 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/save and exit the execution: code: sudo a2dissite default & sudo a2ensite mysite

Restart apache2 code: sudo/etc/init. d/apache2 restart enter http: // localhost in the browser

3. unable to parse the php file, the browser prompts to download the php file to open execute: Code: sudo apt-get install libapache2-mod-php5 sudo a2enmod php5 if displayed:

Code: This module does not exist! Then we need to completely delete the libapache2-mod-php5, and then re-install 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 to clear the browser cache, and then enter http: localhost

4. solution 1: Use the Mysql administrator account to log in with phpmyadmin, click "import", and then click "Browse, find a file named create_tables. SQL in the scripts folder under The phpmyadmin folder. It is OK to import it.

Step 2: Open the libraries folder in the phpmyadmin folder, find the file named config. default. php, and open the file. Modify it. The modified content is not continuous. please modify it manually. do not copy it. Before modification:

$ Cfg [Servers] [$ I] [pmadb] = ";

$ Cfg [Servers] [$ I] [bookmarktable] = ";

$ Cfg [Servers] [$ I] [relation] = ";

$ Cfg [Servers] [$ I] [table_info] = ";

$ Cfg [Servers] [$ I] [table_coords] = ";

$ Cfg [Servers] [$ I] [performance_pages] = ";

$ Cfg [Servers] [$ I] [column_info] = ";

$ Cfg [Servers] [$ I] [history] = ";

$ Cfg [Servers] [$ I] [designer_coords] = ";

$ Cfg [Servers] [$ I] [tracking] = ";

Modified content:

$ Cfg [Servers] [$ I] [pmadb] = 'phpmyadmin ';

$ Cfg [Servers] [$ I] [bookmarktable] = 'PMA _ bookmark ';

$ Cfg [Servers] [$ I] [relation] = 'PMA _ relation ';

$ Cfg [Servers] [$ I] [table_info] = 'PMA _ table_info ';

$ Cfg [Servers] [$ I] [table_coords] = 'PMA _ table_coords ';

$ Cfg [Servers] [$ I] [pdf_pages] = 'PMA _ pdf_pages ';

$ Cfg [Servers] [$ I] [column_info] = 'PMA _ column_info ';

$ Cfg [Servers] [$ I] [history] = 'PMA _ history ';

$ Cfg [Servers] [$ I] [designer_coords] = 'PMA _ designer_coords ';

$ Cfg [Servers] [$ I] [tracking] = 'PMA _ tracking ';

Step 3: log out of phpmyadmin and log on again. Success!

5. set Apache support. htm. html. php sudo gedit/etc/apache2/apache2.conf or sudo gedit/etc/apache2/mod-enabled/php5.conf add AddType application/x-httpd-php to the open file. php. htm. html.

6. solve the problem of displaying Chinese garbled characters in the Firefox browser. if Chinese garbled characters appear in the test in the FireFox browser, the problem is caused by the default language settings. the solution is as follows:

Open the apache configuration file: sudo gedit/etc/apache2/apache2.conf, add: AddDefaultCharset UTF-8 at the end, if still garbled, then switch the UTF-8 to gb2312. Restart Apache: sudo/etc/init. d/apache2 restart and refresh mysql_test.php.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.