Skip to content

Instantly share code, notes, and snippets.

@7hunderbird
Last active August 29, 2015 13:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7hunderbird/9787446 to your computer and use it in GitHub Desktop.
Save 7hunderbird/9787446 to your computer and use it in GitHub Desktop.
quickest setup of a php machine on a vagrant box

Update Ubuntu

You should already be in the vagrant server with vagrant ssh.

sudo su
apt-get update
apt-get upgrade -y 
exit # root
exit # exit vagrant (to reboot)

Reboot Vagrant

From outside the vagrant server reboot then ssh back in.

vagrant reload
vagrant ssh

Install MySQL

We want MySQL 5.5.

sudo su
apt-get install mysql-server mysql-client -y
# MySQL Password: F9iYMLHKd7iVnx

Install Python Software Properties

This will help to be able to add PPA repos.

apt-get install python-software-properties -y

Install Nginx

This is the latest stable version.

add-apt-repository ppa:nginx/stable -y
apt-get update
apt-get install nginx -y
/etc/init.d/nginx start

Install PHP

Install PHP 5.5.

add-apt-repository ppa:ondrej/php5 -y
apt-get update
apt-get install php5-common php5-mysqlnd php5-xmlrpc php5-curl php5-gd php5-cli php5-fpm php-pear php5-dev php5-imap php5-mcrypt -y

Setup a New Default Site

cd /usr/share/nginx/html
mkdir www.example.com
wget -O /etc/nginx/sites-available/www.example.com https://gist.githubusercontent.com/7hunderbird/9787446/raw/ed223970a182d402bebf665356b57463166f1025/example.conf
cd /etc/nginx/sites-enabled/
ln -s /etc/nginx/sites-available/www.example.com www.example.com
rm default

Download Wordpress

cd ~
mkdir src
cd ~/src/
wget http://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz
cd ~/src/wordpress/
cp -R * /usr/share/nginx/html/www.example.com/

Create a Wordpress Database

mysql -uroot -pF9iYMLHKd7iVnx -e "create database wordpress";

Fix Wordpress Folder Permissions

cd /usr/share/nginx/html
find /usr/share/nginx/html/ -type d -exec chmod 755 {} \;
find /usr/share/nginx/html/ -type f -exec chmod 644 {} \;
chown -R www-data:www-data  /usr/share/nginx/html/www.example.com
chmod -R 755 /usr/share/nginx/html/

Restart Services

/etc/init.d/nginx restart
/etc/init.d/php5-fpm restart
server {
server_name example.com www.example.com;
access_log /var/log/nginx/www.example.com.access.log;
error_log /var/log/nginx/www.example.com.error.log;
root /usr/share/nginx/html/www.example.com;
index index.php;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment