Install Ubuntu and build a PHP development environment (LAMP)

Source: Internet
Author: User
Tags php development environment php mysql php mysql extension phpinfo vmware fusion

One. Install Ubuntu

1. Install the virtual machine: because I am the MAC system virtual machine Select VMware Fusion, can be downloaded directly online, and then find a registration code on the Internet, or only 30 days trial.

2. Install the operating system: Here I choose Ubuntu 12.04.5, which is a slightly stable release (LTS); it is not difficult to install, there are a few questions to note:

(1). The boot setting is set to the default entry command line setting:

sudo vim/etc/default/grub

Put code: grub_cmdline_linux_default= "Quiet Splash"
Instead: grub_cmdline_linux_default= "quiet splash text" or change quiet splash directly to test


And then sudo update-grub and restart it.

(2). I am in the local SSH landing Ubuntu, so here you also want some settings:

First, the command line ifconfig to see the system immediately assigned IP, in the local ping IP to see if the network can be connected;

Again in the native SSH [email protected] landing, which is likely to error: Connection refused refused to access the landing,

One reason is to open a firewall, command line sudo iptables–l look at the wall settings, the general default firewall is closed;

The second reason is that when installing Ubuntu, where Ssh-server is not installed by default, command line Ps–ef | grep sshd to see if there is an sshd

If it does not appear, download a bit of ssh-server:

sudo apt-get install Ssh-server

Re-ps–ef | grep sshd looks OK;

Summary: Install the virtual machine and still relatively simple, I am here to use the auto-assigned IP, you can also configure the IP and so on.

Two. Installing Apache2

1. Installation:

sudo apt-get install apache2

Then wait for the installation to complete, after installation is enabled by default, you can use the following command to stop/start/restart the service:

sudo apachectl stop/start/restart or sudo service apache2 Stop/start/restart

2. Configure httpd.conf:

Open httpd.conf:

sudo vim/etc/apache2/httpd.conf

Write as follows:

ServerName localhost

Then enter the previously assigned address in your local browser, carriage return, the It works! appeared; Apache is installed, here Apache's default Web folder is/var/www; You can go to the/etc/apache2/sites-enabled/000-default file to modify it.

Three. Install PHP

1. Install PHP5 and LIBAPACHE2-MOD-PHP5:

sudo apt-get install php5 libapache2-mod-php5

Here libapache2-mod-php5 is Apache parsing PHP, installed after the appearance of the installation is successful:

Here we write the PHP version, php.ini file location information, etc.

2. View Phpinfo:

sudo vim/var/www/phpinfo.php

Write: <?php phpinfo ();? >

Local browser input: After ip/phpinfo.php, you can see the configuration information of PHP.

3. Install the PHP extension:

sudo apt-get install php5 Press the TAB key to appear:

Can be installed as needed, for example I installed the GD Gallery, Curl Extension, memcache and memcached extensions:

sudo apt-get install php5-gd php5-curl php5-memcache php-memcached

4. View the PHP extension Pack and configuration file:

Dpkg-l PHP5

cd/etc/php5/

We see three folders under PHP config file path/etc/php5/

These three are all configuration files, in fact, apt-get the PHP configuration file for the sake of clear modularity, which:

Apache2 inside the php.ini is the web side is the browser runtime configuration files;

The php.ini inside the CLI is the configuration file when the command line runs or the shell script runs;

CONF.D inside the *.ini file is some additional extension configuration, it is generic, so in the Apache2 and CLI also has its soft chain;

Four. Install MySQL

1. Install MySQL

sudo apt-get install mysql-server mysql-client php5-mysql

The installation process will let you enter two times the root account password, here the MySQL and php MySQL extension are installed;

2. Start/stop MySQL:

sudo stop/start MySQL

3. Log in to MySQL:

Mysql-uroot-p

Enter the password you just set to enter MySQL.


4.php access to MySQL:

Create a new mysql.php file in/var/www/, such as:

Local browser Run mysql.php:

Summary: At this point, the PHP development environment is completed, here is the approximate process of building, remember, we install before we must know what is installed, what role, where installed, there is no configuration files, where the configuration file, as long as we clear these, then build the environment will be very easy, Occasionally encountered some problems can be found on the Internet to solve the solution, OK, with a period of time PHP, today to do a small summary.

Install Ubuntu and build a PHP development environment (LAMP)

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.