UBUNTU 轻松一键安装LAMP和配置phpmyadmin
?
PHP开发和服务器运行环境首选LAMP组合,即Linux+Apache+Mysql+Php/Perl/Python,能最优化服务器性能。如何在本地电脑Ubuntu 中安装和配置LAMP环境搭建?Ubuntu9.10本身就是基于Linux内核,所以Linux是现成的了。使用Ubuntu LAMP Server软件包可以很简单地实现Linux下Apache,Mysql和Php的统一安装和配置,也不再需要一个一个来安装配置了。
Ubuntu环境下如何安装LAMP组件?
使用Ubuntu界面管理器:
系统->系统管理->新立得软件包管理器->编辑->使用任务标记分组软件包->LAMP Server(勾选)->确定->返回到上一个窗口点击应用(或System->Administration->Synaptic Package Manager->Edit->Mark packages by Task->LAMP Server->OK)。然后系统会自动下载安装lamp环境软件包,几分钟就下载搞定。安装过程中会要求设置Mysql root帐号的密码,设置好了记住。另外当Ubuntu系统升级时lamp环境组件也会同时更新到最新版本。
安装完毕测试:打开Firefox浏览器在地址栏输入127.0.0.1,显示It works!表明Apache服务器已经开始工作了,LAMP安装也就这样完成了。

?
Linux ubuntu LAMP 安装配置环境-It Works
当然不使用Gnome,使用终端命令也很简单:
直接一条命令:apt-get install apache2 mysql-server mysql-client php5 php5-gd php5-mysql
设置Ubuntu文件执行读写权限
LAMP组建安装好之后,PHP网络服务器根目录默认设置是在:/var/www。由于Linux系统的安全性原则,改 目录下的文件读写权限是只允许root用户操作的,所以我们不能在www文件夹中新建php文件,也不能修改和删除,必须要先修改/var/www目录的读写权限。在界面管理器中通过右键属性不能修改文件权限,得执行root终端命令:sudo chmod 777 /var/www
。然后就可以写入html或php文件了。
如何安装phpmyadmin-Mysql 数据库管理
使用界面管理器:
系统->系统管理->新立得软件包管理器->搜索 phpmyadmin->右键标记安装。
或直接使用一条命令:sudo apt-get install phpmyadmin 安装开始。
phpmyadmin设置:
在安装过程中会要求选择Web server:apache2或lighttpd,选择apache2,按tab键然后确定。然后会要求输入设置的Mysql数据库密码连接密码 Password of the database’s administrative user。
然后将phpmyadmin与apache2建立连接,以我的为例:www目录在/var/www,phpmyadmin在/usr/share/phpmyadmin目录,所以就用命令:sudo ln -s /usr/share/phpmyadmin /var/www 建立连接。
phpmyadmin测试:在浏览器地址栏中打开http://localhost/phpmyadmin。
Ubuntu LAMP 如何配置Apache
1. 启用 mod_rewrite 模块
终端命令:sudo a2enmod rewrite
重启Apache服务器:sudo /etc/init.d/apache2 restart
Apache重启后我们可以测试一下,在/var/www目录下新建文件test.php,写入代码:??<?php phpinfo(); ?>?
保存,在地址栏输入http://127.0.0.1/test.php?或 http://localhost/test.php ,如果正确出现了php 配置信息则表明LAMP Apache已经正常工作了(记得重启Apache服务器后再测试)。
2.设置Apache支持.htm .html .php
sudo gedit /etc/apache2/apache2.conf
或sudo gedit /etc/apache2/mods-enabled/php5.conf
在打开的文件中加上
AddType application/x-httpd-php .php .htm .html 即可。
LAMP配置之Mysql测试
上面php,Apache 都已经测试过了,下面我们再测试一下Mysql 数据库是否已经正确启用。
在/var/www目录下新建 mysql_test.php:
<?php $link = mysql_connect("localhost","root","020511");if (!$link){die('Could not connect: ' . mysql_error());}else echo "Mysql已经正确配置";mysql_close($link);?>
保存退出,在地址栏输入http://127.0.0.1/mysql_test.php,显示”Mysql 已经正确配置”则表示OK了,如果不行,重启Apache服务器后再试一下。
解决Firefox浏览器显示中文乱码等问题
上面在FireFox浏览器中打开mysql_test.php或phpmyadmin测试时,如果出现了中文乱码,则是默认语言设置问题,解决方法如下:
打开apache配置文件: udo gedit /etc/apache2/apache2.conf,在最后面加上:AddDefaultCharset UTF-8
,如果还是乱码的,再将UTF-8改用gb2312。
重启Apache:sudo /etc/init.d/apache2 restart? 再刷新mysql_test.php 中文乱码没有了。
如果要人工启动mysql:mysql -u root -p,根据提示输入密码。
如果重启Apache时出现:
* 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
则还是修改apache配置文件:sudo gedit /etc/apache2/apache2.conf,在文件最后设置:ServerName 127.0.0.1
LAMP组件经常使用的几个终端命令
重启 apache:sudo /etc/init.d/apache2 restart
重启mysql:sudo /etc/init.d/mysql restart
配置 php.ini:sudo gedit /etc/php5/apache2/php.ini
配置 apache2.conf:sudo gedit /etc/apache2/apache2.conf
配置 my.cnf:sudo gedit /etc/mysql/my.cnf
PHP CGI :sudo /var/www/cgi-bin/
Ubuntu PHP 编辑器
最后LAMP配置就完成了,在Ubuntu下进行简单的php代码编辑,用Gedit就可以了。Gedit支持HTML,PHP,Javascsript等近几十种语言的代码高亮功能。如果是PHP项目开发,建议使用PHP IDE编辑器,比如Zend Studio,Eclipse。据说文本编辑VIM也很不错。
PS:如果是Windows XP 下要搭建LAMP 环境,建议大家试试xampp快速安装配置法,使用也很方便快捷,点击前面的超级链接或Google一下就知道怎么用了。
?
还有一种更为简单的一键安装方式:
?
一键安装LAMP服务:
sudo tasksel install lamp-server
一键卸载LAMP:
sudo tasksel remove lamp-server
注意:
通过上面的命令卸载Lamp时不免把Linux系统本身的东西卸载掉了,因此,
在卸载LAMP后一定记着更新一下系统:
sudo apt-get update
sudo apt-get upgrade
上面两条都要执行
??

Setting session cookie parameters in PHP can be achieved through the session_set_cookie_params() function. 1) Use this function to set parameters, such as expiration time, path, domain name, security flag, etc.; 2) Call session_start() to make the parameters take effect; 3) Dynamically adjust parameters according to needs, such as user login status; 4) Pay attention to setting secure and httponly flags to improve security.

The main purpose of using sessions in PHP is to maintain the status of the user between different pages. 1) The session is started through the session_start() function, creating a unique session ID and storing it in the user cookie. 2) Session data is saved on the server, allowing data to be passed between different requests, such as login status and shopping cart content.

How to share a session between subdomains? Implemented by setting session cookies for common domain names. 1. Set the domain of the session cookie to .example.com on the server side. 2. Choose the appropriate session storage method, such as memory, database or distributed cache. 3. Pass the session ID through cookies, and the server retrieves and updates the session data based on the ID.

HTTPS significantly improves the security of sessions by encrypting data transmission, preventing man-in-the-middle attacks and providing authentication. 1) Encrypted data transmission: HTTPS uses SSL/TLS protocol to encrypt data to ensure that the data is not stolen or tampered during transmission. 2) Prevent man-in-the-middle attacks: Through the SSL/TLS handshake process, the client verifies the server certificate to ensure the connection legitimacy. 3) Provide authentication: HTTPS ensures that the connection is a legitimate server and protects data integrity and confidentiality.

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.