Ubuntu Build Apache+php+mysql

Source: Internet
Author: User
Tags phpinfo

1. Install Apache Service

sudo apt-get install apache2

Run the following command to restart under: sudo/etc/init.d/apache2 restart

2, installation PHP5

Installing the PHP5 and Apache PHP5 modules

sudo apt-get install php5

sudo apt-get install LIBAPACHE2-MOD-PHP5

Reboot under Apache

Sudo/etc/init.d/apache2 restart

Test to see if it takes effect.

sudo gedit/var/www/phpinfo.php

<?php   

echo phpinfo();

?>

Save Run http://127.0.0.1/phpinfo.php

3. Installation Mysql
sudo apt-get install mysql-server mysql-client

4, let Apache, PHP support MySQL

sudo apt-get install Libapache2-mod-auth-mysql

sudo apt-get install Php5-mysql

Sudo/etc/init.d/apache2 restart

The APACHE+PHP+MYSQL environment is now complete.

Then install the required modules, such as the following command:

sudo apt-get install php5-mysql php5-curl php5-gd php5-intl 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

Restart Apache2:

/etc/init.d/apache2 restart

Then open http://127.0.01/phpinfo.php to see if the module support has been added.

5, Installation phpMyAdmin
Install phpMyAdmin to manage MySQL:

sudo apt-get install phpMyAdmin

Configure phpMyAdmin
phpMyAdmin default is not installed under/var/www, but in/usr/share/phpmyadmin

You can create a link and then copy the link to the past:

sudo ln-s/usr/share/phpmyadmin/var/www

Then run the command in the terminal

sudo gedit/etc/phpmyadmin/apache.conf

Then put the following sentence:

Alias/phpmyadmin/usr/share/phpmyadmin

Switch

Alias/phpmyadmin/var/www/phpmyadmin

Two. Appendix
1> Apache configuration file path/etc/apache2/apache2.conf
2> php.ini Path/etc/php5/apache2/php5.ini
3> mysql configuration file path/etc/mysql/my.cnf
4> phpmyadmin configuration file path/etc/phpmyadmin/apache.conf
5> Web site root directory/var/www

1. Configure Apache
Using commands in the terminal
sudo gedit/etc/apache2/apache2.conf
Add the following lines to the last side of the configuration file:
Add File type Support
AddType application/x-httpd-php. php. htm. html
Default character set according to your needs
Adddefaultcharset UTF-8
Server address
ServerName 127.0.0.1
Add first page file three order can change the previous access priority (of course you can also add other such as default.php)
DirectoryIndex index.htm index.html index.php

2. Configure PHP5
This is nothing to say, according to the individual's own needs
The following is the default time zone
;d efault.timezone= Remove the preceding semicolon and add a PRC. The People's Republic of China (Gmt+8 time zone)
Default.timezone= PRC
3. Configure MySQL
sudo gedit/etc/mysql/my.cnf
Here's a place to watch.
Because the default is to allow only local access to the database if you have to open it.
Bind-address 127.0.0.1 This sentence is limited to local access to MySQL only. If there is a need for other machine access put this phrase in the # comment out
#bind-address 127.0.0.1

Common commands
1. Restart Apache
Sudo/etc/init.d/apache2 restart
2. Restart MySQL
Sudo/etc/init.d/mysql restart


Installation of GD Library
sudo apt-get install PHP5-GD
Remember to restart Apache after loading
Sudo/etc/init.d/apache2 restart
Enable the Mod_rewrite module
sudo a2enmod rewrite

Related Article

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.