ubuntu下配置apache,php,mysql

apache配置:
sudo apt-get install apache2:安装
ls /var/www/html ->回车,看到“index.html”文件。浏览器输入127.0.0.1查看
sudo vi /etc/apache2/apache2.conf ->找到,更改 /var/www为新的根目录
sudo vi /etc/apache2/sites-available/000-default.conf -> 找到DocumentRoot /var/www/html,更改/var/www/html为新的根目录,我换成了/var/www/
sudo /etc/init.d/apache2 restart:重启
cp /var/www/html/index.html /var/www/ :复制index.html文件到/var/www目录下
浏览器输入127.0.0.1,访问到index.html文件,修改根目录成功
apache80端口:
1, 修改 /etc/apache2/ports.conf 将
NameVirtualHost *:80
Listen 80
改为自己需要的端口
NameVirtualHost *:8080
Listen 8080
2,修改/etc/apache2/sites-available/default 将第一行的

改为自己需要的端口

3,修改 /etc/init.d/apache2/httpd.conf 添加
Servername localhost
重启:service apache2 restart
否则重启时会报如下错误
* Restarting web server apache2
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
… waiting apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
[ OK ]
4,重启apache
sudo /etc/init.d/apache2 restart
端口修改完毕。apache的端口修改为8080了。

安装配置php
sudo apt-get install libapache2-mod-php5 :安装
sudo service apache2 restart:重启
sudo touch var/www/html/index.php:添加文件
sudo gedit /var/www/info.php 回车 输入
浏览器输入localhost:8080/info.php”

mysql配置
sudo netstat -tap | grep mysql:检测系统是否安装mysql(若没有反映,没有显示已安装结果)
sudo apt-get install mysql-server 或 sudo apt-get install mysql-server mysql-client:安装mysql
接下来会让你输入默认用户root的密码
sudo service mysql restart:重启sql,如果重启成功会看到“mysql start/running, process 6905”
sudo apt-get install libapache2-mod-auth-mysql:添加apache的支持
sudo apt-get install php5-mysql:添加php的支持
mysql -u root -p -> 回车,输入mysql密码:登录mysql
启动MySQL服务: sudo start mysql
停止MySQL服务: sudo stop mysql
修改 MySQL 的管理员密码: sudo mysqladmin -u root password newpassword
use mysql:连接数据库 show tables:显示数据库中的表
退出数据库:exit
在/var/www/html下添加文件:sudo touch phpinfo.php
书写代码测试:sudo gedit phpinfo.php

安装了pdo_mysql
①apt-get install php-pear
②如果没有安装php和mysql的开发包,还需要安装
apt-get install php5-dev 安装时说找不到phpize -> sudo apt-get install update,重头来过
apt-get install libmysqlclient15-dev
③然后可以安装pdo了
pecl search pdo
pecl install pdo
pecl install pdo_mysql
④在安装pdo_mysql的时候发生错误:
checking for PDO includes… checking for PDO includes… /usr/include/php/ext
configure: error:
You’ve configured extension pdo_mysql, which depends on extension pdo,
but you’ve either not enabled pdo, or have disabled it.
ERROR: `/tmp/tmpUEZAUf/PDO_MYSQL-1.0.2/configure’ failed
提示找不到pdo但是pdo已经安装了.是pecl的错误,通过指定变量PHP_PDO_SHARED=1来解决 -> PHP_PDO_SHARED=1 pecl install pdo_mysql
⑤最后,修改 -> /etc/php5/apache2/php.ini
添加代码
extension=pdo.so
extension=pdo_mysql.so

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值