Linux Apache MySQL and PHP

Last modified: 
15 Nov 2017 - 07:43
Bonus strings
Nice settings for /www the local user is gnowak:
sudo chown www-data:gnowak -R /var/www/; sudo chmod g+rw -R /var/www/
Mysql tools: sudo aptitude install mysql-admin mysql-gui-tools-common mysql-navigator mysql-query-browser
 
All in one: sudo aptitude install apache2-mpm-prefork apache2 php5 libapache2-mod-php5 php5-cli php5-mysql php5-gd mysql-client mysql-server phpmyadmin mysql-admin mysql-query-browser awstats postfix postfix-mysql postfix-doc mysql-client mysql-server courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl libsasl2-modules libsasl2-modules-sql libsasl2-2 sasl2-bin libpam-mysql openssl php5-common php5-cgi php5-mysql libfcgi-dev phpmyadmin unzip courier-authlib courier-authlib-userdb courier-base courier-ssl libmysqlclient15off ssl-cert libxml2 ucf php5-pspell aspell-da mysql-admin mysql-gui-tools-common mysql-navigator mysql-query-browser; sudo tasksel install lamp-server; sudo dpkg-reconfigure postfix; sudo postconf -e 'home_mailbox = Maildir/'; sudo /etc/init.d/apache2 restart

Drupal Installation with clean URL's on apache2 - last tried 2013-01-19 and it works perfectly
1) Download Drupal
2) copy it into /var/www folder
3) change permissions for /var/www/drupal-6.2/sites/default
4) clean URLs reference: http://drupal.org/node/43783. Follow the steps below.
a) sudo nano /etc/apache2/httpd.conf  - this file may not exist
add the following

Options FollowSymLinks
AllowOverride all
Order deny,allow
Deny from all

Options Indexes FollowSymLinks
DirectoryIndex index.php
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 10.0.0.0/24

b)
sudo nano /etc/apache2/sites-enabled/000-default
change:
Options Indexes FollowSymLinks MultiViews
AllowOverride none
to:
Options Indexes FollowSymLinks MultiViews
AllowOverride all
c)
sudo a2enmod rewrite; sudo service apache2 restart

Drush: http://drupal.org/project/drush; http://drupal.org/project/drush_mm;
drush --uri=http://localhost/drupal
alias drush='php sites/all/modules/drush/drush.php' -> into .bashrc in home

update all modules: drush pm update --uri=http://localhost/drupaltest
update specific modules: drush pm update author_pane simplenews --uri=http://localhost/drupaltest
grn.dk modules: drush dl captcha devel imageapi lightbox2 print webform dhtml_menu imagecache nice_menus simplenews token xmlsitemap cvs_deploy image img_assist pathauto switchtheme views
1) drush install views wysiwyg dhtml_menu advanced_forum devel jquery_plugin cvs_deploy controlpanel front pathauto calendar calendar_block cck link token date drush_extras storm advanced_help webform captcha nodewords

2) Lesser list: drush dl views wysiwyg dhtml_menu advanced_forum devel jquery_plugin cvs_deploy front pathauto cck link token date advanced_help webform captcha nodewords author_pane

kewl module list: frontpage image image_assist image_attach mail_editor quote smileys subscriptions print badbehavior imagefield node_images jstools vote_up_down ctools mp3player ubercart docapi
Project management:project_admin_category timebudget storm project_forecast
project "for drup 5 only"
maybe nice: epublish node_clone
block page visibility: bpv

drush pm install simplenews --uri=http://localhost/drupaltest; drush mm enable simplenews --uri=http://localhost/drupaltest

//Disable random
drush mm disable devel devel_generate devel_node_access devel_themer --uri=http://localhost/drupaltest

CVS setup: http://users.csc.calpoly.edu/~dbutler/tutorials/winter96/cvs/

http://www.linux.ie/articles/tutorials/cvs.php
export CVSROOT=/cvs; cvs init

Drupal CVS
Checkout: cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal co -r DRUPAL-6-14 -d drupaltest drupal (http://drupal.org/node/320)
Update: cvs up -r DRUPAL-6-8 -dP (http://drupal.org/node/93966)

checkout modules from cvs: http://drupal.org/node/321
example: cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r DRUPAL-6--1-0-ALPHA15 -d advanced_forum contributions/modules/advanced_forum -D '2008-10-02'

kewl drupal sites: http://wiki.doomicile.de/projekte/drupal/sysadmin/best_practice

Patch: patch -p0 < name-of-patch.patch
*****************************************************************************************************
Server one step at a time:
Thanks to:http://ubuntuguide.org/wiki/Ubuntu:Gutsy#How_to_install_Apache_and_PHP5

Drupal: thanks to: http://www.lullabot.com/videocast/install-local-web-server-ubuntu
and http://groups.drupal.org/node/6266
a) sudo aptitude install apache2-mpm-prefork apache2 libapache2-mod-php5 php5-cli php5-mysql php5-gd mysql-client mysql-server phpmyadmin mysql-admin mysql-query-browser

b) sudo tasksel install lamp-server

