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, first look at the PHP5 module
Apt-cache Search Php5-mysql
Php5-mysql-mysql Module for PHP5
Php5-mysqlnd-mysql module for PHP5 (Native Driver)
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-mod-php5 php5-cgi php5-cli php5-common php5-curl php5-gd php5-mysql php5-pgsql
sudo a2enmod php5
What PHP5 module, the installation of PHP5 modules, Ubuntu php5 installation module is still very convenient
The following modules choose to install themselves, 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
Reboot Apache2:
/etc/init.d/apache2 restart
Then brush your http://127.0.0.1/info.php to see if the module support has been added.
7 phpMyAdmin
Install phpMyAdmin to manage MySQL:
Apt-get Install phpMyAdmin
phpMyAdmin Settings:
During installation, you will be asked to select the Web server:apache2 or LIGHTTPD, 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.
Then connect phpMyAdmin with Apache2, take my example: www directory in/var/www,phpmyadmin in/usr/share/phpmyadmin directory, so use 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 are installed, let's look at some other settings:
set Ubuntu file to perform read and write permissions
After lamp setup is installed, the default setting for the PHP network server root is in:/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 Apache server: sudo/etc/init.d/apache2 restart
After the Apache reboot we can test, in the/var/www directory to create a new file test.php, write code: <?php phpinfo ();?> save, enter http://127.0.0.1/test.php or HTTP in the address bar ://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:
<?php
$link = mysql_connect ("localhost", "root", "020511″");
if (! $link)
{
Die (' Could not connect: '. Mysql_error ());
}
else echo "MySQL is properly configured";
Mysql_close ($link);
?>
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 revision instead
Memory_limit = 32M
Modify allow maximum upload size, find
Upload_max_filesize = 2M revision instead
Upload_max_filesize = 8M
Allow MySQL and GD modules to check whether the file finally 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 there are garbled, the solution is as follows:
To configure the Apache character encoding:
sudo gedit/etc/apache2/conf.d/charset
Change the contents to Adddefaultcharset UTF-8
To Configure PHP character encoding:
sudo gedit/etc/php5/apache2/php.ini
Found it
Code:
Default_charset = "Iso-8859-1″
To
Code:
Default_charset = "Utf-8″
And then restart Apache:
Code:
Sudo/etc/init.d/apache2 restart