The LAMP combination is preferred for PHP development and runtime environments, that is, Linux + Apache + Mysql + Php/Perl/Python, which can optimize the performance of the server. For example, installing and setting up the LAMP environment in Ubuntu on a Chinese computer? Ubuntu9.10 is based on the Linux kernel and is ready for use in Linux. Running the Ubuntu LAMP Server package can easily implement the same installation and setting of Apache, Mysql, and Php in Linux, and it is no longer necessary to install and set them one by one.
In Ubuntu, how does one install the LAMP component?
Exercise the Ubuntu interface Manager:
System-> System Management-> New Software Package Manager-> edit-> exercise obligation symbol grouping software package-> LAMP Server (check box) -> OK-> return to the previous window and click application (or System-> Administration-> Synaptic Package Manager-> Edit-> Mark packages by Task-> LAMP Server-> OK). Then the system will take the initiative to download and install the lamp environment software package, just a few minutes to complete the download. In the installation process, you must set the password of the Mysql root Account. Other lamp environment components are also updated to the latest version when the Ubuntu system is upgraded.
After the installation test is completed: Open the Firefox viewer and enter 127.0.0.1 in the field to show It works! It indicates that the Apache server has started to work, and the LAMP installation is complete.
Ubuntu LAMP installation environment "src ="/uploads/allimg/110601/115 T36336-0.gif "alt =" ubuntuLAMP installation environment settings "/>
Linux ubuntu LAMP installation and setup environment-It Works
Although Gnome cannot be used, it is easy to execute terminal commands:
One command directly: apt-get install apache2 mysql-server mysql-client php5 php5-gd php5-mysql
Set the read and write permissions for Ubuntu files
After LAMP is set up and installed, the default directory of the PHP network operator is/var/www. Due to the security principle of the Linux system, only root users are allowed to modify the file read and write permissions under the directory. Therefore, you cannot create or delete PHP files in the www folder, you must first modify the read and write permissions of the/var/www directory. You cannot modify the File Permission by right-clicking the attribute in the interface manager. You can run the following command on the root terminal: sudo chmod 777/var/www. Then you can write html or PHP files. If you are not clear about the file permissions exposed in section 777, you can refer to this article to see what file permissions 666 mean.
How to install phpmyadmin-Mysql Database Management
Exercise interface Manager:
System-> System Management-> New Software Package Manager-> Search phpmyadmin-> right-click the symbol to install.
Or run a command: sudo apt-get install phpmyadmin to start installation.
Phpmyadmin settings:
In the installation process, You must select Web server: apache2 or lighttpd, select apache2, press the tab key, and click OK. Then, you must enter the Mysql database Password and the Password of the database's administrative user.
Then create a connection between phpmyadmin and apache2. Take my example: www contents in/var/www, phpmyadmin in/usr/share/phpmyadmin contents: sudo ln-s/usr/share/phpmyadmin/var/www creates a connection.
Phpmyadmin test: Open http: // localhost/phpmyadmin In the Referer bar.
How to configure Apache in Ubuntu LAMP
1. Enable mod_rewrite module
Terminal order: sudo a2enmod rewrite
Restart Apache server: sudo/etc/init. d/apache2 restart
After Apache is restarted, we can test whether to create the file test. php in the/var/www directory and write the code: <? Php phpinfo ();?> Enter http: // 127.0.0.1/test. php or http: // localhost/test. php. If the php setting information appears accurately, it indicates that LAMP Apache is normal (remember to restart the Apache server and test again ).
2.set apacheto support .htm. html. php
Sudo gedit/etc/apache2/apache2.conf
Or sudo gedit/etc/apache2/mod-enabled/php5.conf
Add
AddType application/x-httpd-php. php. htm. html.
Mysql test with LAMP settings
The above php and Apache have been tested. Next, let's test whether the Mysql database has been precisely enabled.
Create mysql_test.php in the/var/www directory:
<? Php $ link = mysql_connect ("localhost", "root", "020511"); if (! $ Link) {die ('could not connect: '. mysql_error ();} else echo "Mysql has been precisely set"; mysql_close ($ link);?>
In the left-side Navigation Pane, enter http: // 127.0.0.1/mysql_test.php to display "Mysql has been precisely set". If not, restart the Apache server and try again.
Handle questions such as Chinese garbled characters on the Firefox Viewer
When mysql_test.php or phpmyadmin is enabled in the FireFox viewer, if Chinese characters are garbled, It is the default language setting question. The procedure is as follows:
Open the apache setting file: udo gedit/etc/apache2/apache2.conf, In the end Of the header plus: adddefacharcharset UTF-8, if still garbled, then the UTF-8 to use gb2312.
Restart Apache: sudo/etc/init. d/apache2 restart and then innovate mysql_test.php.
If you want to manually start mysql: mysql-u root-p, enter the password as prompted.
If the following error occurs when you restart Apache:
* Restarting web server apache2
Apache2: cocould not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
Apache2: cocould not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
Modify the apache configuration file sudo gedit/etc/apache2/apache2.conf, and set ServerName 127.0.0.1 at the end of the file.
Several terminal commands that LAMP components often execute
Restart apache: sudo/etc/init. d/apache2 restart
Restart mysql: sudo/etc/init. d/mysql restart
Set php. ini: sudo gedit/etc/php5/apache2/php. ini
Set apache2.conf: sudo gedit/etc/apache2/apache2.conf
Set my. cnf: sudo gedit/etc/mysql/my. cnf
Php cgi: sudo/var/www/cgi-bin/
Ubuntu PHP Editor
The LAMP setting is complete. You can use Gedit to edit php code in Ubuntu. Gedit supports code highlighting in dozens of languages such as HTML, PHP, and javascsrept. If it is a PHP project development, we propose to exercise the php ide Editor, such as Zend Studio and Eclipse. I heard that text editing VIM is also good.
PS: If you want to build a LAMP environment in Windows XP, we suggest you try the xampp quick installation and setting method, which is convenient and quick to exercise, click the previous hyperlink or Google to know how to use it. (Responsible editor: admin)
Original article, reprinted with the source: Remote blog