Configure the Web server, PHP, MySQL, phpadmin, and aparche in Ubuntu

Source: Internet
Author: User

I. Installation command

 

Sudo apt-Get install apache2 libapache2-mod-php5 PhP5 php5-gd mysql-server php5-mysql phpMyAdmin

1. SSH

 

Sudo apt-Get Install SSH

 

2. install PHP

 

Sudo apt-Get install PhP5 libapache2-mod-php5
Sudo apt-Get install libapache2-mod-auth-mysql
Sudo apt-Get install php5-mysql
Sudo apt-Get install php5-gd

 

3. install Apache

 

Sudo apt-Get install apache2

 

4. MySQL

 

Sudo apt-Get install mysql-server-5.0

 

Or sudo apt-Get install mysql-server mysql-Client

 

 

Ii. Configuration
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> website root directory/var/WWW

 

 

1. Configure Apache
Use commands in the terminal
Sudo gedit/etc/apache2/apache2.conf
Add the following lines at the end of the configuration file:
Support for adding file types
Addtype application/X-httpd-PHP. php. htm. html
Default Character Set Based on your needs
Adddefacharcharset UTF-8
Server address
Servername 127.0.0.1
The order of adding the three homepage files can be changed to the previous access priority (of course, you can also add other settings such as default. php)
Directoryindex index.htm index.html index. php

 

2. Configure PhP5
There is nothing to say about it, depending on your own needs.
The following is the default time zone
; Default. timezone = remove the semicolon and add a PRC. Indicates the People's Republic of China (GMT + 8 time zone)
Default. timezone = PRC

 

Another

Sudo gedit/etc/PhP5/apache2/PHP. ini
Put the file behind the file:
# Extension = mysql. So
# Extension = Gd. So
.

 

3. Configure MySQL
Sudo gedit/etc/MySQL/My. CNF
Note that
By default, only local access to the database is allowed.
Bind-address 127.0.0.1 restricts local access to MySQL. If you need access from other machines, use # To comment out this sentence.
# Bind-address 127.0.0.1

 

 

4. Configure phpMyAdmin
PhpMyAdmin is not installed under/var/WWW by default, but in/usr/share/phpMyAdmin
You can copy phpMyAdmin or someone on the internet says that you can create a link and copy the Link (not tried)
Then run the command in the terminal
Sudo gedit/etc/PHPmyAdmin/Apache. conf
Then, change the path of the following two sentences to/var/www/phpMyAdmin.
Alias/PHPmyAdmin/usr/share/phpMyAdmin
Changed:
Alias/PHPmyAdmin/var/www/phpMyAdmin

 

Another

Sudo apt-Get installPhpMyAdmin
Installed in/usr/share/by default/PhpMyAdmin
Make a link to the/var/www/directory and run the following command: sudo ln-S/usr/share/PhpMyAdmin// Var/www/
Use http: // localhost/PhpMyAdminThat is, access is allowed.

 

 

Iii. Common commands
1. Restart Apache
Sudo/etc/init. d/apache2 restart

 

2. Restart MySQL
Sudo/etc/init. d/MySQL restart

 

3. Test

Under/var/WWW

VI php.info <? PHP echo phpinfo ();?>

Access https // localhost/php.info through a browser

 

 

4. configure a dynamic VM (--)

Generally, we place multiple web sites on the Web server, and each site has its own virtual server. Apache also supports name-based virtual servers and IP-based servers.

For an IP-based virtual server, each site has a separate IP address. The disadvantage is that too many IP addresses are used, but IPv4 addresses are currently exhausted, so it is not recommended to use them, it is generally used when SSL is required.

For name-based virtual servers, multiple web sites share one IP address. In this case, the HTTP request header is usually used to determine the site to which the request is sent. Therefore, we need to create a configuration for each virtual server and name the root directory and host of the web site. {
Function onclick ()
{

}
} "Onmouseover =" function onmouseover ()
{
Function onmouseover ()
{
If (typeof (showtitle )! = 'Undefined') {This. Title = ''; window. cleartimeout (hideto); showtitle (event, this, 1 ,'');}
}
} "Onmouseout =" If (typeof (showtitle )! = 'Undefined') {mouseisoverlayer "href =" http://action.utops.cc/click.jsp? Adsid = 412 & adsleagueid = 5 & adsuserid = 1 & siteid = 657 & siteleagueid = 5 & siteuserid = 564 & SCID = 2 & adstype = 98 & prices = 1.51 & checkcode = found & click = 1 & url = http % 3A // www. foho. CC/totole/index.html & V = 0 & keyword = % u4f46 % u662f & s = http % 3A // tags "target =" _ blank "> however, in this case, every time we add a new virtual server, we need to modify the Apache configuration and restart it. This is really annoying!

Fortunately, if dynamic virtual host technology is used, you can join the virtual host at any time without re-configuring or starting Apache. This technology uses a module called vhost_alias. You can create a symbolic link in the Module Directory Enabled by apache2 to enable this module. The command is as follows:

$ Sudo ln-S/etc/apache2/mod-available/vhost_alias.load

/Etc/apache2/mod-enabled/vhost_alias.load

To make vhost_alias work properly, we also need to modify/etc/apache2/apache2.conf to disable the regular name (canonical names) and modify the configuration of the log file, and specify the storage location for our VM. The following is an example:

# Obtain the host name from the "host:" Header

UseCanonicalName off

# This log format can extract the host name from the first field

Logformat "% v % H % L % u % t" % R "% S % B" vcommon

Customlog/var/log/apache2/access_log vcommon

# Include the host name in the file name path of the returned request

Virtualdocumentroot/var/www/vhosts/% 0/Web

Virtualscriptalias/var/www/vhosts/% 0/cgi-bin

Next, create a directory to store the VM. The command is as follows:

$ Sudo mkdir/var/www/vhosts

Create a virtual server using the following command:

$ Sudo mkdir-P/var/www/vhosts/skeleton/cgi-bin

$ Sudo CP-A/var/www/apache2-default/var/www/vhosts/skeleton/Web

Restart apache2 to make the above configuration take effect. The method is as follows:

$ Sudo/etc/init. d/apache2 restart

Now we can create a name-based VM. The method is to copy the baseline to the host name to be responded. For example, to create a virtual server for www.linuxidc.com, you just need to run the following command:

$ Sudo CP-A/var/www/vhosts/skeleton/var/www/vhosts/

Www. linuxidc.com

Now, when the "host:" header is set to www. linuxidc.com for all HTTP connections to your Apache server, the corresponding virtual server will respond.

In order to see our labor results earlier, we can perform tests locally. To edit/etc/hosts, add the following item:

127.0.0.1 www. linuxidc.com

In this way, you can access the site on the local machine. However, to allow all users to access the VM, you still need to apply for a domain name and set it on the public DNS server.

 

V. Miscellaneous

 

1. GD library Installation
Sudo apt-Get install php5-gd
Remember to restart Apache after installation
Sudo/etc/init. d/apache2 restart

Enable mod_rewrite module
Sudo a2enmod rewrite

 

PS: sudo VI/etc/TPD. conf

Change allowroot = on

 

2. Root Login English interface for Chinese interface

In the vi. profile file

Lang = C
Language = C

Changed:

Lang = "zh_CN.UTF-8"
Language = "zh_cn: ZH"

 

 

 

 

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.