Ubuntu 16.04搭建LAMP开发环境 古城微笑少年丶 2022-04-22 14:46 193阅读 0赞 安装好Ubuntu16.04后,是一台空白的Ubuntu。我的目的是搭建LAMP环境,顺便搭一个Python Django环境。 # 基本设置 # ## 1. 更新源 ## `sudo apt-get update` 源保存的文件是:/etc/apt/sources.list # 安装常用软件 # ## 1.SSH ## `sudo apt-get install openssh-server` * 查看状态: service ssh status/start/stop/restart * 或: /etc/init.d/ssh status/start/stop/restart * 实际上,sevice 命令就是执行/etc/init.d脚本,二者功能是一样的 ## 2.Vim ## `sudo apt-get install vim` ## 3.Tree ## `sudo apt-get install tree` ## 4.Git ## `sudo apt-get install git` # 搭建LAMP # ## 1. 安装Apache ## `sudo apt-get install apache2` * 测试:浏览器访问http://Ubuntu的ip,出现 It Works! 网页 * ‘查看状态:service apache2 status/start/stop/restart * Web 目录: /var/www * 安装目录: /etc/apache2/ * 全局配置: /etc/apache2/apache2.conf * 监听端口: /etc/apache2/ports.conf * 虚拟主机: /etc/apache2/sites-enabled/000-default.conf ## 2. 安装Mysql ## `sudo apt-get install mysql-server mysql-client` * 测试: mysql -u root -p * 查看状态:service mysql status/start/stop/restart * 查看监听端口的情况:netstat -tunpl 或者 netstat -tap ## 3. 安装PHP ## `sudo apt-get install php7.0` * 测试 :php7.0 -v ## 4. 安装其他模块 ## `sudo apt-get install libapache2-mod-php7.0` `sudo apt-get install php7.0-mysql` * 重启服务 `service apache2 restart` `service mysql restart` * 测试Apache能否解析PHP vim /var/www/html/phpinfo.phop 文件中写:<?php echo phpinfo();?> 浏览器访问:[http://ubuntu地址/phpinfo.php][http_ubuntu_phpinfo.php] 出现PHP Version 网页 ## 5. 修改权限 ## `sudo chmod 777 /var/www` ## 6. 安装PhpMyadmin ## `sudo apt-get install phpmyadmin` * 安装:选择apache2,点击确定。下一步选择是要配置数据库,并输入密码。 * 创建phpMyAdmin快捷方式:`sudo ln -s /usr/share/phpmyadmin /var/www/html` * 启用Apache mod\_rewrite模块:`sudo a2enmod rewrite` * 重启服务: service php7.0-fpm restart service apache2 restart * 测试:浏览器访问:[http://ubuntu地址/phpmyadmin][http_ubuntu_phpmyadmin] ## 7.配置Apache ## `vim /etc/apache2/apache2.conf` 添加: `AddType application/x-httpd-php .php .htm .html` `AddDefaultCharset UTF-8` 重启Apache服务:`service apache2 restart` -------------------- # 安装python 包 # ## 1.pip ## sudo apt-get install python-pip ## 2.Django ## pip install django 测试:import django ## 3.MySQL-python ## pip install MySQL-python 测试:import MySQLdb [http_ubuntu_phpinfo.php]: http://xn--ubuntu-u20k9d/phpinfo.php [http_ubuntu_phpmyadmin]: http://xn--ubuntu-u20k9d/phpmyadmin
还没有评论,来说两句吧...