Ubuntu 12.04 Construction of PHP Environment (LAMP)--Non-compiled

Source: Internet
Author: User
Tags phpinfo phpmyadmin

1, first open the command line, switch to root identity, to obtain the latest package
Su Root

sudo apt-get install update


2. Install MySQL Database
sudo apt-get install mysql-server mysql-client
In order to prompt for the database password, and then enter, then there are prompts, and then repeat the input once, and then enter the final installation of the last database test if the installation is successful, see welcome information OK
Mysql-uroot-p
3. Install Apache Server
sudo apt-get install apache2 after the installation is complete test, enter in the browserhttp://localhost/Orhttp://127.0.0.1If "It works!" appears That means the installation is successful. Note: The default document root directory for Apache is the/var/www directory on Ubuntu, the config file is/etc/apache2/apache2.conf, the configuration is stored in subdirectories in the/etc/apache2 directory.
General Web page files can be dropped directly into the/var/www directory, in the browser can be accessed. The default is index.html, so enter 127.0.0.1 or localhost in the browser address bar to access the
4, install PHP, and let Apache support PHP
sudo apt-get install php5 libapache2-mod-php5 reboot Apache server after installation is complete
Sudo/etc/init.d/apache2 Restart then go to Apache's www folder (default in/Var), create phpinfo.php file
Cd/var/www
Ls
VI phpinfo.php
and write it in the phpinfo.php file.
<?php
Phpinfo ();
?>
But we will probably not be able to save after writing, because we do not have permission to write to the WWW directory file, so we first authorize all the files under the WWW folder, and then we write the code.
chmod 777/var/www/finally entered in the browserhttp://localhost/phpinfo.php, you can see the information of PHP, but it is not connected to the database, and the corresponding modules are not installed, then see the 5th step
5. Installed Php-mysql package and some other common modules
sudo apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5- Ming Php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
And then visit againhttp://localhost/phpinfo.php(It's a good idea to reboot Apache first), then we can see the module we added 6, install phpMyAdmin
We can easily manage our MySQL database with phpMyAdmin.
sudo apt-get install phpMyAdmin
The following selection will appear during the installation, asking if you want to configure phpMyAdmin, we select "YES" and then need to enter the MySQL password until the installation is complete.
Since the installation path for phpMyAdmin is/usr/share/phpmyadmin/by default, we move the phpMyAdmin to the/var/www/directory:
sudo mv/usr/share/phpmyadmin/var/www
And thenHttp://localhost/phpmyadminAccess to the phpMyAdmin login interface Note: phpMyAdmin will be installed automatically under/usr/share/phpmyadmin, you need to copy the phpMyAdmin folder to the/var/www directory
So use the command: sudo cp/usr/share/phpmyadmin//var/www/-A, move the folder phpMyAdmin to the/var/www directory
At this point you can test, the browser input 127.0.0.1/phpmyadmin can see the interface to manage the database.
Note: If you want someone else to access your site, you need to change the access permissions for the/var/www folder, command: chmod 777/var/www lamp setup Environment installation process

First Step installation Apache2

sudo apt-get install apache2
Step two Install the PHP module
sudo apt-get install php5
Step three install MySQL
sudo apt-get install Mysql-server
sudo apt-get install mysql-client
Fourth Step other module installation
sudo apt-get install LIBAPACHE2-MOD-PHP5
sudo apt-get install Libapache2-mod-auth-mysql
sudo apt-get install Php5-mysql
sudo apt-get install PHP5-GD
Fifth Step test Apache is working properly
Open the browser and enter localhost to see if there is an IT works! page display. Directory is/var/www
Sixth Step Modify Permissions/var/www
sudo chomod 777/var/www
Seventh Step installation phpMyAdmin
sudo apt-get install phpMyAdmin
Select Apache2 during the installation process and click OK. The next option is to configure the database and enter the password.
Eighth Step Test phpMyAdmin
sudo ln-s/usr/share/phpmyadmin/var/www
Then run http://localhost/phpmyadmin directly to see if there is any database management software appearing.
Configuration process

First step enabling the Mod_rewrite module

sudo a2enmod rewrite
Restart Apache server: sudo/etc/init.d/apache2 restart or sudo service apache2 restart
The second step is to set Apache support. htm. html. php
sudo gedit/etc/apache2/apache2.conf&
Add the following sentence: AddType application/x-httpd-php. php. htm. html
Third Step Test PHP Web page
Edit the mysql_test.php code as follows:
<?php
$link = mysql_connect ("localhost", "root", "password");
if (! $link)
Die (' Could not connect: '. Mysql_error ());
Else
echo "Mysql configuration is correct!";
Mysql_close ($link);
?>
Access http://localhost/mysql_test.php display ' MySQL is configured correctly ' on behalf of the correct configuration.
Fourth step third step here appeared garbled after solution
Open config file sudo gedit/etc/apache2/apache2.conf&
Add the following code: Adddefaultcharset UTF-8
To this end, configure OK.

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.