In this blog, I am going to note down how to install Apache (a.k.a. httpd) on Centos from scratch.
It is convenient and easy to install Apache of version 2.3 on Centos via yum.
Open terminal and type following commands.
Step 1: Clean up and update yum
|
|
Step 2: Install Apache(httpd)
|
|
Step 3: Once it is installed successfully, you can start running the server by
|
|
or
|
|
You may encounter following errors when typing the command above:
|
|
One way to fix it is
- Change the hostname into ip address of your own server
|
|
- Kill processes which occupy port 80
Reference1
Reference2
There you go. To test if Apache is successfully installed, direct your browser to your server’s ip address, you would see welcome page of Apache. Otherwise, it fails.
To uninstall apache, refer to Uninstall Apache
However yum can only install Apache v2.3. Some want to install Apache of version 2.4+, you need to install it from source, since yum doesn’t support higher version.
We could refer two blogs to install it from source.
How to Install Apache 2.4.2 from Source on CentOS 6.2 with SSL
Install Apache and PHP on CentOS 6
After install successfuly,
Stop service by
|
|
And then type the command:
|
|
Uncomment line
|
|
Then restart service by
|
|
Apache runs on port 80. In some versions of CentOS, a firewall, which is installed by default, blocks access to port 80. Perform the following steps to open the port.
Run following commands:
|
|
After adding that instruction, save your firewall rules so that your web server is accessible the next time you reboot.
|
|
Test the Apache installation
Navigate to your Cloud Server IP address (for example, http://192.***.14.***), it shows “It works”.
Check the version of Apache installed by
|
|
Got following messages:
|
|
To stop it
|
|