Home > php教程 > php手册 > ubuntu下安装配置apache2+php5+mysql5

ubuntu下安装配置apache2+php5+mysql5

WBOY
Release: 2016-06-06 19:42:27
Original
1202 people have browsed it

安装 1、安装mysql数据库: sudo apt-get install mysql-server 2、安装Apache HTTP Server sudo apt-get install apache2 3、安装PHP5 和 Apache PHP5 module sudo apt-get install php5 libapache2-mod-php5 4、安装 php5-mysql sudo apt-get install php5

安装

1、安装mysql数据库:

          sudo apt-get install mysql-server

2、安装Apache HTTP Server

          sudo apt-get install apache2


3、安装PHP5 和 Apache PHP5 module
          sudo apt-get install php5 libapache2-mod-php5

4、安装 php5-mysql
        sudo apt-get install php5-mysql

5、安装 phpMyAdmin
       sudo apt-get install phpmyadmin


配置

1、配置php5,允许 mysql 和 gd 模块

       sudo vim /etc/php5/apache2/php.ini

加上:
extension=mysql.so
extension=gd.so


2、配置apache2
  2.1)  设置默认编码:sudo vim /etc/apache2/conf-available/charset.conf
将 #AddDefaultCharset UTF-8 前面的#去掉,使用UTF-8编码,当然也可以把 UTF-8改成别的编码.
  2.2)  更改DocumentRoot 指向的路径

          sudo vim /etc/apache2/sites-available/000-default.conf 

          和

          sudo vim /etc/apache2/sites-available/default-ssl.conf

更改apache2运行路径,更改DocumentRoot 指向的路径(绝对路径)

         ubuntu下安装配置apache2+php5+mysql5

测试

为检查PHP安装状态:
        sudo vim  /usr/workspace/index.php
在上述文件中(路径为配置的apache2运行路径)插入下面这行代码:
<span><?php phpinfo(); ?></span>
Copy after login

重启Apache2:    sudo /etc/init.d/apache2 restart 

在Web浏览器中查看此页面,通过 http://localhost/index.php 或http://yourserveripaddress/testphp.php 地址。

ubuntu下安装配置apache2+php5+mysql5


下面是我安装的版本信息

ubuntu下安装配置apache2+php5+mysql5

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template