How to install resource for ubuntu server
1. Update
sudo apt-get update
2. Install apache2
sudo apt-get install apache2
3. Install php
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
4. Install mysql
sudo apt-get install mysql-server php5-mysql
5. Install mongodb
Import the public key used by the package management system.
sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 7F0CEB10
Create a list file for MongoDB.
echo “deb http://repo.mongodb.org/apt/ubuntu “$(lsb_release -sc)”/mongodb-org/3.0 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
Reload local package database.
sudo apt-get update
Install the MongoDB packages.
sudo apt-get install -y mongodb-org
More detail read here
6. Install mongodb apache extension for apache / php
First, to get this thing going, we’ll need to resolve some dependencies. To do that, run this command from the terminal:
$ sudo apt-get install php-pear php5-dev
Next, you should easily be able to install the driver with the following command:
$ sudo pecl install mongo
What makes Ubuntu 12.04 a little different from other systems in how PHP extensions get loading when Apache/PHP starts. To make sure this extension gets loaded, we’ll need to add a .ini file to “/etc/php5/conf.d”. To do that, run the following command:
/etc/php5/apache2/php.ini
$ sudo touch /etc/php5/conf.d/mongo.ini
After creating the file, add this line of content:
extension=mongo.so
After you’ve saved your new .ini file, restart Apache and verify that the extension is loading with phpinfo()
.
Or ubuntu 14.04
sudo apt-get install php5-mongo
7. Install git
sudo apt-get update
sudo apt-get install git
8. Config www/html folder
Add the www-data group to an existing user
sudo usermod -a -G www-data username
OR if the user doesn’t exist: Create a new user and assign them the www-data group
sudo adduser username www-data
Make sure all files are owned by the www-data group and user (cleans up the ownership)
sudo chown -R www-data:www-data /var/www
Enable all members of the www-data group to read and write files
sudo chmod -R g+rw /var/www
* Note: You are done. But if you want all future files created in this directory to keep the current setup do the following as well:
This is what I do to ensure that all files created keep the current user and permissions (it’s really lame to create new files, say from Git, and then have to update the user, groups and permissions of the new files every time to ensure they can be run by the server)
sudo chmod -R g+rws /var/www
* Final Note: For security reasons it may be better to keep /var/www owned by root:root (depending on what you are doing)
If you want to keep /var/www owned by root replace step 2 with
sudo chgrp -R www-data /var/www/*
9. Install php composer
sudo apt-get install php5 git php5-curl
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer
Then use directly via command
composer
10. Enable command mod
Rewrite
sudo a2enmod rewrite
sudo service apache2 restart
If you plan on using mod_rewrite in .htaccess
files, you also need to enable the use of .htaccess
files by changing AllowOverride None
to AllowOverride FileInfo
. For the default website, edit /etc/apache2/sites-available/default (or 000-default.conf)
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
# changed from None to FileInfo
AllowOverride Indexes FileInfo
Order allow,deny
allow from all
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
to
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Setup vhost for apache2
1. Create the First Virtual Host File
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
2. edit copied file
sudo nano /etc/apache2/sites-available/example.com.conf
Add this
<VirtualHost *:80> ServerAdmin admin@example.com ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com/public_html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
3. Enable
sudo a2ensite example.com.conf
4. Restart
sudo apche2 restart Grant a user permissions on www-data owned /var/www sudo usermod -aG www-data iain # addgroup www-data sudo chown -R www-data:www-data /var/www/example.com/public_html sudo chmod -R 770 /var/www/example.com/public_html Fix mongo install #Step 1: Import the MongoDB public key sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 #Step 2: Generate a file with the MongoDB repository url echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list #Step 3: Refresh the local database with the packages sudo apt-get update #Step 4: Install the last stable MongoDB version and all the necessary packages on our system sudo apt-get install mongodb-org PHP.ini file location (which we will add extension to it - ex: mongo.so) The three files you have there are each meant for different uses. /etc/php5/cli/php.ini is for the CLI PHP program, which you found by running php on the terminal. /etc/php5/cgi/php.ini is for the php-cgi system which isn't specifically used in this setup. /etc/php5/apache2/php.ini is for the PHP plugin used by Apache. This is the one you need to edit for changes to be applied for your Apache setup. Add Require all granted if we custom another root directory <Directory /home/everett/webroot> Options FollowSymLinks MultiViews AllowOverride All Order allow,deny Require all granted </Directory> PHP.ini file location (which we will add extension to it - ex: mongo.so) The three files you have there are each meant for different uses. /etc/php5/cli/php.ini is for the CLI PHP program, which you found by running php on the terminal. /etc/php5/cgi/php.ini is for the php-cgi system which isn't specifically used in this setup. /etc/php5/apache2/php.ini is for the PHP plugin used by Apache. This is the one you need to edit for changes to be applied for your Apache setup.