Lamp Environment Configuration

Source: Internet
Author: User
Tags mcrypt php write

Ubantu environment configuration lamp is relatively simple

I use the 14.0.4. Connect to the server with Xshell

If it is not the root user, the Sudo,root user is not required before the command instruction

1. Installing Apache

Apt-get install apache2 This is the instructions for installing the Apache server, in the middle select [y/n], select Y to confirm

If there is a 404 error in the middle, indicating that the resource to be obtained is not in the place you visited, this time should be updated, apt-get instal update to update, and then execute the previous instruction

Enter your own IP address in the browser to view, as follows

2. Install PHP

Apt-get install PHP5 This is the instructions for installing PHP, in the middle select [y/n], select Y to confirm

The default installation path is var/www/html with the LL command to view the files inside the folder that already has a file index.html file, which is the initial page of Apache

At this point in the HTML folder to run VI phpinfo.php to create a php file (the file name of its own settings), which is to enter the edit file mode

Enter <?php phpinfo () on the inside; Press ESC to exit insert mode and back to command line mode

Input: Wq return to save file

Enter your IP address in the browser/phpinfo.php display as shown, the PHP installation is successful

3. Install MySQL

Apt-get install Mysql-server first installed MySQL server

Intermediate input y, then enter the database password, repeat two times

Apt-get Install mysql-client Database client

Test MySQL after successful installation

Execute MySQL command show databases; show database

Use MySQL; select MySQL Database

Show tables; display table, desc user; Select User data table;

Test Database Installation

Installation of the 4.php_mysql extension

Apt-get install php5-mysql mysql extension

Restart Apache Service apache2 restart

This time execution Phpinfo view appears as shown below to illustrate the successful installation

To test whether the Php_mysql plugin was successfully installed

Edit a PHP file locally (named mysqlconn.php)

Content:

<?php
$link =mysql_connect (' localhost ', ' root ', ' root ');
if ($link) {
echo "Success";
}else{
echo "Falied";
}

Download FileZilla This software to upload the file, create a new site by process configuration, and then drag the file into the directory
If you do not have permission (that is, you are not uploading as root user), then execute command line sudo chmod-r 777/var/www/html the HTML folder open in Xshell.
Then upload it again.
Enter your IP address on the browser/mysqlconn.php appears success Description Php_mysql configuration succeeded


Installing the PHP-GD Library
Apt-get Install PHP-GD (note to navigate to the root directory and then operate)
Restart Apache Server service Apache2 restart

Testing the GD Library
Create file phpgd.php write to the following file
$im =imagecreate (200,200);
$BG =imagecolorallocate ($im, 0,255,255);
Imagefill ($im, 0,0, $BG);
Header (' content-type:image/jpeg; Charset=utf-8 ');
Imagejpeg ($im);
Imagedestroy ($im);

To the root directory open IP address/phpgd.php

Output a square image to illustrate the introduction of success

Php-curl Installation

Apt-get Install Php5-curl Installation

Service Apache2 Restart Restart server

Detect if Curl installation is successful

New File phpcurl.php

Write the following code

<?php
$curl =curl_init ();
$url = "http://www.baidu.com";
curl_setopt ($curl, Curlopt_url, $url);
curl_setopt ($curl, curlopt_returntransfer,1);
curl_setopt ($curl, curlopt_header,0);
$im =curl_exec ($curl);
$info =curl_getinfo ($curl);
if ($info [' Http_code ']==200) {
Print_r ($im);
}
else{
echo "Curl_error:". Curl_error ($curl);
}
Curl_close ($curl);

Put it in the root directory of the file
Connect IP address/phpcurl.php Connect to Baidu then the success of Curl Import


Php-mcrypt Installation
Apt-get Install Php5-mcrypt installation is not yet found in Phpinfo MCrypt
You should also modify the php.ini file to locate the extension keyword in the php.ini file found in the Etc/php5/apache2 directory
Add a extension=xxxx.so part to the
Extension=mcrypt.so Saving can be
Service Apache2 Restart now looks for MCrypt in Phpinfo to find



Lamp Environment Configuration

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.