Install and configure LAMP in Ubuntu to test PHP locally

Source: Internet
Author: User
Tags php development environment

Recently, my main operating system has changed to Ubuntu. I feel that Linux supports php BETTER THAN windows. Installing and testing wordpress templates and plug-ins locally is much easier than remote virtual hosts. I recently used my winter vacation time to study php. As a pseudo-tech man studying science, I usually don't have much time to spend. It is good to take a long vacation. Let's talk about how to set up the LAMP php development environment (Linux-Apache-MySQL-PHP.

First, install the LAMP kit, set the settings correctly, and finally install the php IDE.
1. Install the LAMP package in Ubuntu.
There are many ways to solve the same problem in Ubuntu. I am a cainiao, so I chose the simplest method.
Enter
Sudo tasksel
Then a software package interface will appear, move the cursor to the LAMP server, press the space, and then select this item. Other items can be deselected, and click OK. Next, you will be asked to enter the password of the root user of MySQL. Remember to use it later when installing the php program. Then install LAMP, which is simple. Enter http: // 127.0.0.1 in the browser and test apache2.
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
It indicates that apache2 has been installed. You can also test MySQL and PHP5. I will not explain how to test it here. Generally, the webpage root directory is under/var/www. Some friends may encounter a situation where they cannot parse php correctly. when they enter the home page, they will prompt whether to download and save the php file. In this way, you can restart apache first.
Sudo/etc/init. d/apache2 restart
Use
Sudo apt-get install libapache2-mod-php5
Sudo/etc/init. d/apache2 restart
Sudo a2enmod php5
It is used to install this module and restart apache to solve the problem.
2. Set Linux-Apache-MySQL-PHP correctly.
The first is the permission of the/var/www directory. You can use the following command to add permissions:
Sudo chown-R current user name/var/www
To make it easier to use LAMP, We need to install phpMyAdmin and php5-mcrypt.
Download the latest phpmyadmin and www.phpmyadmin.net from the official website.

Download the package and decompress it to/var/www/phpmyadmin. sample. inc. php is renamed config. inc. php, edit the file, find blowfish_secret, and enter any characters between the quotation marks to save the file.
Run the following command to install the php5-mcrypt; otherwise, 'cannot load the mcrypt extension while logging on to phpmyadmin. Check your PHP configuration. 'Error
Sudo apt-get install php5-mcrypt
Next, edit the php configuration file.
Sudo gedit/etc/php5/apache2/php. ini
Add at the end of the file
Extension = php5-mcrypt.so
This completes the configuration.
Common Errors:
If the following error occurs when http: // 127.0.0.1/phpmyadmin is enabled
Wrong permissions on configuration file, shocould not be world writable!
This is because the permission for the phpmyadmin folder is 777, which is not secure and needs to be changed to 755.
Use commands
Sudo chmod-R 755/var/www/phpmyadmin
If you cannot add a database in myphpadmin, it means that the current user is not in the mysql group. You can go to system-system management-user and group, click to change, and enter the password, add the current user to the mysql group to solve the problem.
3. install and use the integrated Development environment of php in Ubuntu, And the PHP Development Tools Project of eclipse
Go to http://www.eclipse.org/pdt/to download the latest version.
In fact, there are still a lot of php IDE that can be used in Ubuntu, except that eclipse is a free software, and eclipse is used in python before, it feels really good. As for Zend Studio, it is said that it is very powerful. You can try it.

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.