Created
November 18, 2013 21:01
-
-
Save multidis/7535211 to your computer and use it in GitHub Desktop.
LAMP setup on a development machine: follow LAMP_setup_localhost.sh as the top-level file. Needed it for php work with WordPress. Last performed on Ubuntu 12.04 laptop.
NOTE: Jekyll and Django have their own lightweight development servers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## apache 2 | |
sudo apt-get install apache2 | |
## apache2: Could not determine the server's fully qualified domain name, using 127.0.0.1 | |
## setting that up as described in https://help.ubuntu.com/community/ApacheMySQLPHP | |
echo "ServerName localhost" | sudo tee /etc/apache2/conf.d/fqdn | |
sudo service apache2 restart | |
## check http://localhost/ | |
## add php5 module | |
sudo apt-get install libapache2-mod-php5 | |
## enable the module - may already be enabled | |
sudo a2enmod php5 | |
sudo service apache2 restart | |
## add necessary php modules | |
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl | |
sudo service apache2 restart | |
## prevent php being desabled in user dirs; | |
## NOTE: may not be an issue if different dir from "public_html" was used as above | |
gksudo gedit /etc/apache2/mods-enabled/php5.conf | |
## comment-out <IfModule mod_userdir.c>-block | |
## (see http://blag.borap.net/2010/05/04/re-enabling-php-in-user-directories-in-ubuntu-10-04/) | |
sudo service apache2 restart | |
## now configure wwwuser-dir and test php as in site_in_user_dir.sh | |
## change php.ini to development settings: see | |
## https://github.com/php/php-src/blob/master/php.ini-development | |
sudo cp /etc/php5/apache2/php.ini /etc/php5/apache2/php.ini.bak-prod | |
## edit /etc/php5/apache2/php.ini in e.g. Meld diff-viewer based on development-one | |
## also: increase memory_limit | |
sudo cp /etc/php5/apache2/php.ini /etc/php5/apache2/php.ini.bak-dev | |
sudo service apache2 restart | |
## check http://localhost/testphp.php: | |
## e.g. display_errors should be On now, new memory_limit | |
## MySQL (once all above is error-free and tested): follow phpmyadmin screens | |
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql phpmyadmin | |
sudo service apache2 restart | |
## test http://localhost/phpmyadmin and created login-passw | |
## now complete apache config edits as in apache2-conf-edits.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## change apache2-default /var/www/ to /home/user/www-apache/ | |
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/wwwuser | |
gksudo gedit /etc/apache2/sites-available/wwwuser | |
# 1. edit DocumentRoot, Directory directives | |
# 2. edit ErrorLog and CustomLog | |
# 3. change AllowOverride to "All" in at least 2 places: allows htaccess | |
## htaccess note: need also to run "a2enmod rewrite", see apache2-conf-edits.sh | |
sudo a2dissite default && sudo a2ensite wwwuser | |
sudo service apache2 restart | |
## limit log-file growth in the new location | |
#sudo gedit /etc/logrotate.d/apache2 | |
## more practical by hand after development sessions: | |
## run logclear.sh (sudo) regularly from inside /home/user/www-apache/ | |
sudo service apache2 restart | |
## test with some html | |
echo '<h1>Hi user (Apache2)</h1>' > /home/user/www-apache/index.html | |
## check http://localhost/ | |
## test php5 apache2-module from this new location | |
echo '<?php phpinfo(); ?>' > /home/user/www-apache/testphp.php | |
## test htaccess | |
## e.g. DirectoryIndex some.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## clear local apache log-files: run with sudo | |
service apache2 stop | |
mv access.log access.log.old | |
mv error.log error.log.old | |
touch access.log | |
touch error.log | |
service apache2 start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## change run-user in apache | |
gksudo gedit /etc/apache2/envvars | |
## change "APACHE_RUN_USER" and "APACHE_RUN_GROUP" from www-data | |
## to user as in /home/user/www-apache/ of site_in_user_dir.sh | |
## then chown of /var/lock/apache2 to user and restart | |
sudo service apache2 restart | |
## enable rewrites with htaccess | |
sudo a2enmod rewrite | |
sudo service apache2 restart | |
## verify rewrite module is in the list | |
sudo apache2ctl -M | |
## keep track of error log | |
tail -f /home/user/www-apache/error.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment