hockey97 Posted June 15, 2011 Share Posted June 15, 2011 Hi, I am trying to figure out how I can add more domain names to apache via the use of php. I am trying to start into the web hosting business. I want to design my interface for my clients to create their websites. First thing I need is to after they place an order to update my apache config to host their new domain name. how can I add and delete such additions with php without currpting the apache config file. I know I can find some way to access the apache config file with the file write functions of php. Just don't know how I can just add the config settings and delete them later on. Like what if I have 5,000 domain names to cofig setup on apache and later on like about 10 needs to be deleted. those 10 can be anywhere in the file and won't alwasy be in order meaning from 10 to 1 it won't be like were they all will be after each other. It can be scattered on different lines of the file. I want to just delete the proper text and not delete stuff by lines because there can be times where the config of another website might start on the same line I needed to delete so if I delete by lines... I would delete the first line of that website config causing the website to not work properly. any ideas how to tackle this problem? Quote Link to comment https://forums.phpfreaks.com/topic/239408-how-can-you-generate-new-virtual-hosts-on-apache-with-use-of-php/ Share on other sites More sharing options...
gristoi Posted June 15, 2011 Share Posted June 15, 2011 have a look at this link: http://www.linux.com/news/enterprise/systems-management/8202-how-to-set-up-apache-virtual-hosting you can basically set up a vhost direcotry and create a vhost file for each individual domain. this way you can delete and create a whole file without affecting others. This does also come down to which flavour of linux you are using Quote Link to comment https://forums.phpfreaks.com/topic/239408-how-can-you-generate-new-virtual-hosts-on-apache-with-use-of-php/#findComment-1229915 Share on other sites More sharing options...
Adam Posted June 15, 2011 Share Posted June 15, 2011 I don't think you've quite considered some of the security issues here. The user PHP runs as, the Apache user, will not have root access to modify config files and reload the Apache config afterwards. It's certainly not recommended to switch the user Apache runs as to the root user, as that would open a lot of security holes. You also need to consider that each user who has an account with you will need their own unix user, with their own permissions, to limit access to the server. I have absolutely no experience with providing web hosting, but you'll need to use scripts/programs hosted on the site to set all of this up. One possible option would be to use bash, or perhaps a more significant language, but certainly not PHP -- definitely the wrong tool for the job, except to call or set-up a request for the server-side scripts. You'll probably also need to use a more sophisticated implementation than the link provided, if you're planning on having a lot of users. Either way you really need to have a good read up on unix users/permissions/bash/security, or hire a sysadmin. It's not fair to provide an insecure service to your users. Quote Link to comment https://forums.phpfreaks.com/topic/239408-how-can-you-generate-new-virtual-hosts-on-apache-with-use-of-php/#findComment-1229923 Share on other sites More sharing options...
trq Posted June 15, 2011 Share Posted June 15, 2011 It's not that difficult to setup really, but as MrAdam has stated, you'll need to do some reading. I've implemented this type of thing several times in my career and it's not really something that is going to be explained easily in a simple forum post. The first thing I would do is read up on 'dynamic' virtual hosts. It's covered in the Apache manual. It basically allow you to setup Apache to use wildcard paths. This in turn enables you to add sites by simply creating directories in the right place. You don't even need to restart Apache for these sites to become available. Seriously though, if your hear asking these questions your not in the position to do this yourself just yet. Servers invite people looking for security holes and unless you know what you are doing your service will fail. If it does fail, you need to consider that it's not just your data on the line but your clients. Quote Link to comment https://forums.phpfreaks.com/topic/239408-how-can-you-generate-new-virtual-hosts-on-apache-with-use-of-php/#findComment-1229936 Share on other sites More sharing options...
hockey97 Posted June 15, 2011 Author Share Posted June 15, 2011 ya, I know about the security issues. I don't plan on giving root access to my clients or to any request from the outside onto my web server. I have seen programs like webmin and others that is made with php. Those programs allows you to access your server from the internet and you can modify Apache config files and many other stuff. This is why I assumed you can do this task with php. I won't be making linux users for each client. I plan that my website in php will be the main interface for their websites. I am not doing a traditional web hosting where they can just ftp their files over. I will have them use my php editor to create website pages. They can then later on download the files if they want to in case they want to switch hosting providers but don't want to lose their website work. Security is my top priority for my clients. Only my computer or server or my own user can only make changes to the Apache files etc. Thanks for the replies and suggestions. I will take a look at the Apache manual. Quote Link to comment https://forums.phpfreaks.com/topic/239408-how-can-you-generate-new-virtual-hosts-on-apache-with-use-of-php/#findComment-1229949 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.