I want to know how to create subdomain using PHP.
The server uses cPanel control panel and i have seen code but not clear of what it does.
Is there any php function to create subdomains?
Or do we have to rely the server settings for this?
if you have cPanel then you can use what i used.
very simple function provided my hosting company server guy.
http://vikku.info/programming/php/create-subdomain-dynamically-in-php-code-to-create-subdomains-in-server-using-php.htm
As the other use said i agree that php cannot do anything with this...
These functions call cPanel libraries indirectly and those functions can access server level functions because they will have permission to do that.
PHP has nothing to do with domain or subdomains. You have to configure your server application accordingly to achieve this.
If you are using apache, take a look in their documentation about vhosts.
Related
Currently, I developing a WordPress plugin with React frontend.
I tried to connect my backend (PHP) running on a virtual host with webpack devserver with hot module replacement (HMR).
Is there any config how to do it.
note: I tried with devserver proxy but cant figure it out.
Thanks in advance.
Getting HMR is always complicated for custom setup like these. Theoretically, this is pretty simple. You simply need to run the webpack-dev-server with the HMR module. On your PHP file, make sure it uses the JS file generated from webpack-dev-server. The code to refresh is bundled in the JS file so it should work.
However, the devil is in the details. You'll need to make sure the communication between your page and webpack-dev-server works without issue. Monitor your websocket network request and make sure they communicate as expected.
An issue you'll probably encounter is security since the websocket connection is expecting a different host. In this case, you can use config from the following answer: I am getting an "Invalid Host header" message when connecting to webpack-dev-server remotely
Another issue could be that the JS file tries to connect to the wrong location. Eg: It thinks that your host is where the websocket connection is. If this is the case, you can use the public setting. See here for documentation: https://webpack.js.org/configuration/dev-server/#devserverpublic
To me this is akin to running with a reverse proxy. You can see this discussion to understand the problem: https://github.com/webpack/webpack-dev-server/issues/804
There might be other problems. You just need to check the websocket connection and make sure they communicate without problems
How you refer to the generated js file is a separate problem. A simple example would be setting the port to 8081 and bundling the js file into bundle.js. Then in your php code, refer to it as http://localhost:8081/bundle.js
It's possible to connect to a shared folder and list, read or write files in the folder as if it were a local folder with php? I was searching but I haven't found anything that woks for me.
If you intend to access Windows-based Share with SMB protocol, use can use Icewind\SMD library.
It can't possible with only PHP, We can't access the local directory/file using PHP.
But, If you write some Thread or File Watcher task using Java(Watch service) or Python or any other supported technology and send file related events to your PHP web-service or API.
Not sure but if will think in that way...it can be possible.
I am developing APIs in node js and have hosted the application on amazon EC2. In a third party API it is required to host a php page on our server and give its public url back to them. Is there another way to host it apart from a LAMP setup? Anything apart from EC2 is also fine but please take into consideration that this is a single page having some logic and nothing else will be there in PHP.
I work with node and php. I would recommend NGINX. It's configuration files are really simple and it's much lighter-weight than apache.
You can simply create a redirect/rewrite directive in NGINX that will pass your php page to the node server instead and be done. For this usecase, you wouldn't actually even need to install or configure the PHP backend.
http://nginx.org/en/docs/beginners_guide.html#proxy
You might also check AWS domain management tools (AWS Route 53). There may be a way to directly rewrite the incoming PHP request to go to your node app instead without installing any webserver on your EC2.
Yes, there are other web-servers available apart from apache: For instance Nginx plus or Lighttpd, both are fine and lightweight alternatives to host your PHP files on EC2.
Though, it's not clear to me why don't you like the LAMP setup. Maybe Apache+PHP, without MySQL, would be enough for you?
How can I change password of the mail account using php. I am using IMAP functions.
IMAP doc : http://php.net/manual/en/book.imap.php
Note: There is no acess to cpanel API
If you don't have access to the cPanel API, then you're even less likely to have root access to the various files that would be needed to make the changes.
Changing passwords is not a feature of IMAP, POP or SMTP - it's a server configuration issue, so you need to manipulate the server configuration. Several hosts provide APIs (such as cPanel / Hostgator) but you've ruled that out, so he only other option would be "exec", and I wouldn't touch that with a bargepole for cPanel, Plesk or simlar as you'd also need ot manuliplate the databases that store the configs. Ouch, if if you had root access.
Edit: A bit more reasearch and I have found this: http://trac.roundcube.net/browser/github/plugins/password/password.php that supports several back ends. However the cPanel option uses the cPanel API; so still no luck!
What you could try is mailpw_change. It is not really PHP, but a simple HTML UI with a Python script that is called underneath (which you could adapt to your needs as it's super-simple).
how do i go about adding ftp users to an apache web server? i need the user to register from normal web/script and then have an FTP account set up for them automatically.
I have seen the cPanel API, and it is pretty decent, but since cPanel costs money, i don't wish to use it for this project. I'm also reluctant to use any other lisenced piece of software.
i want to be able to do it using shell/batch (or pure PHP, though that hardly seem plausible)
Well as you said Apache is a Web and not an FTP Server. But most FTP servers like e.g. PureFtpd offer MySQL authentication. So you just have to modify the authentication table with PHP to add new users.