Home  >  Article  >  Backend Development  >  Ubuntu下安装PHP

Ubuntu下安装PHP

WBOY
WBOYOriginal
2016-06-23 14:30:38855browse

Ubuntu下安装PHP

安装apache2:sudo apt-get install apache2。查看是否成功:http://localhost/
安装PHP5:sudo apt-get install php5
sudo apt-get install libapache2-mod-php5(根据俺的实际测试,这一步似乎不用做了,在上一步已经安装好了,不过还是建议你copy/paste一下这条命令)
sudo /etc/init.d/apache2 restart 测试PHP5是否安装成功
sudo gedit /var/www/testphp.php
在里面写入,然后在Firefox中打开: http://localhost/testphp.php

安装mysql:sudo apt-get install mysql-server

MySql初始只允许本机(127.0.0.1)连接,如果想多台机子使用或者向Internet开放的话,编辑/etc/mysql/my.cnf
sudo gedit /etc/mysql/my.cnf
找到bind-address = 127.0.0.1,用#注释掉,象这样:#bind-address = 127.0.0.1

MySql默认没有设置root密码,本机的root用户也没有密码,有风险是吧,这样
mysqladmin -u root password your-new-password
mysqladmin -h root@local-machine-name -u root -p password your-new-password(这里我怎么也连接不上mysql服务器,最后在mysql-admin里面改的)
sudo /etc/init.d/mysql restart

安装MYSQL Administrator:sudo apt-get install mysql-admin

安装MYSQL for Apache HTTP Server
sudo apt-get install libapache2-mod-auth-mysql
sudo apt-get install php5-mysql

(sudo apt-get install phpmyadmin)

要让PHP与MySql一起工作,编辑
sudo gedit /etc/php5/apache2/php.ini
取消对;extension=mysql.so的注释,象这样

extension=mysql.so

保存文件,然后
sudo /etc/init.d/apache2 restart

测试:
http://localhost/phpmyadmin

Statement:
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