ubuntu下启动apache和mysql的命令(转)

ubuntu下启动apache和mysql的命令

 
  1. // Apache  
  2. //Task: Start Apache 2 Server /启动apache服务  
  3. # /etc/init.d/apache2 start  
  4. //or  
  5. $ sudo /etc/init.d/apache2 start  
  6. //Task: Restart Apache 2 Server /重启apache服务  
  7. # /etc/init.d/apache2 restart  
  8. //or  
  9. $ sudo /etc/init.d/apache2 restart  
  10. //Task: Stop Apache 2 Server /停止apache服务  
  11. # /etc/init.d/apache2 stop  
  12. //or  
  13. $ sudo /etc/init.d/apache2 stop   
  14. // Mysql  
  15. /etc/init.d/mysql start  
  16. /etc/init.d/mysql stop  
  17. /etc/init.d/mysql restart
  18. 如果遇到系统提示无法解析ServerName的时候 设置以下
  19. 首先,安装Apache2,安装命令:sudo apt-get install apache2  
  20. 安装完成后,进入到/etc/apache2中(根据自己的实际安装目录),这边我配置文件在/etc/apache2中。

     我们看到没有想象中的httpd.conf配置文件,这里要说明的是apache2的配置文件是apache2.conf,而不是http.conf。

     打开apache2.conf。写入两条语句

    ServerName localhost

    DirectoryIndex index.html index.htm index.php

    这里的ServerName localhost是为了防止最后开启apache2服务的时候会提示DNS出错。

    DirectoryIndex index.html index.htm index.php是默认目录的写法。保存退出。

    可以在apache2.conf中加入  AddDefaultCharset GB2312 

       设置默认字符集,定义服务器返回给客户机默认字符集(由于西欧UTF-8是Apache默认字符集,因此当访问有中文的网页时会出现乱码,这时只要将字符集改成GB2312,再重启Apache服务即可)

    Listen 192.168.1.1:80       设置监听ip是192.168.1.1的地址和端口为80

    Listen 192.168.1.2:8080     设置监听ip是192.168.1.2的地址和端口为8080

    Alias /down    "/sofТWare /download"   

    创建虚拟目录(创建名为down的虚拟目录,它对应的物理路径是:/sofТWare /download)

    Alias /ftp     "/var/ftp"                

    创建虚拟目录(创建名为ftp的虚拟目录,它对应的物理路径是:/var/ftp)

    <Directory "/var/www/html">       

    设置目录权限

    (<Directory "目录路径">此次写设置目录权限的语句</Directory>)

          Options FollowSymLinks        page:116

          AllowOverride None

    </Directory>

原文地址:https://www.cnblogs.com/wildmonk3y/p/4947262.html