Ubuntu Build Lamp

Source: Internet
Author: User
Tags php web server phpmyadmin fully qualified domain name

Share what the great God gave you.

Direct one command: Apt-get install apache2 mysql-server mysql-client php5 php5-gd php5-mysql


Set Ubuntu file to execute read and write permissions


After the LAMP is assembled and installed, the default settings for the PHP Web server root directory are:/var/www. Because of the security principle of Linux system, the file read and write permission in the directory is only allowed by root user, so we can't create a new php file in www folder or modify or delete it, we must first modify the read and write permission of the/var/www directory. In the interface manager through the right-click property cannot modify the file permissions, you have to execute the root terminal command: sudo chmod 777/var/www. You can then write to the HTML or PHP file. If the file permissions for 777 are not very clear, you can see in this article: what does the file permission 666 mean.


How to install Phpmyadmin-mysql database management


Using the interface Manager:


System--system management, new software package Manager, search phpmyadmin-> right-click Tag installation.


Or use a command directly: sudo apt-get install phpMyAdmin installation begins.


phpMyAdmin settings:


During installation, you will be asked to select Web Server:apache2 or LIGHTTPD, select apache2, press TAB, and then OK. You will then be asked to enter the MySQL database password for the setup password Password of the database ' s administrative user.


Then connect the phpMyAdmin with the apache2, take my example: the WWW directory is in the/var/www,phpmyadmin directory in/usr/share/phpmyadmin, so just 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.


Ubuntu LAMP How to configure Apache


1. Enable the Mod_rewrite module


Terminal command: sudo a2enmod rewrite


Restart Apache server: sudo/etc/init.d/apache2 restart


After the Apache restart we can test, in the/var/www directory to create a new file test.php, write code: Save, in the address bar input http://127.0.0.1/test.php or http://localhost/test.php, If the PHP configuration information appears correctly, it indicates that lamp Apache is working (remember to restart the Apache server and test again).


2. Set Apache support. htm. html. php


sudo gedit/etc/apache2/apache2.conf


or sudo gedit/etc/apache2/mods-enabled/php5.conf


In the open file, add


AddType application/x-httpd-php. php. htm. html.


The MySQL test for lamp configuration


The above php,apache have been tested, let us test the MySQL database is correctly enabled.


Create a new mysql_test.php under the/var/www directory:


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


if (! $link)


{


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


}


else echo "MySQL is configured correctly";


Mysql_close ($link);


?>


Save exit, enter http://127.0.0.1/mysql_test.php in the Address bar, show "MySQL is configured correctly" means OK, if not, restart the Apache server and try again.


Solve problems such as garbled characters in Firefox browser display


Above in the Firefox browser open mysql_test.php or phpMyAdmin test, if the Chinese garbled, it is the default language setting problem, the workaround is as follows:


Open Apache configuration file: Udo Gedit/etc/apache2/apache2.conf, at the end of the add: Adddefaultcharset UTF-8, if it is garbled, then UTF-8 instead of gb2312.


Restart Apache:sudo/etc/init.d/apache2 Restart re-refresh mysql_test.php Chinese characters are gone.


If you want to manually start Mysql:mysql-u root-p, enter the password as prompted.


If you restart Apache, it appears:


* Restarting Web server apache2


Apache2:could not reliably determine the server ' s fully qualified domain name, using 127.0.1.1 for ServerName


Apache2:could not reliably determine the server ' s fully qualified domain name, using 127.0.1.1 for ServerName


or modify the Apache configuration file: sudo gedit/etc/apache2/apache2.conf, at the end of the file set: ServerName 127.0.0.1


Several terminal commands frequently used by lamp components


Restart Apache:sudo/etc/init.d/apache2 restart


Restart Mysql:sudo/etc/init.d/mysql restart


Configuring Php.ini:sudo Gedit/etc/php5/apache2/php.ini


Configuring Apache2.conf:sudo gedit/etc/apache2/apache2.conf


Configuring My.cnf:sudo GEDIT/ETC/MYSQL/MY.CNF


PHP cgi:sudo/var/www/cgi-bin/

Ubuntu Build Lamp

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.