How to set up a web server? [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have been asked to setup an online web server (e.g, digital ocean) and describe the steps I took. (e.g, installing and configuring private keys, firewall and web server).
And also what steps did I take to secure my setup?
I know very basic about php and HTML and this my first time setting up an online web server. My main question is that to set up an online web server I must pay money and buy space or I should use my own PC as a web server. which one is easier? I am trying to stick to the above question. Any help or reference to guide me will be appreciated.

There are a few elements to consider here, for the server, you need this
computer
operative system (windows, linux, mac, ...)
setting user access and user restrictions
setting a firewall
set remote access if needed (ssh, vnc)
For the web part of the question, you need this
web server software (apache, lighthttpd, nginx, iis, ...)
server side programming/scripting language if needed (perl, php, asp, ...)
If you can use a PC that you already have, use that one, after, you will have to mae that computer reachable from the exterior, for that, you have so give your external IP to the people that is going to use it, if you have a fixed ip, use that one, if you don't, then use something like dyndns.
Of course, if you have a router, then you have to configure that router to pass the requests to port 80 to your PC serving as web server. You can start learning about that process with this search about setting a NAT
You don't have to use a dedicated machine for this, you can also use a virtual machine on your existing system, check VirtualBox, one of the easiest to set up.
All that are just the most basic steps, some are very simple, some are more complex. Definitely you don't have to buy/rent a server, although, it may be easier that doing all the work yourself. If this is for a school/university assignment, check the conditions applied and if you can use a PC/virtual server on their machines. If this for work, hire somebody that knows how to do it and if you want to learn, stay close to that person.

Hmm paying would probably be easier but you wouldn't learn anything.
My advice would be download Debian linux and install it to a computer you don't use. Then install apache.
Debian is pretty easy to install, they supply a gui, but there's also a guide here that's very in depth.
Also apache is as easy as sudo aptitude install apache2, and your documents will need to be in /var/www to show up online. Make sure your ports are forwarded. A good guide, again, is the Debian documentation here.
As far as securing it goes, make sure ssh only accepts keys, and not passwords. Also close any ports you don't need.

Related

How do I convert a php web application into a desktop application and retain database [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
We have a web-application developed in PHP. But most of clients don't have internet connection all the time. So, is there way to convert the app into a desktop application so that it works stand alone and it syncs to web application whenever there is an internet connection? Currently I am testing it locally via xampp and it works but I dont want to have to install xampp or wamp on a clients pc. I am an amateur at coding FYI. I would appreciate any precise answer with example.
A nice and simple way to do that without having to go through XAMPP or LAMP installation making it really simple to your users is to use PHP built-in server as of PHP 5.4.0.
$ cd ~/public_html
$ php -S localhost:8000
You can test this by adding an index.php in the public_html directory and then just run the command $ php -S localhost:8000 inside public_html. Open up your browser and type localhost:8000 so you can see your index.php file.
Another important thing is that your users must have Mysql installed (or whatever DBMS you are currently using).
Source PHP documentation
To avoid installing server on every client pc you can use Virtual Machine, so you would have same environment and just copy to every pc you need.
To keep the source code up to date (when connected) use GIT or other version control system (SVN may be easier to get into).
You have to install mysql or whatever DBMS you are using at backend as well as install XAMPP or any other server to run PHP script. If you dont want to install full XAMPP you can use portable XAMPP which is just copy and paste.
You can right a script which can keep checking after specific intervals, if internet is available then synch database with live server.

Is it possible to fully simulate linux web server on windows machine with cygwin? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
This is a theoretical question and hope you won't refuse it directly.
The problem I am having is that I am working both on front-end and back-end development. Basically by day I am fron-end developer which involves a lot of different browsers, Photoshop and other tools needed for design/fron-end work. But by night I am heavy php developer.
Now this is quite a tricky situation. As a back-end developer I would really love to use linux server, same as production servers for projects, which will be much easier to synchronize. But as a front-end developer I need all the tools, that are available mostly for windows.
I have been looking long time for a solution OTHER than virtual linux machine. Finally i ran into the Cygwin. It looks promissing, but my question is, can I fully simulate linux webserver with this tool? are there any limitations?
I would appreciate any opinion, also if you know about some elegant way/tool how to achieve what I need, please share it with me.
Thank you!
EDIT:
Why I don't want to use virtual machine:
It takes too much RAM. If I run IDE, Photoshop, Virtual Machine etc. my PC has hard time to catch UP
I am looking for "seamless" solution. Something that can run quietly on my background, best as a service.
File sharing. I know it is possible to share files between PC and virtual machine but I just don't feel like it is very elegant solution
I had something more on my mind, but this is what I could come up with so far.
Basically Linux is pretty amazing, and I just cannot believe there would not be any simplier, less-robust solution to this problem than installing whole linux system.
Wish I could help more, but right from cygwins website it says "Cygwin is not: a way to run native Linux apps on Windows."
That said, it appears some people have got a lamp stack working in Cygwin and also here
So it sounds possible, but I have to re ask the question of why you would want to. Seems extraordinarily complex when you could install virtualbox and a turn key linux solution to get a real environment that is much easier to troubleshoot.
If you do get it working, I'd love to see a blog post on how you got it.
It depends what you mean by "fully simulate".
You can run an apache web server in cygwin, but it is quite difficult to set up. By a strict definition of "fully simulate" this is already quite different, the steps to set up the web server are different from a real linux machine.
Given that PHP already abstracts a lot of the underlying system away from you, you might find that there is really very little difference (for most purposes) in going down this path vs just installing wamp for your development.
Rather than install a virtual machine on your dev system you could also get a free amazon instance (for the first year) and do your web dev on that.
You can run Apache with PHP on a windows machine without any hassle at all. You do not even need Cygwin.
I run Apache+PHP and use it for development. I have not had any problems with transferring to a Linux machine. I use FTP Sync to update the Linux machine with just a click on an icon and it just updates the necessary files.

SSH package for PHP? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Ok this may seem like a very, very awkward question but here's my problem:
I need to be able to SSH to my site while at the library at my school but the only thing is that it NEVER works if I try to FileZilla it or puTTy it. I am not even using port 22 rather a separate port. Still it seams as if it is blocked.
I was wondering if I could use some package that I can add to my admin section on my site so I can ssh to my site directly from the browser (Also my school uses windows so doing ctrl+x in nano doesn't work.
I would preferably use PHP, as I can not use any other Server Side language (technical reasons) and I am pretty noob to websites and stuff, this is my first project as such.
PHP has an excellent built-in SSH package (via pecl): http://us2.php.net/manual/en/book.ssh2.php
If you don't already have it, here are installation instructions: http://us2.php.net/manual/en/install.pecl.intro.php
Check out phpSecLib. It implements the SSH protocol in PHP and is pretty common for this type of thing.
There are others available too if you search for something like "PHP SSH client"
It seems like you want to run commands on your own server. Installing an SSH library for PHP will not help you in that regard, unless you ssh from your server to itself. How about using a php web shell?
You'll have to make sure to secure it but it should allow you to run any commands you need within the browser.
The connection from your school to the Internet is probably protected by a firewall.
In the easiest case the workstations in your school have direct access to the Internet but the firewall blocks connections to most ports. If this is the case you can try running sshd on port 80, the port used for HTTP.
In a more complicated case the workstations must pass through a HTTP proxy in order to access web pages. Apparently Putty allows connecting to an SSH server through a HTTP proxy, you just have to configure it correctly.
None of this requires PHP modules as the connections are made directly to sshd.

How to edit php files locally? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
With HTML files, I can work locally and preview the files in my browser after I've saved and made changes (and use LiveReload), but with PHP the browser just loads the code. Do I need to run a local server to work on it locally, or is there an easier way?
The extent of my PHP is using include statements for headers and footers.
Yes you will need a local server to run PHP scripts locally. Check out MAMP for Mac or XAMPP for PC.
Yes, you'll need to install something such as WAMP
No - since php is a serverside interpreted language you have to run a server. The easiest way is to install xampp whick brings everything you need - apache, mysql, php.
On windows you could also install IIS server which is part of windows
You can very easily download and set up a server - and on that note, yes do do need to have PHP and Apache set up to have PHP working.
I would probably suggest something like WAMP - it is basically pre-setup and requires very little config to get up and running. This will come with Apache Server, MySQL and PHP set up nicely to work together and comes with a very easy to use point and click interface. Oh, and it even installs PHPMyAdmin so that you can easily work with your databases if you are not familiar with console controls.
You need to set up a server that can serve php requests appropriately. However, this is incredibly easy to do. Just google how to install a LAMP server (on Linux), or look into WAMP (on windows). If this is still too much for you, look into purchasing a shared hosting account or something. I have a small one for like $15 a year. They will have the servers set up with everything you need already; you'll just have to upload the files.
Yes, you need to run a local server to 'work with it'. I would suggest XAMPP. To actually edit the files, you of course need a text editor. Any editor will do as far as I'm aware, but I use Notepad++ myself, or even the NetBeans IDE.

Should I move client to Lamp or develop on Wamp?

I have never developed for WAMP, the hosting guy for my new client says they are using Windows servers, they can setup PHP and MySQL for me, but they cannot switch to a *nix server.
He said there are some nuances from PHP on *nix Vs. win.
So my question is, if I have never programmed PHP on win, should I go through the hassle of switching hosts (since they cannot do *nix themselves), or are the differences slight enough that it shouldn't be too big a problem for me?
(side note: the state of the clients website has no effect since it is a static all-flash site and is going to be completely rebuilt)
Thanks!
I would suggest XAMPP which is a complete LAMP package which will install on either Windows or Linux.
You can do all your development on your local machine this way.
Edit to address the actual question: Before bringing this up with the client, here are some things to consider:
What is your relationship with the client? Is this a one project deal, or do you hope to continue working for them? Either way, do you want to get a good reference from them? Are you a long established service provider with a high level of trust, or a new face who has yet to prove themselves? How would they respond if you suggest that they change? Would they mind switching web hosts?
How comfortable are you working with Windows in general? Can you can use it with moderate skill and comfort?
What is your time frame for project completion? How long would it take to find a new hosting service and get set up? How will this impact your scheduled completion?
Ultimately, if you decide to raise the issue, the client has to decide whether they want to move to a new hosting company. Some factors to consider there include:
How long have they been with this host? How good or bad is the relationship between your client and their hosting company. What contractual obligations are in place between them? Would your client have to pay to leave?
After you finish the initial development, who is going to maintain and administer the system (you or someone at the client company), and which system do they know?
Now, if you want to use Windows, I'll mention that, in addition to XAMPP, the WAMP server, which will run on just about any modern version of Windows. I used it for a class (where it was required), and then on a development system for a project at work that ultimately ran on a Linux server. Both ran Windows XP. I don't recall needing to make any changes when copying the PHP from Windows to Linux, although I did stay away from any functions which would have been platform dependent. FWIW, I found WAMP very easy to set up, administer, and use.
I'd suggest to avoid windows hosting. There is no much difference for the PHP as it already multiplatform, but windows is not an option for the public host. Less performance, less security, less operability.
Also, note that they never administer php installation, so, it will be trouble in support.

Categories