手把手教你在Ubuntu上安装Apache、MySql和PHP
1:首先安装apache:打开终端(ctrl+Alt+t),
输入命令:sudo apt-get install apache2即可安装,
安装完后,打开浏览器,在地址栏输入:localhost或者http://127.0.0.1
看到It works,表示安装成功!
默认根目录:/var/www/
2:安装mysql:
sudo apt-get install mysql-server-5.0
安装完后,会要你新设置mysql root密码,输入你自己的密码后enter键,再确认密码。
3:安装PHP 5 and Apache PHP 5 module:
sudo apt-get install php5 libapache2-mod-php5
sudo /etc/init.d/apache2 restart(重启apache)
试试成功否:
命令:gksudo gedit /var/www/text.php 【在apache默认根目录/var/www/下创建一text.php文件】
在text.php文件中输入以下代码检验是否安装成功:
<ol class="dp-xml"> <li class="alt"><span><span class="tag"></span><span class="tag-name">php</span><span> </span></span></li> <li><span>echo “helloworld”; </span></li> <li> <span> </span><span class="tag">?></span><span> </span> </li> </ol>
在浏览器地址栏输入:http://localhost/text.php 如果页面显示helloworld则表示成功
温馨提示:如果返回终端时无法再次输入命令时,按ctrl+z组合键
4:让apache和php支持php :
sudo apt-get install libapache2-mod-auth-mysql
sudo apt-get install php5-mysql
sudo /etc/init.d/apache2 restart(重启apache)
至此环境已搭建完!
/var/www/(apache2网页文件放在这里)
/var/lib/mysql(mysql文件放在这里)
如果你要远程连接的话,还要安装SSH,命令:sudo apt-get install ssh
可能我们还是习惯用phpmyadmin
5:安装phpmyadmin
sudo apt-get install phpmyadmin
此时在浏览器上输入:http://localhost/phpmyadmin 发现not found
所以我们还必须把安装好到phpmyadmin文件夹转移到/var/www/下面
sudo ln -s /usr/share/phpmyadmin/ /var/www/
执行上面到命令,我们已经把phpmyadmin文件夹转移到目的地了,也或者你把phpmyadmin直接复制到/var/www/的文件夹下面也可以。
我们再次浏览器上输入:http://localhost/phpmyadmin 回车时发现我们熟悉的界面回来了
原文:http://blog.csdn.net/guaikai/article/details/6905781

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 uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP makes it easy to create interactive web content. 1) Dynamically generate content by embedding HTML and display it in real time based on user input or database data. 2) Process form submission and generate dynamic output to ensure that htmlspecialchars is used to prevent XSS. 3) Use MySQL to create a user registration system, and use password_hash and preprocessing statements to enhance security. Mastering these techniques will improve the efficiency of web development.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

Deploying a ZooKeeper cluster on a CentOS system requires the following steps: The environment is ready to install the Java runtime environment: Use the following command to install the Java 8 development kit: sudoyumininstalljava-1.8.0-openjdk-devel Download ZooKeeper: Download the version for CentOS (such as ZooKeeper3.8.x) from the official ApacheZooKeeper website. Use the wget command to download and replace zookeeper-3.8.x with the actual version number: wgethttps://downloads.apache.or

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.
