Moving all files you want to host locally to /var/www/html
can be really annoying.
This script will allow you to run the apache server from the current working directory.
Enter the directory you want to host the apache server from.
And then run the command bellow:
apache-server
When you run the command, new temporary configuration will be created and copied to the apache server configuration.
As soon as you stop the server (Ctrl+C), configuration will be removed, and if there is no other apache host running, the apache service will be automatically stopped. - So you are not always hosting the default directory at localhost
.
Clone this repo to your system.
git clone https://github.com/Quartyn/apache-server
Enter cloned directory
cd apache-server
Move the apacheServerConfig
directory into the /usr/local/bin
or /usr/bin
directory (Your choice. I recommend /usr/local/bin
).
sudo mv apacheServerConfig /usr/local/bin
After it's done, you will create a new symbolic link to the apacheServerConfig/run-server
file.
sudo ln -s /usr/local/bin/apacheServerConfig/run-server /usr/local/bin/apache-server
Optional:
Here, you can also rename the symbolic link apache-server
with your preferred command name. Then, you will be able to start this command with your "own name".
For example, if you decide your symbolic link to be run-server
, you will then start the server with command
run-server
And that's all! Enjoy. Now you can run a server.