Introduction
Target of this writeup is keeping track how to set up a VPS. It's for absolute beginners, so experts please comment.Base OS: Centos 5
Target setup:
- Apache 2.2, with mod_ssl and mod_ruid
- PHP 5.2, with APC and Uploadprogress
- Mysql 5
- Proftp
- Webmin
Putty, SSH client
Install Utter Ramblings Yum repository
CentOS 5 comes standard with PHP 5.1, some other repositories come standard with 5.3, which will either limit functionality or provide errors. So I will use the Utter Ramblings Yum Repository.Login to your server as root with Putty, speedup Yum a little and update your server:
yum install yum-fastestmirror
yum update
I personally like to use the simplest of editors: vi. Open or create a file as above, start editing with "i", stop editing with help button "F1", save the file with "ZZ" and exit with ":q!".
vi /etc/yum.repos.d/utterramblings.repo
[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
Read more: http://www.jasonlitka.com/yum-repository/#ixzz0iK46UmBx
Press "F1" and "ZZ" to save and exit. Run update again:
yum update
Install Apache and PHP
Installing Apache, with development tools, mod_ssl and mod_php:yum install httpd httpd-devel mod_ssl mod_php
You could be running into problems here when packages cannot be found. Some setups of Centos protect against certain updates to make sure the system keeps on working. If so, check:
vi /etc/yum.conf
and look for a line that start with "exclude". If it's there, comment it out with "#" after pressing "i". Press "F1" and save with "ZZ". Repeat the yum command before. Point your browser to your domain or ip-address and see something working there.
Make a info.php file to check if PHP is working and it's configuration.
vi /var/www/html/info.php
<?php
phpinfo();?>
Point your browser to www.yourdomain.com/info.php or 123.123.123.123/info.php. You should now see the text above appearing in your browser. Since we just installed PHP, Apache is not booted with PHP. So we just have to restart it:
service httpd restart
And we reload the browser to see the PHPinfo page. As you should be able to see, PHP needs some more goodies to be really useful.
Dressing up PHP
Installing APC (a cache, which should work?) and uploadprogress (to get rid of those annoying status report errors).yum install php-pear php-devel
Install a C++ compiler:
yum install gcc gcc-c++ autoconf automake
Then:
pecl install apc uploadprogress
Include in php
echo "extension=apc.so" > /etc/php.d/apc.ini
Which will make a small file in /etc/php.d/ containing "extension=apc.so", and so telling PHP that it should be included. Drupal will warn you that the standard APC memory of 30mb is not enough. To up it a little, edit:
vi /etc/php.d/apc.ini
and add:
apc.shm_size=48
Same for upload progress:
echo "extension=uploadprogress.so" > /etc/php.d/uploadprogress.ini
And restart apache
service httpd restart
Check info.php and find both APC and uploadprogress installed now. Now for some graphics. Let's install GD2
yum install gd php-gd
and Imagemagick
yum install ImageMagick ImageMagick-perl ImageMagick-devel
Then:
pecl install imagick
Add the ini file
echo "extension=imagick.so" > /etc/php.d/imagick.ini
Install the php mbstring module Drupal needs and php-xml for Drupal 7 (dom).
yum install php-mbstring php-xml
Restart Apache to see the changes:
service httpd restart
And see in info.php (Thanks!)
Installing Webmin
Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely.Making the Webmin repository:
vi /etc/yum.repos.d/webmin.repo
and paste there:
[Webmin]
name=Webmin Distribution Neutral
baseurl=http://download.webmin.com/download/yum
enabled=1
gpgkey=http://www.webmin.com/jcameron-key.asc
Then just do
yum install webmin
Now point your web browser to www.mydomain.com:10000 and login as root. (More info)
You could now surf to Others, PHP Configuration, Resource Limits and change the Maximum memory allocation to 128M. Safe and check your info.php and see the memory_limit has changed to 128M.
Installing ProFTPD
ProFTP is probably the easiest FTP server on Centos, which is not shipped with Centos, so we will install another repository first.vi /etc/yum.repos.d/dag.repo
And add
[dag]
name=DAG RPM Repository
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
Update the system and install Proftpd
yum update
yum install proftpd
Done! (More info) Make Proftpd start at startup and start now:
chkconfig --levels 235 proftpd on
service proftpd start
Username = "username"
Home directory = Automatic
Shell = bin/bash
Password = "password"
Primary group = New group with same name as user
Create home directory? = Yes
Copy template files to home directory? = Yes
Create user in other modules? = Yes
Startup your ftp program and connect to your web server using the username and password above. Make a new directory public_html and another one in there public_html/drupal6 and upload all Drupal files to that directory. (More info)
Compile mod_ruid
Mod_ruid makes Apache change username and group to the files it uses at the moment. So if it's working in the home directory of drupaluser, it will behave like it is drupaluser, opening and writing files like it is you and limiting itself to drupalusers home directory. Another option would be SuPHP, but that's considered slow.Development of mod_ruid seemed to have stopped a few years ago. Luckily somebody picked it up and continued the effort on Sourceforge with a list of new releases. Check for the latest release, for now mod_ruid2-0.9.tar.bz2.
Install dependencies:
yum install libcap libcap-devel
cd /tmp/
wget http://sourceforge.net/projects/mod-ruid/files/mod_ruid2/mod_ruid2-0.9.tar.bz2
tar -xvwf mod_ruid2-0.9.tar.bz2
cd /tmp/mod_ruid2-0.9/
apxs -a -i -l cap -c mod_ruid2.c
service httpd restart
Careful! If you update Apache to a newer version, you might have to do the step above again.
(Thanks!)
Installing Mysql
Install MySQL and dependencies as follows:yum install mysql-server mysql php-mysql php-pdo
chkconfig --levels 235 mysqld on
service mysqld start
/usr/bin/mysql_secure_installation
Enter current password for root (enter for none): "enter"
Set root password? [Y/n] "y"
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
Click on MySQL Database Server under servers. If it is not there, you might need to do a "Refresh Modules" on the left below.
Tell Webmin the root user (root) and your new password.
Create a new database for your Drupal website.
-> Create a new database.
Name: anything you like
Character set: utf8
Collation order: default
Initial table: none
Now make a new user
-> User Permissions
-> Create new user.
Username: drupal
Password: anything you like
Hosts: localhost
Permissions:
Select table data
Insert table data
Update table data
Delete table data
Create tables
Drop tables
Manage indexes
Alter tables
Create temp tables
Lock tables
Restart Mysql and Apache
service mysqld restart
service httpd restart
(More info)
Finalize
Make a new virtual host for your domain.In Webmin: Servers > Apache Webserver > Create virtual host
Handle connections to address = Specific address = your domain name
Document Root = path to your installation of Drupal
Copy directives from = Nowhere
Safe and "Apply Changes" in the upper right.
Open your new virtual server
Edit Directives and add
AllowOverride All
just above ""
Safe and "Apply Changes" in the upper right.
And your server should be working.
0 comments:
Post a Comment