Parsing Aliyun configuration apache+php+phpmyadmin+mysql in ubuntu12.04 environment

Source: Internet
Author: User
Tags chmod ini mysql in php file file permissions mysql database phpmyadmin aliyun

The relevant IP settings used in this tutorial should be modified in your environment.
Update apt-get before using because the server is basically a bare system
Apt-get Update;
Apt-get upgrade;
1 We use the root account to install, first switch to the root account, enter the command:
sudo su

2 Installing MySQL 5
Enter command:
Apt-get Install Mysql-server mysql-client
The root account password needs to be set during installation and the following prompts are made:
New password for the MySQL "root" user:repeat password for themysql "root" User:

3 Installation Apache2
Enter command:
Apt-get Install Apache2
In the browser enter your server address listed in http://192.168.0.100 to see if Apache2 is working, if shown (itworks!), the description has been worked.
Apache in Ubuntu the default document root is/var/www, configuration file/etc/apache2/apache2.conf, additional Configuration Storage subdirectory/etc/apache2 such as/etc/apache2/mods-enabled ( For the Apache module,/etc/apache2/sites-enabled (for virtual hosts), and/ETC/APACHE2/CONF.D.

4 Installation PHP5
to install the PHP5 and Apache PHP5 modules:
Apt-get Install PHP5 LIBAPACHE2-MOD-PHP5
(if there are installed content is not found, need to update Apt-get, execute apt-get Update)
And then restart Apache:
/etc/init.d/apache2 restart

5 test PHP5/Can build a probe page
vi/var/www/info.php
Enter the following:
<?php
Phpinfo ();
?>
Then open the browser access (http://127.0.0.1/info.php):
You can see some of the modules that have been supported.

6 get MySQL support for PHP5
We need to install Php5-mysql, check out PHP5 's module
Apt-cache search Php5-mysql
Php5-mysql-mysql module for PHP5
Php5-mysqlnd-mysql module for PHP5 (Native Driver)
and then install the required modules, such as the following Command:
apt-get Install php5-mysql
apt-get install php5-mysqlnd
sudo apt-get install php5 libapache2-mo D-PHP5 php5-cgi php5-cli php5-common php5-curl php5-gd php5-mysql php5-pgsql
sudo a2enmod php5

What is the difference php5 module, install PHP5 module, Ubuntu php5 installation module is also very convenient
the following modules choose to install, some modules are not necessarily correct
Apt-get install Php5-mysql php5-curl PHP5-GD Php5-intlphp-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mingphp5-ps Php5-pspell php5-recode php5-snmp Php5-sqlite php5-tidyphp5-xmlrpc php5-xsl
Reboot Apache2:
/etc/init.d/apache2 Restart
then brush your HTTP://127.0.0.1/ Info.php viewing module support has not been added.

7 phpmyadmin
install phpMyAdmin to manage MySQL:
apt-get install phpMyAdmin
phpMyAdmin settings:
requires the Web server:apache2 or lighttpd to be selected during installation, select Apache2, press the TAB key, and then determine. You will then be required to enter the MySQL database password to connect the settings to the password Password of the DB ' s administrative user. The
then connects phpMyAdmin with Apache2, taking my example: the WWW directory is/var/www,phpmyadmin in the/usr/share/phpmyadmin directory, so use the command: sudo ln-s/usr/ Share/phpmyadmin/var/www Establish a connection.
phpMyAdmin test: Open Http://localhost/phpmyadmin in the browser address bar.
phpMyAdmin Access Address: http://127.0.0.1/phpmyadmin/

The basic components of lamp above are installed, let's look at some other settings:
Set the Ubuntu file to perform read and write permissions
after Setup is installed, the PHP network server root default setting is:/var/www. Because of the security principle of Linux system, the file read-write permission in the modified directory is only allowed to operate by the root user, so we cannot create the php file in the WWW folder, nor modify and delete it, we must first modify the read and write permissions of the/var/www directory. You cannot modify file permissions in the interface Manager by right-clicking the property, and you must execute the root terminal command: sudo chmod 777/var/www. You can then write HTML or PHP files. If the file permissions indicated for 777 are not very clear, refer to the chmod command.

Configure Apache
1 enable mod_rewrite module
terminal command: sudo a2enmod rewrite
Restart the Apache server: Sudo/etc/init.d/apache2 Restart
Apache Restart we can test, in the/var/www directory to create a new file test.php, write code: <?php phpinfo (),?> save, in the address bar input HTTP://127.0.0.1/ test.php or http://localhost/test.php, the correct appearance of the PHP configuration information indicates that the lamp Apache is working (remember to reboot the Apache server and test again).

2 set Apache support. htm. html. php
sudo gedit/etc/apache2/apache2.conf
In the open file, add
AddType application/x-httpd-php. php. htm. html.
Configure MySQL Test
the above php,apache have been tested, and then we test the MySQL database has been properly enabled.
Create a new mysql_test.php in the/var/www directory:

Copy Code code as follows:


&lt;?php


$link = mysql_connect ("localhost", "root", "020511″");


if (! $link)


{


die (' Could not connect: '. Mysql_error ());


}


else echo "MySQL is properly configured";


mysql_close ($link);


?&gt;


Save exit, enter http://127.0.0.1/mysql_test.php in the Address bar, show "MySQL has been properly configured" means OK, if not, restart the Apache server and try again.
Configure PHP5
sudo gedit/etc/php5/apache2/php.ini modify allows maximum memory usage, find
Memory_limit = 8M modified to
Memory _limit = 32M
Modify allow maximum upload size, find
Upload_max_filesize = 2M Modify to
Upload_max_filesize = 8M
allow MySQL and GD modules, Check to see if the file contains the following code, if not added on. (The default is to add at the end of the configuration file, check for just in case)
Extension=mysql.soextension=gd.so Save and close the file.
If garbled characters occur, the workaround is as follows:
Configure Apache character encoding:
sudo gedit/etc/apache2/conf.d/charset
Change the contents to Adddefaultcharset UTF-8
Configure PHP character encoding:
sudo gedit/etc/php5/apache2/php.ini
Find
Code:
Default_charset = "Iso-8859-1″
" to
Code:
Default_charset = "Utf-8″
then restart Apache:
Code:
sudo/etc/ Init.d/apache2 Restart

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.