Earlier this week we talked about Linux CentOS version 6.4 distribution. The article was about how to install CentOS 6.4 on a new computer or spare hard drive, including step-by-step screenshots. Today, following this, we will show you how to setup a development web server for your CentOS 6.4 installation, including database software MySQL, web server Apache and PHP language.
– CentOS 6.4 installation. See our guide here.
How to setup CentOS 6.4 Web Server
1. Open a terminal session. Right anywhere on your desktop and select ‘Open in Terminal’.
2. Login as ‘root’ using following command : su
3. Create a custom user (command : useradd username) for the web server, in our example we chose : webuser
4. Verify that user has been created. Type the following command : cat /etc/passwd | grep webuser
5. Change webuser’s password using the following command : passwd webuser
6. Add webuser to the sudoer list (root privileges). Type the following command : visudo. Add the following : webuser ALL=(ALL) ALL
7. If you intend to run it as a production server you will need to configure iptables to accept http connection. In our case we deactivate it, since it’s a development server. Type the following 2 commands to do so : service iptables stop && chkconfig iptables off
8. Update and confirm your packages using : yum update
9. Install web server packages. This will include web server (apache), database server (mysql), php language and php connection to database module. To do so, type the following command : yum install httpd php mysql-server php-mysql
10. Type the following commands to configure and set permissions to your web server :
chown apache:apache /var/www/html/ -R
chcon -R -u system_u -t httpd_sys_content_t -r object_r /var/www/html/
11. Next step is to start web server and database server (MySQL). To do so, please type the following command :
service httpd start && service mysqld start
12. Edit index.html webpage to test your web server. You can edit it using the following command : nano /var/www/html/index.html
13. Test your webserver by browsing local ip address : 127.0.0.1
Installing a clean and stable web server with database on CentOS 6.4 is as easy as pie. Only need a few minutes of your time and you can start develop php code. Stay tune, we will show you soon how to install wordpress.