sudo apt-get update
结果报错:
W: 无法下载 bzip2:/var/lib/apt/lists/partial/cn.archive.ubuntu.com_ubuntu_dists_precise_universe_binary-i386_Packages Hash 校验和不符 W: 无法下载 bzip2:/var/lib/apt/lists/partial/cn.archive.ubuntu.com_ubuntu_dists_precise_multiverse_binary-i386_Packages Hash 校验和不符 W: Some index files failed to download. They have been ignored, or old ones used instead.第一次尝试修改软件源:
点击【Ubuntu 软件中心】--> 左上角【编辑】-->下拉列表的【软件源】,修改之后还是不行。
第二次尝试:
sudo rm -r /var/lib/apt/lists/partial/* sudo rm -r /var/lib/apt/lists/* sudo apt-get update 更新完成。 参考文章:https://blog.csdn.net/super_mimi/article/details/40628887安装apache:
sudo apt-get install apache2查看apahce版本
test@localhost:~$ apache2 -v Server version: Apache/2.2.22 (Ubuntu) Server built: Jul 15 2016 15:32:45访问ip地址:
It works! This is the default web page for this server. The web server software is running but no content has been added, yet.说明apache正常运行了。
查看php版本:
test@localhost:~$ php5 -v PHP 5.3.10-1ubuntu3.26 with Suhosin-Patch (cli) (built: Feb 13 2017 20:37:53) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologiesphp安装成功。
没有msql.so,说明mysql没有被正确加载。
php默认不安装MySQL扩展,需要手动安装:
sudo apt-get install php5-mysql再次检查是否加载:
test@localhost:~$ cat /etc/php5/conf.d/mysql.ini ; configuration for php MySQL module extension=mysql.so加载成功。
(7)测试环境是否正常:
重启一下mysql:
test@localhost:~$ sudo service mysql restart mysql stop/waiting mysql start/running, process 7503重启apache:
test@localhost:~$ sudo service apache2 restart * Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName [ OK ]默认web目录在 /var/www下。
编辑phpinfo文件测试,进入/var/www目录:
sudo vim phpinfo.php(如果没有vim,安装vim:sudo apt-get install vim)
内容:
<?php echo mysql_connect('localhost','root','123456')?'db success':'db fail'; phpinfo();然后访问这个文件,IP地址/phpinfo.php。
可以看到db success和phpinfo信息,表示搭建成功。
sudo apt-get install php5-gd curl libcurl3 libcurl3-dev php5-curl
需要重启apache,sudo service apache2 restart
方法一:
可以使用一条命令安装所有软件:
sudo apt-get install apache2 php5 mysql-server php5-mysql 。
方法二:
使用tasksel工具安装:
sudo tasksel install lamp-server
(10)安装phpmyadmin
apt-get 方式:
sudo apt-get install phpmysadmin
sudo ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin
手动上传:
在电脑上下载phpmyadmin,然后上传到服务器上。
转载于:https://www.cnblogs.com/gyfluck/p/9335615.html
相关资源:JAVA上百实例源码以及开源项目