If you need help getting a Debian based Linux machine online, check out a post I did the other day titled: How do I set up a Next Generation Rackspace Cloud Server running Debian 7 (Wheezy)?
Okay, slap yourself in the face real quick. It's time to get started!
SSH into your machine.
Then walk through the following post: How do I install mysql-client, mysql-server, and libmysqlclient-dev on a Next Generation Rackspace Cloud Server running Debian 7 (Wheezy)? Note that you can skip the libmysqlclient-dev piece.
Great. You're back. Okay, now run the following command:
sudo aptitude install apache2You'll be prompted to "ok" the amount of space that will be used after unpacking the archives. Enter "yes" to proceed.
Apache's default document root is /var/www on Debian, and the configuration file is /etc/apache2/apache2.conf. Additional configurations are stored in subdirectories of the /etc/apache2 directory such as /etc/apache2/mods-enabled (for Apache modules), /etc/apache2/sites-enabled (for virtual hosts), and /etc/apache2/conf.d.
If you enter your server's IP address into your browser, you'll see that we're on fire!
Okay, now on to installing php:
sudo aptitude install php5PHP 5.4 will be installed. If you're setting up a Debian 6.0 (Squeeze) box and require php 5.4 (like I used to) then splash some hot coffee in your face because we've got an extra couple of steps to perform!
Run the following command:
sudo nano /etc/apt/sources.listAdd the following lines to the end of the file:
# http://www.dotdeb.org/instructions/ (but only for php54) deb http://packages.dotdeb.org squeeze-php54 all deb-src http://packages.dotdeb.org squeeze-php54 allNow save the file. Next, run the following two commands:
wget http://www.dotdeb.org/dotdeb.gpg cat dotdeb.gpg | sudo apt-key add -After doing that, we can now update our list of available packages via the following command:
sudo aptitude updateOk, now we can install php 5.4 via the following command:
sudo aptitude install php5Boom goes the dynamite! We can verify our install by running the following command:
php -vWhich will output:
PHP 5.4.14-1~dotdeb.1 (cli) (built: Apr 21 2013 05:21:34) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend TechnologiesOkay, sweet! Now that we have php installed we can put a dot php file in apache's default document root (/var/www), restart apache, and then test our new setup. To begin, run the following command:
sudo nano /var/www/info.phpThen enter:
<?php phpinfo();Save the file. Now restart apache (since we haven't done so yet since installing php) via the following command:
sudo /etc/init.d/apache2 restartNow access your new info.php page. You'll see the following:
You'll see we now have php working via the "Apache 2.0 Handler" (see "Server API" line). If you do a search for "mysql" you'll see that "mysql" is nowhere to be found! We'll need to fix that (as well as install other useful php modules). To see your options, run the following command:
aptitude search php5I recommend installing php5-mysql, php5-curl, php5-gd, php-pear, php5-imagick, php5-imap, php5-mcrypt, php5-memcache, php5-sqlite, php5-tidy, php5-xmlrpc, and php5-xsl via the following command:
sudo aptitude install php5-mysql php5-curl php5-gd php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-sqlite php5-tidy php5-xmlrpc php5-xslOkay sweet. Now we're talking! Revisit your info.php page (aptitude will have already restarted apache for you), do a search for "mysql" and then revel in your success! You are on fire!
Okay, now if you're anything like me you'd like a web interface to your remote database. PHPMyAdmin has you covered... but only if we install it! Get started with the following command:
sudo aptitude install phpmyadminAs usual you'll be prompted about incoming file size. Enter "yes" when prompted. Next, you'll be presented with the following package configuration screen:
Select "No". And boom! You've got PHPMyAdmin installed! Not! There's actually one more step. To see for yourself visit your /phpmyadmin page and observe the 404!
To fix this. Run the following command:
sudo nano /etc/apache2/conf.d/phpmyadmin.confThen add the following line to the file:
Include /etc/phpmyadmin/apache.confSave the file. Then, restart apache via the following command:
sudo /etc/init.d/apache2 restartNow revisit your /phpmyadmin page and observe your awesomeness!
Now that we've got our system set up properly we can remove our info.php file via the following command:
sudo rm /var/www/info.phpNow das wassup! Congrats, you're done! You successfully installed the latest versions of Apache, MySQL, and PHP.
If you're interested in getting your Apache hosting environment set up you should check out a post I wrote the other day titled: How do I set up Apache virtual hosts on a Debian based Linux machine and configure to support HTTPS?
No comments:
Post a Comment