hookup Me went live in June of 2022, at this time I installed and setup our AMP environment on a pre-installed Centos (Linux) system.
This involved 3 primary applications, Apache which is a web server, MySQL which is a database, and PHP which is a programming language.
Over this last weekend I did the first big upgrade of the environment and thought with this new blog I would detail the steps to make it easier for someone else.
Downloading your source
Create a directory called /work/src, then download and untar your apache, mysql and php tarballs.
Below are three places to look, but ensure you get the latest source.
Build and Install MySQL
First create a group called mysql, then a user associated with that group. If you get any errors about the group or user already being there, don't worry and just continue.
useradd -g mysql -c "MySQL Server" mysql
Now go to your working directory, which should be something like /work/src/mysql-5.0.51b and we will begin with a very basic configure.
chown -R root:root *
Now we're ready to make and install mysql, stay in the same directory.
make && make install
MySQL is now installed, but there are a few more steps to get a working database up.
Go to your installed MySQL directory and initialize the database.
Now set correct permissions on your new install.
chown -R root:mysql /work/apps/mysql-5.0.51b
chown -R mysql:mysql /work/apps/mysql-5.0.51b/data
Copy the default configuration for mysql to /etc. Pick whichever you like, but I usually go for at least the large config.
cp share/mysql/my-large.cnf /etc
chown root:sys /etc/my.cnf
chmod 644 /etc/my.cnf
Now we need to create startup scripts so that on each server reboot mysql will restart.
cp share/mysql/mysql.server /etc/rc.d/init.d/mysql
chmod +x /etc/rc.d/init.d/mysql
/sbin/chkconfig --level 3 mysql on
Previously I've had to manually change root's password, delete test databases and other little tasks, now you can simply run the below script. You can quite safely answer "Yes" to all questions the script asks you. Make sure your $PATH is set correctly before running.
One final step I like to perform is to remove access to mysql from outside the server. I have two options for doing this, you should only pick one.
1. Allow MySQL to bind to localhost (127.0.0.1) by adding bind address = 127.0.0.1 to the [mysqld] section of your /etc/my.cnf file.
2. Allow socket connections ONLY by unhashing the skip-networking option in your /etc/my.cnf
There can be a lot more to the security of your MySQL server, however these are the basics and should set you up initially.
Create your first database instance and user
You now have your database installed, but still need to create a database instance and a user, otherwise what's the point of the database?
First, create a new database called "NewApp". Try not to add anything other than letters otherwise you may have problems.
mysqladmin -u root -p create NewApp
mysql -u root -p
You should now be in mysql and can create your user and assign that user privileges to the database you just created.
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES
ON databasename.* TO 'username'@'localhost'
IDENTIFIED BY 'password';
'databasename' is the name of your database
'username@localhost' is the username of your MySQL account
'password' is the password required for that username
Your database is up and ready to go.
Apache is a whole lot easier to install and get up and running than MySQL. The options we are going to use are fairly standard, one to notice is the deflate option. Deflate is going to be used in another post to zip content before it leaves your server which puts a little extra load on your cpu but frees up a lot of bandwidth. You can quite safely remove the deflate line from that configure command if you don't want to use it.
The SO option is so that in the future you can include dynamically loaded modules to apache, which means a smaller footprint right now with the ease of adding functionality later.
Go to your working directory and configure apache.
make && make install
You are done.
This document has been written when PHP5 is what you should be using. Options are set for that version. If you like, you can run ./configure --help and take a look at all the available options to configure php with. However I've provided a fairly comprehensive set of config options, unless you need something specific they should work well for you.
These installs have been done with Drupal in mind, so if you're running drupal, these should work great. I also have a 64bit server, so you may need to take the 64 out of specific variables.
make && make install
There are a couple of things you should do to ensure PHP is ready. Specifically put your config in place and update it.
cp /work/src/php-5.2.6/php.ini-recommended /work/apps/php/etc/php.ini
ln -s /work/apps/php/etc/php.ini /work/apps/php/lib/php.ini
PHP is installed.
Integrate Apache, MySQL and PHP
Now all your applications are installed, you just need to tie them in to work together. You've already
linked PHP to MySQL in PHP's configure command so they know how to communicate, the only thing left is to edit your Apache config to deal with PHP correctly.
Edit your httpd.conf file, located under /work/apps/apache-2.2.8/conf and ensure the following options are set.
The below entry should be in your DSO support section :
LoadModule php5_module modules/libphp5.so
Then you want to make sure that index.php is a valid index file, so ensure that at least index.php and index.html are in the DirectoryIndex setting.
DirectoryIndex index.php index.htm index.html
To ensure that php files are interpreted correctly and not just displayed as text files, you should add the following lines, you'll find the right spot with the other AddType entries.
# Interpret PHP
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Config complete, get ready to start apache.
First step, lets make sure Apache starts on reboot.
ln -s /work/apps/apache-2.2.8/bin/apachectl /etc/rc.d/init.d/apache
ln -s /etc/rc.d/init.d/apache /etc/rc.d/rc3.d/S90apache
Then start it.
You Should now be up and running, with whatever application you're hoping to run or just ready to create your own website.
I hope the guide has been useful, it is obviously a little specific with directory names and versions. You should be able to substitute everything and figure out the small differences between my environment and yours.
Should you require help, I can provide a small amount of free assistance. If it becomes too much I'll either need to direct you to a website or a fee will be required.
There are many other options you can use, you can of course get further into the security and setup of each application and find what works best for you.
Thank you for taking the time to read this and I hope it all worked well for you.