phpmyadmin: linux学习篇-使用apt-get方式安装LAMP包括phpmyadmin
linux学习篇-使用apt-get方式安装LAMP包括phpmyadmin
搭建LAMP环境有两种方式可以选择,一是用apt-get方式安装,这个适合初学者。有点是安装简单,不需要做什么配置就可以使用。缺点是自主性太差,安装目录啊啥的都是默认的,不方便自己管理,也不敢轻易的移动位置。二是用编译安装的方法。这个适合有点经验的朋友,优点是可以自动选择需要安装的扩展啊,制定安装的位置和网站根目录啊等等。缺点是不太容易上手。
本人也是个新手,首先介绍下用第一种方式,也就是apt-get方式安装LAMP,以及安装phpmyadmin管理mysql。一下文章选自网络,但是经过自己试验,的确没问题。
打开终端(快捷键ctrl+alt+t)
1.安装 Apache
1.打开终端
2. 输入以下命令
sudo apt-get install apache2
3. 如果没有sudo 权限,需要输入密码。
2.测试 Apache
为了确定安装是否成功,我们来测试一下。
1. 打开浏览器,输入以下网址
http://localhost/
如果成功,你会看到以下内容 "It works!" , 祝贺你,第一步,你算是跨出去了。
3.安装 PHP5
Step 1. 打开终端(ctrl+alt+t)
Step 2. 输入以下命令行:
sudo apt-get install php5 libapache2-mod-php5
Step 3.为了使PHP和Apache能一起工作,我们需要配置一下PHP并且测试一下。
Step 4.重启apache sudo /etc/init.d/apache2 restart
4.测试 PHP
Step 1.我们先建一个PHP 测试文件(我们叫它phptest.php),输入以下内容 :
sudo gedit /var/www/testphp.php
Step 2.这时我们会打开一个文本编辑器,在里面输入以下内容.
Step 3.保存退出。
Step 4. 现在打开浏览器,查看一下我们刚刚建立的内容。输入以下网址。
http://localhost/testphp.php
如果显示出PHP的信息内容页面,说明你又成功了一小步。
5.安装 MySQL
下面我们来安装Mysql5 (这是最后一步,也是麻烦比较多的一步,安装的时候注意。)
Step 1. 再一次地打开终端,输入以下内容。
sudo apt-get install mysql-server
Step 2.在安装的时候,如果要求你输入Mysql 密码,则输入密码。如果没有要求,则执行下一步。在终端中输入下面命令。
mysql -u root
后来,你还要输入以下内容;
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');
以上的'root'是你的Mysql 用户名,'yourpassword'是你的新密码。
Step 3.下面我们将去处理更为棘手的phpmyadmin这里经常出现的问题就是明明安装了phpmyadmin但却在输入http://localhost /phpmyadmin的时候,没有出现管理界面,反而出现没有找到的页面。不急,我们先安装再了phpmyadmin然后再去解决。输入以下命令:
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
这里的phpmyadmin是与我们之前装的php5 是相配合的,如果你装的PHP 和phpmyadmin不相配,它们不会工作。
Step 4.现在我们去解决phpmyadmin“不工作”的问题,当我们安装了phpmyadmin 后,不要以为一切就绪了。其实我们还有一项工作要去完成,就是去配置phpmyadmin和apache2。同样的终端,输入:
sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/sites-available/phpmyadmin
这样我们就把phpmyadmin中的apache.conf(apache配置文件)复制到apache2/sites-available下的phpmyadmin文件下。
Step 5.接着输入,进入sites-enabled文件夹下:
cd /etc/apache2/sites-enabled/
Step 6.进入之后,我们要建立一个通往配置文件的链接以便能利用它。输入:
sudo ln -s ../sites-available/phpmyadmin
Step 7.重启apache2
sudo /etc/init.d/apache2 restart
好了。打开http://localhost/phpmyadmin 去体验一下吧。
/etc/phpmyadmin/目录下的config.inc.php文件必须不能是world writeable
但必须是可读的。readable
sudo chmod go-w config.inc.php//去掉组群和其他用户,group,other的写权限。
-rwxr-xr-x 1 root root 4388 2月 15 03:24 config.inc.php*
到此为止,我们的LAMP 配置就完全结束了,希望对你有所帮助。
本文链接http://www.cxybl.com/html/wlbc/Php/20130608/38504.html

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

To set up a CGI directory in Apache, you need to perform the following steps: Create a CGI directory such as "cgi-bin", and grant Apache write permissions. Add the "ScriptAlias" directive block in the Apache configuration file to map the CGI directory to the "/cgi-bin" URL. Restart Apache.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

The steps to start Apache are as follows: Install Apache (command: sudo apt-get install apache2 or download it from the official website) Start Apache (Linux: sudo systemctl start apache2; Windows: Right-click the "Apache2.4" service and select "Start") Check whether it has been started (Linux: sudo systemctl status apache2; Windows: Check the status of the "Apache2.4" service in the service manager) Enable boot automatically (optional, Linux: sudo systemctl

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.
