您的位置:首页 > 编程语言 > PHP开发

ThinkPhp 学习笔记(一)

2014-11-19 00:00 218 查看
摘要: 一个网卡配置多个ip地址,apache就 基于多个ip 地址配置virtural host 整个号apace php thinkphp

整合PHP 框架

因为我的php 里配置恩几个主机,所以参考了网上资料 配置基于多IP地址配置virtural host

1 环境

redhat linux, php5.5 apache 2.2

[root@test_1 ahcustomer]# cat /proc/version
Linux version 2.6.32-358.el6.x86_64 (mockbuild@x86-022.build.eng.bos.redhat.com) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Tue Jan 29 11:47:41 EST 2013

2. 一个网卡添加多个ip地址

[root@test_1 php]# ifconfig
eth0      Link encap:Ethernet  HWaddr 84:2B:2B:94:F7:7D
inet addr:192.168.2.241  Bcast:192.168.2.255  Mask:255.255.255.0
inet6 addr: fe80::862b:2bff:fe94:f77d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:4912690 errors:0 dropped:0 overruns:0 frame:0
TX packets:5260810 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3889990544 (3.6 GiB)  TX bytes:4838872261 (4.5 GiB)
Interrupt:18

lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING  MTU:16436  Metric:1
RX packets:3567 errors:0 dropped:0 overruns:0 frame:0
TX packets:3567 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1752163 (1.6 MiB)  TX bytes:1752163 (1.6 MiB)

该主机目前只有一个eth0

执行

ifconfig eth0:1 192.168.2.242 netmask 255.255.255.0 up

在用ifconfig 命令查看

[root@test_1 php]# ifconfig
eth0      Link encap:Ethernet  HWaddr 84:2B:2B:94:F7:7D
inet addr:192.168.2.241  Bcast:192.168.2.255  Mask:255.255.255.0
inet6 addr: fe80::862b:2bff:fe94:f77d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:4912690 errors:0 dropped:0 overruns:0 frame:0
TX packets:5260810 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3889990544 (3.6 GiB)  TX bytes:4838872261 (4.5 GiB)
Interrupt:18

eth0:1    Link encap:Ethernet  HWaddr 84:2B:2B:94:F7:7D
inet addr:192.168.2.242  Bcast:192.168.2.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
Interrupt:18

lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING  MTU:16436  Metric:1
RX packets:3567 errors:0 dropped:0 overruns:0 frame:0
TX packets:3567 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1752163 (1.6 MiB)  TX bytes:1752163 (1.6 MiB)


eth0:1 在电脑重启时就会自动消失

这里可以把这个命令

ifconfig eth0:1 192.168.2.242 netmask 255.255.255.0 up

添加到rc.local

3. 解压thinkphp 包

解压到如下目录(注意此处我已经修改了Application 读写权限)

[root@test_1 ahcustomer]# pwd
/opt/www/ahcustomer
[root@test_1 ahcustomer]# ll
总用量 24
drwxrwxrwx 5 root root 4096 11月 19 15:03 Application
-rw-r--r-- 1 root root  416 6月  13 09:57 composer.json
-rw-r--r-- 1 root root 1009 6月  13 09:57 index.php
drwxr-xr-x 2 root root 4096 6月  13 09:57 Public
-rw-r--r-- 1 root root 2681 6月  13 09:57 README.md
drwxr-xr-x 8 root root 4096 6月  13 09:57 ThinkPHP

4.配置apache httpd.conf

<VirtualHost 192.168.2.242:80>
DocumentRoot /opt/www/ahcustomer
ServerName 192.168.2.242
<Directory "/opt/www/ahcustomer">
Options Indexes FollowSymLinks
IndexOptions Charset=utf-8
AllowOverride All
Order allow,deny
Allow from all

</Directory>
</VirtualHost>

5 报错

应用目录[./Application/]不可写,目录无法自动生成! 请手动生成项目目录~

chmod a+w /opt/www/ahcustomer/Application

6 访问地址

http://192.168.2.242/index.php
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: