ubuntu lamp(apache+mysql+php) 环境搭建及相关扩展更新
时间:2023-10-16 03:26:55
一、环境安装
1.安装apache2
sudo apt-get install apache2
安装后在浏览器中打开:http://localhost/或者http://127.0.0.1
如果出现It works!证明apache安装成功。
2.安装PHP
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart
测试:
sudo vi /var/www/testphp.php
写入php works!保存退出vi。
然后在浏览器中输入http://127.0.0.1/testphp.php或者http://localhost/testphp.php
如果显示出php works!表示php配置成功。
3.安装MYSQL
sudo apt-get install mysql-server
安装过程中按提示设置root密码即可。
注:修改密码:
mysql -uroot -p
mysql>use mysql;
mysql>update user set password=PASSWORD('new password') WHERE user='root';
mysql>exit
重启mysql,或是刷新权限也行
重启即可: sudo /etc/init.d/mysql restart 或是 restart mysql
4、让apache、php支持mysql
sudo apt-get install libapache2-mod-auth-mysql
sudo apt-get install php5-mysql
sudo /etc/init.d/apache2 restart
至此Ubuntu+apache2+php 5+mysql的安装完成。
提示:
/etc/apache2/下:
1、apache2.conf 是主配置文件,httpd.conf 用户配置文件
2、虚拟目录在 httpd.conf 中
DocumentRoot “路径”
ServerName 名称
#Listen 127.0.0.1:80 #注意这个文件中不能写上监听,如果必须要写,那就需要先去apache2.conf下将include /etc/apache2/ports.conf 给注释掉,因为ports.conf中已经监听来80端口
3、目录设置在 /etc/apache2/sites-enabled/000-default 可以设置虚拟主机
4、php.ini: /etc/php5/apache2/php.ini
5、mysql.cnf: /etc/mysql/my.cnf
4、重启apache : /etc/init.d/apache2 restart
5、重启mysql: sudo /etc/init.d/mysql restart 或是 restart mysql
6、日志文件: /var/log/apache2/
二、GD库安装
sudo apt-get install php5-gd
sudo /etc/init.d/apache2 restart
三、curl扩展安装
sudo apt-get install php5-curl
sudo /etc/init.d/apache2 restart
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
解决Python3 控制台输出InsecureRequestWarning问题
十万条Access数据表分页的两个解决方法
下拉列表两级连动的新方法(一)
Jupyter Lab设置切换虚拟环境的实现步骤
![](https://img.aspxhome.com/file/2023/4/133584_0s.png)
Tensorflow实现神经网络拟合线性回归
![](https://img.aspxhome.com/file/2023/4/92514_0s.jpg)
python Tkinter的图片刷新实例
php中正则替换函数ereg_replace用法实例
MySQL下高可用故障转移方案MHA的超级部署教程
SQL SERVER2012中新增函数之字符串函数CONCAT详解
Oracle跨数据库查询并插入实现原理及代码
tensorflow 利用expand_dims和squeeze扩展和压缩tensor维度方式
python爬虫指南之xpath实例解析(附实战)
![](https://img.aspxhome.com/file/2023/6/104996_0s.png)
Python实现微信自动好友验证,自动回复,发送群聊链接方法
![](https://img.aspxhome.com/file/2023/7/63227_0s.jpg)
python matplotlib画图实例代码分享
![](https://img.aspxhome.com/file/2023/5/117865_0s.png)
Linux下rpm方式安装mysql教程
Python实现常见的4种坐标互相转换
![](https://img.aspxhome.com/file/2023/0/63200_0s.png)
利用matplotlib实现根据实时数据动态更新图形
![](https://img.aspxhome.com/file/2023/0/118000_0s.jpg)