本文中所指的ubuntu是指在vmware虚拟机下虚拟的服务器。
在安装的时候要注意两点,一个是尽量不要选择简易安装,二是在启动之前配好网络(将默认的NAT改成桥接模式)。
安装之后可以手动设置root密码,因为ubuntu在默认情况下没有设置ubuntu的root用户。
1 2 3 |
$sudo passwd $输入$用户密码 $设置#root密码两遍即可设置成功 |
确认可以联网的情况下分别使用apt-get方式安装ssh,以便在虚拟机外模拟用Xshell连接远程服务器的场景。
1 2 |
#先更新软件列表,如果是非管理员,请sudo #apt-get update |
然后安装即可
1 |
#apt-get install openssh-server |
安装好之后即可用Xshell等软件连接ubuntu了
安装软件apache2
1 |
#apt-get install apache2 |
其他软件例如php5 mysql-server 安装方式相同
这里在说一些常用的环境插件包
1 2 3 4 |
#apache2插件包 apache2-bin apache2-data apache2-doc apache2-mpm-prefork apache2-utils #php5插件包 php-pear php5-mysql php5-dev libapache2-mod-php5 php5-dev php5-curl php5-gd php5-imagick php5-mcrypt |
安装之后重启即可。
修改默认首页(/etc/apache2/mods-enabled/dir.conf)
1 2 3 4 5 6 7 |
<IfModule mod_dir.c> DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm </IfModule> 改成 <IfModule mod_dir.c> DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm </IfModule> |
启动伪静态mod_rewrite组件
1 2 |
a2enmod rewrite service apache2 restart |
事实上还有一种更简答的方法安装上面提到的众多软件包——使用tasksel的方式
1 2 3 4 |
#没有tasksel的换先安装tasksel #apt-get install tasksel #安装tasksel完成之后 #tasksel install lamp-server |
同一服务器下创建多网站的步骤:
先创建每个网站默认的根目录
然后在/etc/apache2/sites-available/ 下面创建conf文件(别忘了扩展名,直接复制默认的然后打开修改即可)。
注意在其中加入一段代码给相关目录权限
1 2 3 4 5 6 7 8 9 |
最上面加上 ServerName bbs.aidu.com 中间修改好文件夹路径 最后加上 <Directory /wwwroot/bbs/> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> |
之后在/etc/apache2/sites-enabled/ 下建立和/etc/apache2/sites-available/ 目录中的软连接。
例如:
1 |
root@jess:/etc/apache2/sites-enabled# ln -s ../sites-available/bbs.conf bbs.conf |
之后重启apache2服务即可。
Comments | NOTHING