iis服务器助手广告广告
返回顶部
首页 > 资讯 > 精选 >一个简单的基于Debian的开发环境。
  • 204
分享到

一个简单的基于Debian的开发环境。

2023-06-03 12:06:58 204人浏览 独家记忆
摘要

这只是一个快速演练,描述了如何设置一个体面的开发环境,允许轻松设置多个站点。它已经假定您已经安装并配置了PHP,MySql和Apache已经运行的Debian或ubuntu操作系统 。你还需要一个有效的sudo。虽然其中一些东西是

这只是一个快速演练,描述了如何设置一个体面的开发环境,允许轻松设置多个站点。它已经假定您已经安装并配置了PHPMySql
Apache已经运行的Debian或ubuntu操作系统 。你还需要一个有效的sudo。

虽然其中一些东西是Debian / Ubuntu特定的,但将它应用于任何其他发行版并不困难。

我们需要做的第一件事是创建一个'www'组。该群组中的任何人都可以创建新网站。

sudo groupadd www

把自己放在这个群体中。

sudo gpasswd –a username www && newgrp www

现在,我们需要确保我们所有站点的存储位置都由www拥有和写入。

sudo chown :www /var/wwwsudo chmod g+ws /var/www

chmod的s开关设置粘滞位并确保在/ var / www中创建的所有目录也属于www组。

我们需要确保www可以写入保存vhost配置的目录。

sudo chown :www /etc/apache2/sites-*

接下来,我们将创建模板vhost配置。我们将使用它来为我们的每个站点生成配置。

<VirtualHost *:80>        ServerName {SITE}.local        DocumentRoot /var/www/sites/{SITE}.local/htdocs    DirectoryIndex index.php    <Directory />        Options FollowSymLinks        AllowOverride All    </Directory>        <Directory /var/www/sites/{SITE}.local/htdocs>        Options Indexes FollowSymLinks MultiViews        AllowOverride All        Order allow,deny        allow from all    </Directory>    ErrorLog /var/www/sites/{SITE}.local/logs/error.log    LogLevel warn    CustomLog /var/www/sites/{SITE}.local/logs/access.log combined</VirtualHost>

将其保存为/etc/apache2/sites-available/example.conf

现在,让我们创建一个简单的测试站点。

mkdir -p /var/www/sites/foo.local/{htdocs,logs}echo '<?php phpinfo(); ?>' > /var/www/sites/foo.local/htdocs/index.phpcd /etc/apache2/sites-availablesed -e 's/{SITE}/foo/g' example.conf > foo.confsudo a2ensite foo.confsudo /etc/init.d/apache2 restartecho '127.0.0.1 foo.local' | sudo tee -a /etc/hosts

这里有一些命令,但它非常简单:

The first line creates the minimal required directory structure for a new WEB site.
We then create an index.php file which has a call to phpinfo() in it.
Next we move into the directory where our vhost configs are stored.
We then create a new vhosy config called foo.conf which is a copy of the example.conf from above, we use sed to replace all instances of '{SITE}' with 'foo'
Next, enable this vhost. This adds a symlink within /etc/apache2/sites-enabled
Restart Apache.
Add foo.local to our hosts file. This enables the url Http://foo.local to resolve to our local Machine and hence, be served by Apache.

这是真的。你可以在这个基本想法上建立相当多的东西。我在多用户系统中实现的一件事是向'www'组的成员提供新命令。这些命令主要是
围绕需要sudo的东西的包装器 ,但它确实使得从最终用户的角度来看整个过程更加清晰。考虑到机会和兴趣,我可能会在另一个教程中详细介绍相关细节。

有一点需要注意。如果您希望网站中的目录可由Apache写入,则必须使它们属于www-data组,并且该组将需要写入权限。例如;

mkdir -p /var/www/sites/foo.local/uploadssudo chown :www-data /var/www/sites/foo.local/uploadssudo chmod g+w /var/www/sites/foo.local/uploads

--结束END--

本文标题: 一个简单的基于Debian的开发环境。

本文链接: https://www.lsjlt.com/news/234322.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作