Ubuntu 12.04 - Install Joomla with LEMP
This is a simple step by step guide for install Joomla CMS onto a Ubuntu 12.04 server with LEMP stack (Linux Nginx MySQL PHP).
joomla
- Update
- sudo apt-get update
- LEMP
- Install Nginx
- sudo apt-get install nginx
- sudo /etc/init.d/nginx start
- Test nginx has started by navigating to server url and checking "Welcome to nginx"
- Install PHP and plugins
- sudo apt-get install php5-cli php5-fpm php5-mysql
- Config nginx to work with PHP
- sudo vim /etc/nginx/sites-available/default
- In server section
- change "index index.html index.htm;" to "index index.html index.htm index.php;"
- Look for the "location ~ .php$ {" block and edit as below:
-
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ .php$ { try_files $uri =404; fastcgi_split_path_info ^(.+.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: fastcgi_pass 127.0.0.1:9000; # With php5-fpm: # fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; }
- sudo service nginx restart
- sudo vim /usr/share/nginx/www/phpinfo.php
- <? php phpinfo(); ?>
- Navigate to server url /phpinfo.php and check php info page appears
- Install MySQL
- sudo apt-get install mysql-server
- Set root password
- Optional: Install phpmyadmin
- sudo apt-get install phpmyadmin
- Select "apache2" for web server to config (doesn't matter)
- Select "no" for "configure database with dbconfig-common"
- Add the following to /etc/nginx/sites-available/default below the php section
-
location /phpmyadmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpmyadmin/(.+.php)$ { try_files $uri =404; root /usr/share/; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } location ~* ^/phpmyadmin/(.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/; } } location /phpMyAdmin { rewrite ^/* /phpmyadmin last; }
- sudo vim /etc/php5/fpm/php.ini
- add line "extension=mysqli.so"
- uncomment (remove ";") "mysqli.allow_local_infile = On"
- sudo /etc/init.d/php5-fpm restart
- sudo service nginx restart
- Navigate to server url /phpmyadmin to check the admin client is working
- Install Nginx
- Joomla
- Download and setup joomla dirs
- sudo mkdir -p /var/www/joomla/web (best practise name is domain name rather than joomla)
- cd /tmp
- wget http://joomlacode.org/gf/download/frsrelease/17410/76012/Joomla_2.5.7-Stable-... (get latest download url from http://www.joomla.org/download.html)
- sudo apt-get install unzip
- unzip Joomla_2.5.7-Stable-Full_Package.zip
- rm -f Joomla_2.5.7-Stable-Full_Package.zip
- sudo mv * /var/www/joomla/web/
- sudo chown -R www-data:www-data /var/www/joomla/web (allow nginx to write joomla files)
- Create MySQL DB and user (joomla, joomla_admin/joomla_admin_password)
-
- mysqladmin -u root -p create joomla
- mysql -u root -p
- GRANT ALL PRIVILEGES ON joomla.* TO 'joomla_admin'@'localhost' IDENTIFIED BY 'joomla_admin_password';
- GRANT ALL PRIVILEGES ON joomla.* TO 'joomla_admin'@'localhost.localdomain' IDENTIFIED BY 'joomla_admin_password';
- FLUSH PRIVILEGES;
- quit;
- Make nginx config
- sudo vim /etc/nginx/sites-available/joomla
-
server { listen 80; server_name www.example.com example.com; root /var/www/www.example.com/web; if ($http_host != "www.example.com") { rewrite ^ http://www.example.com$request_uri permanent; } index index.php index.html index.htm default.html default.htm; location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } # deny running scripts inside writable directories location ~* /(images|cache|media|logs|tmp)/.*.(php|pl|py|jsp|asp|sh|cgi)$ { return 403; error_page 403 /403_error.html; } # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). location ~ /. { deny all; access_log off; log_not_found off; } location / { try_files $uri $uri/ /index.php?q=$uri&$args; } # caching of files location ~* .(ico|pdf|flv)$ { expires 1y; } location ~* .(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ { expires 14d; } location ~ .php$ { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; }}
- sudo ln -s /etc/nginx/sites-available/joomla /etc/nginx/sites-enabled/joomla
- sudo /etc/init.d/nginx reload
- Download and setup joomla dirs