I am a newbie in Linux. I want to install a Ubuntu Linux server and use the LAMP package on this server to run my own website. LAMP kit is "Linux + Apache + Mysql + PHP these four software constitute a set of tools that can run the website software ." Through the installation attempt, I have gained some successful installation and configuration experience. Through this article, I will learn from the attackers of the Linux website server system. Apache2 web page service will be used in the software environment of this website.
I am a beginner in Linux. I want to install a Linux Server of Ubuntu 12.04 and use the LAMP package on this server to run my own website. LAMP kit is "Linux + Apache + Mysql + PHP these four software constitute a set of tools that can run the website software ." Through the installation attempt, I have gained some successful installation and configuration experience. Through this article, I will learn from the attackers of the Linux website server system. In this installation of website software environment, Apache2 web service software, MySQL5 website background database software, and PHP5 interpreter language software will be used. The configured system can also provide FTP services.
1. Install LAMP
- Sudo apt-Get install apache2 mysql-Server mysql-Client php5 php5-Gd php5-Mysql
Most LAMP operations are related to the/var/www directory. For convenience, modify the directory permission to be accessible by common users.
- Sudo chmod 777./Var/Www/
2. phpmyadmin Installation
- Sudo apt-Get install phpmyadmin
During the installation process, You must select Web server: apache2 or lighttpd, select apache2, press the tab key, and click OK. Then, you are required to enter the Mysql database Password of the database's administrative user.
Then, establish a connection between phpmyadmin and apache2. Take my example: the www directory is in the/var/www directory, and the phpmyadmin directory is in the/usr/share/phpmyadmin directory. Therefore, run the following command: connect sudo ln-s/usr/share/phpmyadmin/var/www.
Phpmyadmin test: Open http: // localhost/phpmyadmin in the address bar of the browser.
3. Apache configuration
(1) Enable mod_rewrite module
Terminal command: sudo a2enmod rewrite
(2) restart the Apache server: sudo/etc/init. d/apache2 restart
After Apache is restarted, you can test it and create a file test under the/var/www directory. php, write code: Save, enter http: // 127.0.0.1/test in the address bar. php or http: // localhost/test. php. If Mysql is correctly configured, both Apache and mysql are normal. (Remember to restart the Apache server before testing ).
Test. php
- <?Php
- $Link = Mysql_connect("Localhost","Root","Mysql password");
- If (!$Link)
- {
- Die('Could not connect :' . Mysql_error());
- }
- Else Echo "Mysql has been correctly configured";
- Mysql_close($Link);
- ?>
4. PHP Chinese garbled characters in the browser
If Chinese characters are garbled during the test. php test in the FireFox browser, the default language settings are incorrect. The solution is as follows:
Open the apache configuration file: udo gedit/etc/apache2/apache2.conf, add: AddDefaultCharset UTF-8 at the end, if still garbled, then switch the UTF-8 to gb2312.
Restart Apache: sudo/etc/init. d/apache2 restart and refresh test. php.
For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2