Here's a job you'll get often as a systems administrator: install and configure a new server with LAMP software package: Apache + MySQL/MariaDB + PHP, including apache mod_ruid2.
To be honest with you, it's not very exciting but let's dig in anyway.
Let’s assume that we have freshly installed CentOS 6 server that needs to be configured.
You probably want to run the updater first and wait for it to finish:
[root@ServerSuitTest ~]# yum update
Then we need to install apache2 package:
[root@ServerSuitTest ~]# yum install httpd
Let’s add ServerName directive to the Apache config file, allow Apache daemon launch at server boot and start it immediately:
[root@ServerSuitTest ~]# chkconfig httpd on [root@ServerSuitTest ~]# echo ServerName *:80 >> /etc/httpd/conf/httpd.conf [root@ServerSuitTest ~]# service httpd start
If you try to open the default Apache page right now, however, you'll likely see a connection error page in your browser. The problem is that CentOS's default iptables configuration restricts any connections to the server except SSH connections and ICMP protocol packages.
So you need to add iptables rule for HTTP protocol and save iptables config:
[root@ServerSuitTest ~]# iptables -A INPUT 1 -p tcp --dport 80 -j ACCEPT [root@ServerSuitTest ~]# iptables-save > /etc/sysconfig/iptables
We also need to install apache mod_ruid2 package, which requires some prerequisite packages itself:
[root@ServerSuitTest ~]# yum install httpd-devel gcc libcap-devel
After that, download the latest version of Apache mod_ruid2 from https://sourceforge.net/projects/mod-ruid/files/latest/download, compile and install it:
[root@ServerSuitTest ~]# tar xvf mod_ruid2-0.9.8.tar.bz2 [root@ServerSuitTest ~]# cd mod_ruid2-0.9.8 [root@ServerSuitTest mod_ruid2-0.9.8]# apxs -a -i -l cap -c mod_ruid2.c
That's the end of the setup; mod_ruid is compiled and will be loaded after Apache2 restarts.
You should now check to make sure it's configured correctly by running the commands shown below:
[root@ServerSuitTest ~]# cat /etc/httpd/conf/httpd.conf | grep ruid2 LoadModule ruid2_module /usr/lib64/httpd/modules/mod_ruid2.so [root@ServerSuitTest ~]# service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]
Now, let’s install MariaDB server:
We’ll need to add a MariaDB repository first, by editing the file /etc/yum.repos.d/MariaDB.repo and adding in following lines to it:
[root@ServerSuitTest ~]# nano /etc/yum.repos.d/MariaDB.repo [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1.12/centos6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1 [root@ServerSuitTest ~]# yum install MariaDB-server MariaDB-client
Just as we did with Apache daemon, we need to allow MariaDB server to start at boot. We also need to manually start it up the first time we run it:
[root@ServerSuitTest ~]# chkconfig mysql on [root@ServerSuitTest ~]# service mysql start
And finally install PHP:
[root@ServerSuitTest ~]# yum install php php-mysql php-common php-mcrypt \ php-xml php-gd php-devel
Then we’ll need to restart Apache daemon so our changes takes effect:
[root@ServerSuitTest ~]# service httpd restart
Now you can test that it’s working:
[root@ServerSuitTest ~]# echo "<?php phpinfo(); ?>" > /var/www/html/index.php
You can go to http://<your server IP address>/index.php and see PHP configuration info page:
Basic installation and configuration of LAMP is complete.
I really hope this was more fun for you than it was for me.
You can go through these steps everytime you need to setup LAMP. I got to let you know, though, that ServerSuit has the whole LAMP stack pre-configured!
Once you add your server to the dashboard, you just need to select the LAMP package, and click install. Does it make it more fun? Unlikely, but it does make it faster and easier, which is still a win for everyone.
Go to ‘Software’ tab, choose ’LAMP package’, and click to ‘Install LAMP Package’ button.
Within minutes, depending of your server bandwidth, you’ll have completely configured LAMP server. Don't forget to follow us @serversuit to keep up with new articles and updates.