ubuntu14 php环境配置

方法一:

1.更新ubuntu软件列表

# apt-get update

2.安装apache

# apt-get install apache2

3.安装php

# apt-get install php5

4.安装mysql

# apt-get install mysql-server

安装过程需要设置root密码

安装mysql php扩展

# apt-get install php5-mysql

5.安装phpmyadmin

#apt-get install phpmyadmin
#ln -s /usr/share/phpmyadmin /var/www/phpmyadmin

install 安装的phpmyadmin 项目一般在 /usr/share中,需要进行 ln -s /usr/share/phpmyadmin /var/www/phpmyadmin 复制并连接

注意: http://localhost 访问的是 /var/www/html/里面的index.php,所以需要修改配置

vim /etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:80>
        # The ServerName directive sets the request scheme,hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts,the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However,you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8,...,trace1,debug,info,notice,warn,# error,crit,alert,emerg.
        # It is also possible to configure the loglevel for particular
        # modules,e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/,which are
        # enabled or disabled at a global level,it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

DocumentRoot /var/www/html 改为DocumentRoot /var/www,这样http://localhost将访问 /var/www目录下,phpmyadmin的路劲为:http://localhost/phpmyadmin/

6.重启mysql,apache

# service apache2 restart
# service mysql restart

方法二:

# tasksel install lamp-server

相关文章

文章浏览阅读2.3k次,点赞4次,收藏22次。最近安装了CARLA预...
文章浏览阅读6.3k次,点赞5次,收藏15次。在清华镜像中下载U...
文章浏览阅读5k次。linux环境, python3.7.问题描述: 安装...
文章浏览阅读4.2k次,点赞4次,收藏17次。要安装这个 standa...
文章浏览阅读894次,点赞51次,收藏31次。在安卓使用vscode主...