如何在Ubuntu 14.04中创建虚拟主机 [英] how to create a virtual host in ubuntu 14.04

查看:83
本文介绍了如何在Ubuntu 14.04中创建虚拟主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ubuntu 14.04操作系统,我想在启动我的php项目之前创建一个虚拟主机.如果有人可以给我终端命令,我将不胜感激.

I'm using ubuntu 14.04 operating system and I want to create a virtual host before starting my php project. If any one can give me the terminal commands I would be grateful.

我已经安装了必要的安装,并且正在使用Symfony php框架.

I have already installed necessary installations and I'm using Symfony php framework.

推荐答案

创建虚拟主机

sudo nano /etc/hosts

输入密码=>

创建IP和域名=>

127.0.0.1    testsite.lk

创建项目文件夹=>转到该目录comand提示符=>

create project folder=> Go to that directory comand prompt=>

sudo chmod -R 777 testsite.lk

将项目分配给组=>:〜/mayura $

to asign project to group=> :~/mayura$

> sudo chown -R www-data:www-data testsite.lk/

授予权限=>:〜/mayura $

give permission=> :~/mayura$

sudo chmod -R 777 testsite.lk/

为垂直主机提供文档根文件:〜/mayura $

give document root file for vertual host :~/mayura$

cd /etc/apache2/sites-available/

sudo nano testsite.lk.conf
                <VirtualHost *:80>
                    DocumentRoot /home/mayura/project/testsite/web
                    DirectoryIndex index.php
                    ServerName testsite
                    <Directory "/home/mayura/project/testsite/web">
                        Options Indexes FollowSymLinks MultiViews
                        AllowOverride All
                        Order allow,deny
                        allow from all
                    Require all granted
                    </Directory>
                </VirtualHost>

在该文件夹中的Netbeans上创建新项目=>index.php

Create New project on Netbeans in that folder=> index.php

启用站点=>

cd /etc/apache2/sites-available

sudo a2ensite testsite.lk.conf

Apache reload =>

Apache reload=>

sudo /etc/init.d/apache2 reload

启动浏览器=>运行=>

Start Browser=> Run=>

xdg-open http://testsite.lk

这篇关于如何在Ubuntu 14.04中创建虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