chenshenhai / blog

个人博客,没事写写玩玩~~~
146 stars 21 forks source link

ubuntu下apache2+php+mysql环境配置 #13

Open chenshenhai opened 8 years ago

chenshenhai commented 8 years ago

ubuntu下apache2+php+mysql环境配置

安装apache2

# 安装
sudo apt-get install apache2

# 执行文件地址
/etc/init.d/apache2

# 配置文件目录
/etc/apache2

# 启动apache2
sudo apache2ctl -k start

# 停止apache2
sudo apache2ctl -k stop

# 重新启动apache2
sudo apache2ctl -k restart

# 如果重启遇到一下问题
# AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
#需要在apache2.conf 文件中加上 ServerName 127.0.0.1

安装php

# 目前会自动安装到php7版本

sudo apt install php

sudo apt-get install libapache2-mod-php

安装mysql

# 目前会安装到mysql5.7版本

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install mysql-server mysql-client

彻底卸载以上的安装

# 彻底卸载apache2
sudo apt-get --purge remove apache-common
sudo apt-get --purge remove apache
sudo find /etc -name "*apache*" |xargs  rm -rf 
sudo rm -rf /var/www
sudo rm -rf /etc/libapache2-mod-jk
sudo rm -rf /etc/init.d/apache2
sudo rm -rf /etc/apache2
dpkg -l |grep apache2|awk '{print $2}'|xargs dpkg -P

# 彻底卸载php
sudo apt-get –purge remove libapache2-mod-php php php-gd php-mysql
sudo apt-get autoremove php
sudo find /etc -name "*php*" |xargs  rm -rf 
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P

# 彻底卸载mysql
sudo apt-get autoremove --purge mysql-server
sudo apt-get remove mysql-server
sudo apt-get autoremove mysql-server
sudo apt-get remove mysql-common
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
sudo find /etc -name "*mysql*" |xargs  rm -rf 

# 检查是否完整删除
dpkg -l | grep apache
dpkg -l | grep apache2
dpkg -l | grep php 
dpkg -l | grep mysql