Quantcast
Channel: Web Host
Viewing all 31 articles
Browse latest View live

Fastest Way of Installing Drupal 7.23 on Mac OS X 10.9 , 10.8, 10.7

0
0

Fastest Way to install the latest Drupal 7 version on Mac OS X Mavericks 10.9 or 10.8 

 

fast-drupal-osx-mavericks

Drupal is a quality CMS application and is as simple or complex as your needs vary, it runs on the same foundations that Mac OS X Mavericks or Mountain Lion, Lion or Snow Leopard provides similar to a Linux environment.

This tutorial assumes a certain degree of comfort in the command line application (in the Utilities folder) Terminal for installing Drupal 7 on Mac OS X Lion or Snow Leopard but if the instructions below are followed correctly it will get the job done easily. If you would rather have a point and click install - follow the Drupal OSX guide here.

Before proceeding Drupal needs a couple of things to get going and those things are what is called an AMP stack  - Apache, MySQL and PHP. Apache and PHP already come bundled in OS X and just need to be enabled but MySQL needs to be downloaded and configured, luckily a point and click installer is provided. 

Optionally and preferably also install phpmyadmin to manage the database from a browser. To get the AMP stack working correctly on OS X follow this guide on Apache/MySQL/PHP  and for phpMyAdmin if required. Once these components are in place you are OK to proceed. Or you may already have an AMP stack by using MAMP or XAMPP.

OS X has 2 web document roots '/Library/WebServer/Documents' and '/Users/username/Sites/' also known as '~/Sites' this guide uses  '~/Sites'. This tutorial assumes that the shared drupal directory will be called "drupal". The mysql database will be called drupal and the mysql user is root. This takes into account that OS X has Apache/MySQL/PHP and phpMyAdmin all ready installed and runnng. All of the installation takes place in the command line using OS X's Terminal application.

Drupal Download and Configure

Make a sharing directory and move into it:

mkdir ~/Sites/drupal ; cd ~/Sites/drupal

get the latest drupal,  swap 7.x for incremental updates[

curl -O http://ftp.drupal.org/files/projects/drupal-7.23.tar.gz 

expand it

tar -xvzf drupal-7.23.tar.gz  

move all files into shared directory one level up

mv drupal-7.23/* .

move hidden files one level up

mv drupal-7.23/.* .

remove compressed archive and empty directory

rm -rf drupal-*

create a settings file

cp ~/Sites/drupal/sites/default/default.settings.php ~/Sites/drupal/sites/default/settings.php

fix permissions on the default directory and settings file

chmod -R a+w ~/Sites/drupal/sites/default

or do the first lot in one hit (good for a script for multiple installs) 

mkdir ~/Sites/drupal ; cd ~/Sites/drupal ; curl -O http://ftp.drupal.org/files/projects/drupal-7.23.tar.gz ;tar -xvzf drupal-7.23.tar.gz ; mv drupal-7.23/* . ; mv drupal-7.23/.* . ; rm -rf drupal-* ; cp ~/Sites/drupal/sites/default/default.settings.php ~/Sites/drupal/sites/default/settings.php ; chmod -R a+w ~/Sites/drupal/sites/default 

Create the Drupal Database

create a new database (no space between -p and password - as an alternative this can be done in phpmyadmin

mysql -u [username] -p[password] -e "create database [databasename];"

or in phpMyAdmin

phpmyadmin-drupal-database-create

 

Finish the Drupal Install

 

Open - http://localhost/~username/drupal/

 

osx-fast-drupal-install

 

 All done! faster than you can say "bitnami" If this is your first time installing Drupal, go with the Standard option

Then when you get to the Database configuration put in the details you used to set up MySQL in this case the db was "drupal" and the db user was "root". In the advanced options you can tweak the db prefix, port and host, the default "localhost" should be fine for this purpose.

Next steps are to create a master admin account and a few generic system settings and you are done.

finish-drupal-install

Post Installation Tips

As a foot note, to sort out clean URLs, the .htaccess needs a tweak as the install is in a subdirectory, the "RewriteBase" needs to be explicitly set:

# If your site is running in a VirtualDocumentRoot at http://example.com/, 
# uncomment the following line:
RewriteBase /~username/drupal

And also for smoother compatibilities for Drupal upgrades and module/theme add on installs change the local ownership to _www on your drupal web shared directory

sudo chown -R _www ~/Sites/drupal

Upgrading Drupal

To upgrade an incremental version of Drupal - say from 7.12 to 7.23, you download the new core base files and replace the current files in the web root apart from the Sites directory, and if customized, also the .htaccess file.

After replacing the files run a database update: http://mydomain.com/update.php or from within Drupal Admin > Reports > Available Updates > Update to patch any software.

Thats it Drupal should be up and running!


Backing Up a VPS cPanel Server to Amazon S3 Bucket

0
0

Some webhosts offer remote backup storage at a cost, some do random weekly backups and don't like to talk about it - but will do a restore on request at a cost. With cheap available cloud service at hand why not shift that back up data totally offsite up to the cloud. Here is a tutorial to script a linux cPanel VPS backup to an Amazon S3 bucket.

Create the Bucket

First thing you need to do is set up your Amazon S3 service and create a bucket to dump stuff in. Get your secret key ID and Access ID logged down for later use.

Install Amazon S3 CLI Tools

Next thing to do is to install Amazon S3 command line tools on to your cPanel Server, you will need access to the command line and need to add the repository that the tools are in - this guide is based on the Cent OS system.

Go to the repository directory

cd /etc/yum.repos.d

Get the S3 Command Line Tools Repo for CentOS 5 or 6

wget http://s3tools.org/repo/RHEL_5/s3tools.repo

or

http://s3tools.org/repo/RHEL_6/s3tools.repo

This will add the s3tools.repo

Install the S3 Tools

yum install s3cmd

installing s3 tools to cpanel

Configure the Tools

s3cmd --configure

This is where you need your access key ID and secret key and then a encryption password which you need to set.  You will need to make a call on whether you use an encypted transfer or not, pay off being the encrypted transfer will take longer.

You are also asked to verify the path to gpg program it prompts the default which in most cases is correct

/usr/bin/gpg

After you have added in your details run the test to verify the connection and save the settings. If you need to edit the settings at a later date just run the s3cmd --configure command again. The configuraton file is saved in roots home.

/root/.s3cfg

Using the s3cmd tool

List your S3 buckets

s3cmd ls

Make a new bucket

s3cmd mb s3://bucketname

To see all the options and parameters

s3cmd --help

Enable WHM/cPanel Backups

If you haven't already got it going, enable the backups.

cpanel-whm-configure-backup

This will save your backups on your cPanel server by default at

/backup/cpbackup/

And then in daily/weekly and monthly directories, depends on what freqency was enabled as above in the 'Backup Rentention' options.

Getting the BackUp Script in Order

First up is to make a space for the log files so you can see the successes and failures

mkdir /var/log/backuplogs

Save the script as

/root/dailybackup.sh

In the script pasted below, the backup rotation degree is set as 2(“DEGREE=2″ ,). This means that, 2 days old backup will be deleted automatically. You can increase this backup retention period by adjusting the “DEGREE” variable.

This script is set to copy the backups which cPanel generates for the daily backup from the directory below (the script is not mine it belongs to the Jackal all kudos to him on that).

/backup/cpbackup/daily

The script:

 

#!/bin/bash

##Notification email address

_EMAIL=your_email@domain.com

ERRORLOG=/var/log/backuplogs/backup.err`date +%F`

ACTIVITYLOG=/var/log/backuplogs/activity.log`date +%F`

##Directory which needs to be backed up

SOURCE=/backup/cpbackup/daily

##Name of the backup in bucket

DESTINATION=`date +%F`

##Backup degree

DEGREE=2

#Clear the logs if the script is executed second time

:> ${ERRORLOG}

:> ${ACTIVITYLOG}

##Uploading the daily backup to Amazon s3

/usr/bin/s3cmd -r put ${SOURCE} s3://Backup_daily/${DESTINATION}/ 1>>${ACTIVITYLOG} 2>>${ERRORLOG}

ret2=$?

##Sent email alert

msg="BACKUP NOTIFICATION ALERT FROM `hostname`"

if [ $ret2 -eq 0 ];then

msg1="Amazon s3 Backup Uploaded Successfully"

else

msg1="Amazon s3 Backup Failed!!\n Check ${ERRORLOG} for more details"

fi

echo -e "$msg1"|mail -s "$msg" ${_EMAIL}

#######################

##Deleting backup's older than DEGREE days

## Delete from both server and amazon

#######################

DELETENAME=$(date  --date="${DEGREE} days ago" +%F)

/usr/bin/s3cmd -r --force del s3://Backup_daily/${DELETENAME} 1>>${ACTIVITYLOG} 2>>${ERRORLOG}
 

What you need to change in the script:

  • email address
  • source (if not /backup/cpbackup/daily
  • S3 bucket name - which is in the script in 2 places

Set the correct permissions on the script

chmod u+x /root/dailybackup.sh

To run it daily, copy it to cron

cp -p /root/dailybackup.sh /etc/cron.daily/

To run it after the regular cPanel back up, create a file

/scripts/postcpbackup

With the content

#!/usr/bin/perl
system(“/root/dailybackup.sh”);

Give it some perms....

chmod 755 /scripts/postcpbackup

The final thing to do is to create a symbolic link of the s3cmd configuration to the root level, otherwise an error is received in the log.

ln -s /root/.s3cfg /.s3cfg

That should do it check your bucket after and you should see your backups - if not check the error log and see what went wrong:

/var/log/backuplogs/

Tags:

Connect to Amazon S3 Bucket from the Command Line in OS X

0
0

This process requires a couple of Unix tools installed, s3cmd and gpg (optional), s3cmd is the command line tool used to connect to Amazon S3 and gpg is an optional secure tool allowing data transfer to be encypted over HTTPS between you and Amazon.

This guide uses Homebrew to install the 2 required programs, this can also be done with MacPorts.

You will already need to have your Amazon S3 buckets set up and need to have Access ID and Secret Key ready to be pasted into the Terminal.

Install s3cmd

brew install s3cmd

Install gpg

brew install gpg

Configure s3cmd

s3cmd --configure 

When prompted paste in your Access key, Secret key and encryption password, the encyption password has to be made by you. The path to gpg is:

/usr/local/bin/gpg

Thats all you need to do.

Using the s3cmd Tool

To list all your buckets:

s3cmd ls

To list contents of a bucket:

s3cmd ls s3://mybucket

To get something from the bucket and move to your desktop:

s3cmd get s3://mybucket/my-needed-file.png ~/Desktop

And the reverse to put something to the bucket - using the -P flag to make it public:

s3cmd -P put ~/Desktop/my-file.png  s3://mybucket/

To delete a file:

s3cmd del s3://mybucket/my-file-to-delete.png

Check the man for more options

man s3cmd

How to set up Virtual Hosts in Apache on Mac OSX 10.9 Mavericks and OSX 10.8 Mountain Lion

0
0

Setting up Virtual Hosts in Apache on Mac OSX 10.9 Mavericks or Mountain Lion is straight forward after you have your local Web Development environment up and running - get your web development up and running first following the AMP stack guide here 10.8 or 10.9 if required.

The process of setting up Virtual Hosts is done easier in the Terminal either using nano or vi with sudo or as a root user,  or you can you a GUI visual editor like Text Wrangler which allows access to the /private/etc directory by clicking 'Show Everything" in the open dialog box.

Allow the vhosts configuration from the Apache configuration file httpd.conf

sudo nano /etc/apache2/httpd.conf

Search for 'vhosts' and uncomment the include line

# Virtual hosts

Include /private/etc/apache2/extra/httpd-vhosts.conf
 
This will allow usage of the httpd-vhosts.conf file, open this file to add in the vhost.
sudo nano /etc/apache2/extra/httpd-vhosts.conf
 
An example in the file is given of the format required to add additional domains, just follow this to create your new virtual host:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/usr/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>
 
We can take this example and extend on it, if you wanted a domain named apple.com for example, you can copy the existing text block and edit to suit:
<VirtualHost *:80>

    ServerName apple.com

    ServerAlias www.apple.com

    DocumentRoot "/Users/username/Sites/apple"

    ErrorLog "/private/var/log/apache2/apple.com-error_log"  CustomLog "/private/var/log/apache2/apple.com-access_log" common

    ServerAdmin neilgee@coolestguidesontheplanet.com

        <Directory "/Users/neilg/Sites/apple">

            Options Indexes FollowSymLinks

            AllowOverride All

            Order allow,deny

            Allow from all

        </Directory>

</VirtualHost>
 
So here I am creating a vhost for apple.com and making the document root in my Sites folder, in the text block above I have also added in some directory permissions and a server alias to also use the 'www' prefix, what you need to change is the document root location, email address and domain name to suit your needs. Finish and save the file.
 
One of the better workflows is to create a 'Sites' folder and store your vhosts in it - but now also you need to spoof the IP address to be the local one, the set up of these using the User/Sites folder is outlined in the links above for the initial AMP stack guides.
 

Spoof Your IP address to the Domain

sudo nano /etc/hosts
 
Add the Domain to resolve to the local address 
127.0.0.1 apple.com
127.0.0.1 www.apple.com
 

Restart Apache

sudo apachectl restart
 
Check out your local vhost domain in the browser
 

Losing Localhost

One caveat to note about virtual hosts is that once set up you lose your older document root previously at /LIbrary/WebServer/Documents or accessed in the browser at http://localhost what happens is that you get a 403 Forbidden Error. But the ~/username document root is still compatible.
 
To get around this, you need to add in a vhost for localhost and declare this vhost before any of the others, in the same file:
 
sudo nano /etc/apache2/extra/httpd-vhosts.conf

Add in:

<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>
 
Then restart Apache and all should be good.
 

Video Guide on vhosts

iNode What You Did Last Summer

0
0

How to find out how many inodes you are using on a hard disk or in a directory?

Most hosting plans have a limitation on inodes - so you need to know how many and where they are being used if you need to do some slashing. 

To find the inode limit for your whole disk or VPS

df -i
Output will be similar to this:
 
Filesystem            Inodes   IUsed   IFree IUse% Mounted on

/dev/vzfs            1000000  805718  194282   81% /
 
To find and display a well formatted summary of how many inodes are in a certain directory and list all the subdirectories - move into the directory and run:
 
echo "Detailed Inode usage for: $(pwd)" ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf "$c\t\t- $d\n" ; done ; printf "Total: \t\t$(find $(pwd) | wc -l)\n"
 
Output will be similar to below
inode-usage-directory
 
 

 

Tags:

Installing PEAR on OSX 10.9 Mavericks and OSX10.8/10.7

0
0

PEAR is a poplular PHP package manager, it doesn't come by default on OSX, how to install PEAR on OSX 10.9 Mavericks and earlier versions of OSX.

Check if you have it

pear version

If not, move into:

cd /usr/local

Get it

curl -O  http://pear.php.net/go-pear.phar

Install It

sudo php -d detect_unicode=0 go-pear.phar

Click yes a couple of times during the install

pear-mountain-lion-osx

Add PEAR to your PATH

cd 

vi .bashrc

or 

vi .bash_profile

Add to your PATH variable:

/Users/USERNAME/pear/bin

So the PATH variable line will look something like this, each path is separated by a colon and finished with the variable $PATH

export PATH="/usr/local/mysql/bin:/Users/admin/pear/bin:$PATH"

Refresh

source .bash_profile

Verify

pear version

Output should be

PEAR Version: 1.9.4
PHP Version: 5.4.17
Zend Engine Version: 2.4.0
Running on: Darwin admins-MacBook.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64
 
That's PEAR installed and ready.

 

How to Find and Delete Files in Directory Based on Modification Date

0
0

How to find and delete files in a Linux directory based on when the file had been modified from a certain amount of days ago - this can be useful for dealing with directories with copious amounts of files like email boxes and log folders.

 

First to see the files modified or created based on a certain date:

find /path-to-directory -mtime +5 -exec ls -l {} \;

This will list all the files created or modified 5 days prior to the current date.

 

Then to remove the files

find /path-to-directory -mtime +5 -exec rm -f {} \;

This will remove all those files previously listed.

 

Alter the '-mtime' argument in the command to change the amount of days, by adjusting the figure after it. '+5' will preserve any files created/modified withiin the last 5 days and delete files modified older then 5 days ago.

Tags:

How do I know if my website has been hacked?

0
0

Check with Google

If you think that your site may have been hacked but are not too sure - you can check to see what Google thinks at the following URL

http://www.google.com/safebrowsing/diagnostic?site=mydomain.com

Just swap out mydomain.com with your actual domain name

how-to-find-if-your-site-has-been-hacked

What you will see from the returned page is if Google thinks its been hacked.

 

If your website has been hacked, you can see which pages have been infected via the Google Webmaster Tools, they hava a Malware section which will list all the pages - so if you haven't set your site up with Google WebMaster Tools do this as a first step. Once you have WebMaster Tools set up check the malware section to see what the damage is.

google-malware-website

From this point you have a couple of choices based on your skill level, if you don't know how to fix the malware just copy the listed malware provided by Google and email it to your service provided and ask them to help or otherwise roll up your sleeves get access to your website via preferably the command line SSH or FTP and get ready to search and delete the malware code from the infected files.

Check with Sucuri

Sucuri will scan your site for malware and let you know is your CMS up to date and also advise if you are on blacklists.

Tags:


Upgrade MySQL Database from 5.5 to 5.6 on OSX 10.8 Mountan Lion

0
0

MySQL version 5.6.14 is available for download for OSX, a double click and install is available named Mac OS X ver. 10.7 (x86, 64-bit), DMG Archive. (Don't worry about the 10.7 naming, Works fine in OSX 10.9 and OSX 10.8)

Stop the MySQL Server

sudo /usr/local/mysql/support-files/mysql.server stop

Download and Launch the DMG

There is no upgrade option in the installer and you are presented with the 3 installations:

mysql-update-osx

You need to install all the three installers.

Control/Right click the mysql-5.6...pkg to avoid the security GateKeeper. Follow the installation processes.

Location of MySQL 5.6 Data

MySQL data and files will be stored at:

/usr/local/mysql-5.6.14-osx10.7-x86_64

and an 'mysql' directory alias is also created that points to the same location

/usr/local/mysql

which points to 

mysql -> mysql-5.6.14-osx10.7-x86_64

Your previous installation is maintained and will be filed in the same location with the appropraite version you were using, like so:

/usr/local/mysql-5.5.13-osx10.6-x86_6

What needs to be done is to migrate the database and tables to the new version.

Migrate Databases

The key directory from the previous instance that needs to be copied is :

/usr/local/mysql-5.5.13-osx10.6-x86_64/data

So in this instance the previous mysql version was 5.5.13 - rename the new data directory and copy in the old one and fix file ownership to MySQL:

Change Name of newer data directory
sudo mv /usr/local/mysql-5.6.14-osx10.7-x86_64/data /usr/local/mysql-5.6.14-osx10.7-x86_64/dataold
Copy Old Databases into new location
sudo cp -rf /usr/local/mysql-5.5.13-osx10.6-x86_64/data /usr/local/mysql-5.6.14-osx10.7-x86_64/
Set Correct Ownership to MySQL
sudo chown -R _mysql /usr/local/mysql-5.6.14-osx10.7-x86_64/data

Start MySQL and Repair

Now we need to start the MySQL database and run a repair/upgrade tool on the older databases

sudo /usr/local/mysql/support-files/mysql.server start
Run the Upgrade Tool
/usr/local/mysql/bin/mysql_upgrade

If you get errors on the first run, run the command again

Restart MySQL
sudo /usr/local/mysql/support-files/mysql.server restart
Check the Version
/usr/local/mysql/bin/mysql
Set MySQL Password
/usr/local/mysql/bin/mysqladmin -u root password 'yourpasswordhere'
my.cnf

In the latest version of MySQL 5.6 there is a default 'my.cnf' file that the database references that is now stored in:

/usr/local/mysql-5.6.14-osx10.7-x86_64/my.cnf

So if you have made any customisations to the behaviour of MySQL then these will now need to be added in the new my.cnf file and make a copy to /etc so any global changes will be read in when MySQL is launched.

Get Apache, MySQL, PHP and phpMyAdmin working on OSX 10.9 Mavericks

0
0

Get your Local Web Development Server Up & Running on OSX 10.9 Mavericks

osx mavericks 10.9

With the new OS out of the bag, getting the AMP stack running on OSX 10.9 Mavericks is is pretty much the same as on OS X Mountain Lion 10.8. This tutorial will go through the process on getting Apache, MySQL, PHP and phpMyAdmin running on the new Maverick Californian driven OS.

If you had your local development already set up in OSX 10.8 and simply did an upgrade to 10.9, your MySQL, Apache and phpMyAdmin settings should all be good, you just need to enable PHP

 

Apache/WebSharing

The web sharing option has not made it back in 10.9, which was previously a GUI option in System Preferences back in 10.7, but fear not Apache is installed ready to be switched on.

no-web-sharing in Mountain Lion

No Web Sharing Option in System Preferences

Apache is pre-installed in the OS and needs to be enabled via the command line - this needs to be done in Terminal which is found at /Applications/Utilities/Terminal

For those not familiar with the Terminal, it really isn't as intimidating as you may think, once launched you are faced with a command prompt waiting for your commands - just type/paste in a command and hit enter, some commands give you no response - it just means the command is done, other commands give you feedback - lets get to it....

to start it

sudo apachectl start

to stop it

sudo apachectl stop

to restart it

sudo apachectl restart

To find the Apache version

httpd -v

The version installed in OSX Mavericks is Apache/2.2.24

apache web serving it works

After starting Apache - test to see if the webserver is working in the browser - http://localhost - you should see the "It Works!" text.

 

Document Root

Document root is the location where the files are shared from the file system and is similar to the traditional names of 'public_html' and 'htdocs', OSX has historically had 2 web roots one at a system level and one at a user level - you can set both up or just run with one, the user level one allows multiple acounts to have their own web root whilst the system one is global for all users. It seems there is less effort from Apple in continuing with the user level one but it still can be set up with a couple of extra tweaks. It is easier to use the user level one as you don't have to keep on authenticating as an admin user.

System Level Web Root

- the default system document root is still found at - 

http://localhost/

The files are shared in the filing system at -  

/Library/WebServer/Documents/

User Level Root

The other web root direcroty which is missing by default is the '~/Sites' folder in the User account. You need to make a "Sites" folder at the root level of your account and then it will work. Upgrading from a previous OS X version preserves the Sites folder but removes the ability to web serve from it - this is where you need to add in a 'username.conf' file.

sites user web root folder osx mavericks

Create a Sites folder at the account root level 

Check that you have a “username.conf” filed under:

/etc/apache2/users/

If you don’t (very likely), then create one named by the short username of the account with the suffix .conf, it's location and permissions/ownership is best tackled by using the Terminal, the text editor 'nano' would be the best tool to deal with this.  

Launch Terminal, (Applications/Utilities), and follow the commands below, first one gets you to the right spot, 2nd one cracks open the text editor on the command line (swap 'username' with your account's shortname, if you don't know your account shortname type 'whoami' the Terminal prompt):

cd /etc/apache2/users
sudo nano username.conf

Then add the content below swapping in your 'username' in the code below:

<Directory "/Users/username/Sites/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Permissions on the file should be:

-rw-r--r--   1 root  wheel  298 Jun 28 16:47 username.conf

If not you need to change...

sudo chmod 644 username.conf

Restart Apache for the new file to be read:

sudo apachectl restart

Then this user level document root will be viewable at:

http://localhost/~username/

 

Overide .htaccess

If you are going to use the document root at /Library/WebServer/Documents it is a good idea to allow any .htaccess files used to override the default settings - this can be accomplished by editing the httpd.conf file at line 217 and setting the AllowOverride to All and then restart Apache. This is already taken care of at the Sites level webroot by following the previous step.

/etc/apache2/httpd.conf

allow-override-htaccess

 

PHP

PHP 5.4.17 is loaded in the latest preview of OSX 10.9 Mavericks and needs to be turned on by uncommenting a line in the httpd.conf file.

sudo nano /etc/apache2/httpd.conf

Use "control" + "w" to search within nano and search for 'php' this will land you on the right line then uncomment the line (remove the #):

LoadModule php5_module libexec/apache2/libphp5.so

Write out and Save using the nano short cut keys at the bottom 'control o' and 'control x'

Reload apache to kick in

sudo apachectl restart

To see and test PHP, create a file name it "phpinfo.php" and file it in your document root with the contents below, then view it in a browser.

<?php phpinfo(); ?>

 

MySQL

MySQL is again a missing component in OS X 10.9 and needs to be dowloaded from the MySQL site use the Mac OS X ver. 10.7 (x86, 64-bit), DMG Archive version (works fine on 10.9).

When downloading you don’t have to sign up, look for » No thanks, just take me to the downloads!  - go straight to the download mirrors and download the software from a mirror which is closest to you.

Once downloaded install the 3 components. You may need to adjust the Security and Privacy System Pref to allow installs of 3rd party apps because of the new security feature of Mountain Lion known as the 'Gatekeeper', which keeps unscrupulous installer packages at bay.

To get around this without changing the global preferences (better!) right click or command click the .pkg installer to bring up the contextual menu and select open, then you get the warning - then click Open.

 

mysql install packages osx 10.9

Install all 3...

  • mysql5.6.xxx.pkg
  • MySQLstartupitem.pkg
  • MySQLPrefPane

install for osx user or all osx users

The first is the MySQL software, the 2nd item allows MySQL to start when the Mac is booted and the third is a System Preference that allows start/stop operation and a preference to enable it to start on boot.

You can start the MySQL server from the System Preferences or via the command line 

start-mysql system preferences

sudo /usr/local/mysql/support-files/mysql.server start 

To find the MySQL version from the terminal, type at the prompt:

/usr/local/mysql/bin/mysql -v

This also puts you in to an interactive dialogue with mySQL, type \q to exit.

After installation, in order to use mysql commands without typing the full path to the commands you need to add the mysql directory to your shell path, (optional step) this is done in your “.bash_profile” file in your home directory, if you don’t have that file just create it using vi or nano:

cd ; nano .bash_profile
export PATH="/usr/local/mysql/bin:$PATH"

The first command brings you to your home directory and opens the .bash_profile file or creates a new one if it doesn’t exist, then add in the line above which adds the mysql binary path to commands that you can run. Exit the file with type “control + x” and when prompted save the change by typing “y”. Last thing to do here is to reload the shell for the above to work straight away.

source ~/.bash_profile
mysql -v

You will get the version number again, just type “\q” to exit.

Set the MySQL root password

Note that this is not the same as the root or admin password of OSX - this is a unique password for the mysql root user, use one and remember/jot down somewhere what it is.

/usr/local/mysql/bin/mysqladmin -u root password 'yourpasswordhere'

Use the single 'quotes' surrounding the password

Fix the 2002 MySQL Socket error

Fix the looming 2002 socket error - which is linking where MySQL places the socket and where OSX thinks it should be, MySQL puts it in /tmp and OSX looks for it in /var/mysql the socket is a type of file that allows mysql client/server communication.

sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

phpMyAdmin

phpMyAdmin is installed pretty much the same way as before.  

Fix the 2002 socket error first if you haven't done so from the MySQL section- 

sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Download phpMyAdmin, the zip package and move the folder with its contents into the document root level renaming folder to 'phpmyadmin'.

Make the config folder

mkdir ~/Sites/phpmyadmin/config

Change the permissions

chmod o+w ~/Sites/phpmyadmin/config

Run the set up in the browser

http://localhost/~username/phpmyadmin/setup/ or http://localhost/phpmyadmin/setup/

You need to create a new localhost mysql server connection, click new server.

 

 


Switch to the Authentication tab and set the local mysql root user and the password.
Add in the username “root” (maybe already populated, add in the password that you set up earlier for the MySQL root user set up, click on save and you are returned to the previous screen.
(This is not the OSX Admin or root password - it is the MySQL root user).

 


Make sure you click on save, then a config.inc.php is now in the /config directory of phpmyadmin directory, move this file to the root level of /phpmyadmin and then remove the now empty /config directory.

 

 

Now going to http://localhost/~username/phpmyadmin/ will now allow you to interact with your MySQL databases.

To upgrade phpmyadmin just download the latest version and copy the older 'config.inc.php' from the existing directory into the new folder and replace - backup the older one just in case.

Permissions

To run a website with no permission issues it is best to set the web root and its contents to be writeable by all, since it's a local development it should'nt be a security issue.

Lets say that you have a site in the User Sites folder at the following location ~/Sites/testsite you would set it to be writeable like so:

sudo chmod -R a+w ~/Sites/testsite

If you are concerned about security then instead of making it world writeable you can set the owner to be Apache _www but when working on files you would have to authenticate more as admin you are "not" the owner, you would do this like so:

sudo chown -R _www ~/Sites/testsite

This will set the contents recursively to be owned by the Apache user.

If you had the website stored at the System level Document root at say /Library/WebServer/Documents/testsite then it would have to be the latter:

sudo chown -R _www /Library/WebServer/Documents/testsite

So I think it's worth setting up the User level root as there is less authentication!

That's it! You now have the native AMP stack running ontop of the tamed Mavericks wave.

 

If you need virtual hosts configured I have added a separate guide on how to set these up in the Apache config files.

That's it! You now have the native AMP stack running ontop of OSX Mavericks.

Install Drush via PEAR on a cPanel Server

0
0

How to install Drush via PEAR on a cPanel Server 

Install PEAR

The first thing that you need to do is make sure that PEAR is running 

pear version

If PEAR is not installed it can be easily added via EasyApache Update via WHM in the Exhaustive Options List, check the box and recompile to add in PEAR to your server.

install-drush-via-pear-cpanel

 

Once you have PEAR installed, you need to get the PEAR user config file set up - go to your cPanel GUI interface and click on PHP PEAR Packages you will see a config-set screen display 'suceeded'

php-pear-cpanel

php-pear-cpanel-config

Now on the command line go to your home directory and see your PEAR config

cd
ls -la .pea*
-rw-r--r-- 1 letit letit 527 Dec 15 01:05 .pearrc

Link PEAR to the drush channel to download the package

pear channel-discover pear.drush.org

Output should be:

Adding Channel "pear.drush.org" succeeded
Discovery of channel "pear.drush.org" succeeded

Install drush

pear install drush/drush

Upgrading drush

For future upgrades just run

pear upgrade drush 

For drush commands type drush and see what is available - otherwise check the drush website and a starting point for basic drush commands here.

Viewing all 31 articles
Browse latest View live




Latest Images