【背景】
项目需要搭建一套mysqlapi的开发环境,进行域名绑定
【方法】
主要方式通过修改apache的vhost配置文件,重启apache服务,以及最终在客户端绑定hosts。
1、查看apache服务目录
[[email protected] 10.73.13.48 sinasrv2]# ps aux |grep httpd root 1488 0.0 0.1 336416 13904 ? Ss Jul03 0:00 /usr/local/sinasrv2/sbin/httpd -k restart www 8449 0.0 0.1 339244 13212 ? S 04:02 0:00 /usr/local/sinasrv2/sbin/httpd -k restart www 8450 0.0 0.1 340780 14496 ? S 04:02 0:02 /usr/local/sinasrv2/sbin/httpd -k restart www 8451 0.0 0.1 340080 13784 ? S 04:02 0:00 /usr/local/sinasrv2/sbin/httpd -k restart www 8452 0.0 0.0 336932 11456 ? S 04:02 0:00 /usr/local/sinasrv2/sbin/httpd -k restart www 8453 0.0 0.1 340784 14720 ? S 04:02 0:03 /usr/local/sinasrv2/sbin/httpd -k restart www 16928 0.0 0.1 340780 14188 ? S 06:50 0:00 /usr/local/sinasrv2/sbin/httpd -k restart root 18487 0.0 0.0 61164 764 pts/27 S+ 10:37 0:00 grep httpd www 28401 0.0 0.0 339024 11964 ? S 09:47 0:00 /usr/local/sinasrv2/sbin/httpd -k restart
目录所在的地方为/usr/local/sinasrv2,该目录下的文件为
[[email protected] 10.73.13.48 sinasrv2]# cd /usr/local/sinasrv2 [[email protected] 10.73.13.48 sinasrv2]# ll total 60 drwxr-xr-x 3 root root 4096 May 6 16:11 bin drwxr-xr-x 2 root root 4096 Aug 8 2011 distcache drwxr-xr-x 8 www www 12288 Jul 9 10:32 etc drwxr-xr-x 13 root root 12288 Mar 10 09:49 include drwxr-xr-x 15 root root 4096 Jun 7 21:29 lib lrwxrwxrwx 1 root root 23 Jan 13 2011 lib64 -> /usr/local/sinasrv2/lib lrwxrwxrwx 1 root root 17 Jan 13 2011 modules -> lib/httpd/modules drwxr-xr-x 3 root root 4096 Dec 19 2012 rome drwxr-xr-x 2 root root 4096 Dec 3 2013 sbin drwx------ 2 nobody root 4096 Mar 18 2011 scgi_temp drwxr-xr-x 14 root root 4096 Nov 27 2012 share drwx------ 2 nobody root 4096 Mar 18 2011 uwsgi_temp drwxr-xr-x 5 root root 4096 Jul 2 2013 var
2、修改apache的vhost配置文件
vim /usr/local/sinasrv2/etc/httpd.conf
添加如下内容:
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /data1/www/htdocs/dpadmint-dev.grid.sina.com.cn ServerName api-dev.mysql.cluster.sina.com.cn ErrorLog /data1/www/logs/api-dev.mysql.cluster.sina.com.cn-error_log CustomLog /data1/www/logs/api-dev.mysql.cluster.sina.com.cn-access_log combined ProxyPass / http://127.0.0.1:6184/ ProxyPreserveHost on </VirtualHost>
3、重启apache服务
[[email protected] 10.73.13.48 etc]# apachectl restart [[email protected] 10.73.13.48 etc]# ps aux |grep httpd root 1488 0.0 0.1 336416 13924 ? Ss Jul03 0:00 /usr/local/sinasrv2/sbin/httpd -k restart www 23323 0.0 0.0 336416 6992 ? S 10:48 0:00 /usr/local/sinasrv2/sbin/httpd -k restart www 23324 0.0 0.0 336416 6992 ? S 10:48 0:00 /usr/local/sinasrv2/sbin/httpd -k restart www 23325 0.0 0.0 336416 6992 ? S 10:48 0:00 /usr/local/sinasrv2/sbin/httpd -k restart www 23326 0.0 0.0 336416 6992 ? S 10:48 0:00 /usr/local/sinasrv2/sbin/httpd -k restart www 23327 0.0 0.0 336416 6992 ? S 10:48 0:00 /usr/local/sinasrv2/sbin/httpd -k restart root 23329 0.0 0.0 61164 764 pts/27 S+ 10:48 0:00 grep httpd
4、 测试校验
绑定host
输出结果为
{"status": 0, "result": {"database": ["elink"]}, "request_id": 1208541870}
时间: 2024-10-12 15:40:09