1) Download Drupal
2) copy it into /var/www folder
3) change permissions for /var/www/drupal-6.2/sites/default
4) clean URL's (http://drupal.org/node/43783)
a) Probably only thing needed:
sudo nano /etc/apache2/httpd.conf
and add the following

Options FollowSymLinks
AllowOverride all
Order deny,allow
Deny from all

Options Indexes FollowSymLinks
DirectoryIndex index.php
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 10.0.0.0/24

b)
sudo nano /etc/apache2/sites-enabled/000-default
change:
Options Indexes FollowSymLinks MultiViews
AllowOverride none
to:
Options Indexes FollowSymLinks MultiViews
AllowOverride all
c)
sudo a2enmod rewrite; sudo /etc/init.d/apache2 restart

Apache: sudo aptitude install apache2
PHP + PHPApache: sudo aptitude install php5 libapache2-mod-php5 php5-gd php5-mysql phpmyadmin
Restart Apache: sudo /etc/init.d/apache2 restart

MySQL-server: http://ubuntuguide.org/wiki/Ubuntu:Feisty/Servers#How_to_install_MYSQL_D...
sudo aptitude install mysql-server

Mail-server: https://help.ubuntu.com/community/Postfix; http://www.urbanpuddle.com/articles/2007/08/27/setup-postfix-on-ubuntu-f...

sudo aptitude install postfix postfix-mysql postfix-doc mysql-client mysql-server courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl libsasl2 libsasl2-modules libsasl2-modules-sql libsasl2-2 sasl2-bin libpam-mysql openssl php5-common php5-cgi php5-mysql libfcgi-dev phpmyadmin unzip courier-authlib courier-authlib-userdb courier-base courier-ssl libfam0 libltdl3 libmysqlclient15off ssl-cert libxml2 ucf

sudo dpkg-reconfigure postfix

sudo postconf -e 'home_mailbox = Maildir/'

**STOP go further only if you know what you are doing ;-)**

Configure Postfix to do SMTP AUTH using SASL (saslauthd):
sudo postconf -e 'smtpd_sasl_local_domain ='; sudo postconf -e 'smtpd_sasl_auth_enable = yes'; sudo postconf -e 'smtpd_sasl_security_options = noanonymous'; sudo postconf -e 'broken_sasl_auth_clients = yes'; sudo postconf -e 'smtpd_recipient_restrictions =; permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'; sudo postconf -e 'inet_interfaces = all'

Next edit /etc/postfix/sasl/smtpd.conf and add the following lines:
pwcheck_method: saslauthd
mech_list: plain login

Generate certificates to be used for TLS encryption and/or certificate Authentication:
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024; chmod 600 smtpd.key; openssl req -new -key smtpd.key -out smtpd.csr; openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt; openssl rsa -in smtpd.key -out smtpd.key.unencrypted; mv -f smtpd.key.unencrypted smtpd.key; openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650; sudo mv smtpd.key /etc/ssl/private/; sudo mv smtpd.crt /etc/ssl/certs/; sudo mv cakey.pem /etc/ssl/private/; sudo mv cacert.pem /etc/ssl/certs/

Configure Postfix to do TLS encryption for both incoming and outgoing mail:
sudo postconf -e 'smtpd_tls_auth_only = no'; sudo postconf -e 'smtp_use_tls = yes'; sudo postconf -e 'smtpd_use_tls = yes'; sudo postconf -e 'smtp_tls_note_starttls_offer = yes'; sudo postconf -e 'smtpd_tls_key_file = /etc/ssl/private/smtpd.key'; sudo postconf -e 'smtpd_tls_cert_file = /etc/ssl/certs/smtpd.crt'; sudo postconf -e 'smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem'; sudo postconf -e 'smtpd_tls_loglevel = 1'; sudo postconf -e 'smtpd_tls_received_header = yes'; sudo postconf -e 'smtpd_tls_session_cache_timeout = 3600s'; sudo postconf -e 'tls_random_source = dev:/dev/urandom'; sudo postconf -e 'myhostname = server1.example.com'

Restart the postfix daemon like this:
sudo /etc/init.d/postfix reload

MYSQL
#!/bin/bash
#Inspired from http://www.cyberciti.biz/faq/ubuntu-linux-mysql-nas-ftp-backup-script/

NOW=$(date +"%Y-%m-%d")

### MySQL Setup ###
MUSER="USER"
MPASS="PASS"
MHOST="HOST"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"

DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')"
echo $DBS
for db in $DBS
do
FILE=$NOW_mysql-$db.-$(date +"%T").sql
$MYSQLDUMP -h $MHOST -p$MPASS $db > $FILE
doneu

#mysqldump -u gnowak -h mysqlhost -p code gnowak_smf
#mysqldump -h mysqlhost -ppassword gnowak_smf > gnowak_smf.sql

Tags: