Vargant Ubuntu 15.04安裝LNMP
環(huán)境
Mac Os 10.11.1
1.Vagrant 1.7.4
2.VirtualBox 5.0.4
3.Ubuntu 15.4 amd64
http://uec-images.ubuntu.com/vagrant/vivid/current/vivid-server-cloudimg-amd64-vagrant-disk1.box
- 配置Vagrant
cd dev
mkidr project_name
vagrant init
vagrant box add ubuntu15 /Users/you/Iwork/vbox/vivid-server-cloudimg-amd64-vagrant-disk1.box //絕對路徑
vim Vagrantfile
onfig.vm.box = "ubuntu15"
config.vm.network "private_network", ip: "192.168.33.20"
config.vm.synced_folder "project_name", "/var/www/html/project_name"
//可以配置更多項目
config.vm.synced_folder "project_name1", "/var/www/html/project_name1"
config.vm.synced_folder "project_name2", "/var/www/html/project_name2"
vagrant up #stops the vagrant machine
vagrant ssh #connects to machine via SSH user vagrant passowd vagrant
vagrant halt #starts the vagrant machine
- 更新ubuntu源
sudo apt-get update
- 安裝Nginx [/etc/nginx/nginx.conf]
sudo apt-get install nginx
- 安裝mysql
sudo apt-get install mysql-server
The following extra packages will be installed:
libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18 libterm-readkey-perl
mysql-client-5.6 mysql-client-core-5.6 mysql-common mysql-server-5.6 mysql-server-core-5.6
- Starting and Stopping the MySQL Server
The MySQL server is started automatically after installation. You can check the status of the MySQL server with the following command:
sudo service mysql status
Stop the MySQL server with the following command:
sudo service mysql stop
To restart the MySQL server, use the following command:
sudo service mysql start
- 安裝PHP(php-fpm) [/etc/php5/fpm/php-fpm.conf ] [/etc/php5/fpm/php.ini]
sudo apt-get install php5-fpm php5-mysql php5-curl php5-gd
The following NEW packages will be installed:
php5-cli php5-common php5-fpm php5-json php5-mysql php5-readline php5-curl php5-gd
- mysql遠(yuǎn)程連接
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
# bind-address = 127.0.0.1
//設(shè)置mysql訪問權(quán)限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '要設(shè)置的密碼' WITH GRANT OPTION;
FLUSH PRIVILEGES;
- 配置PHP
;cgi.fix_pathinfo=1
cgi.fix_pathinfo=0
sudo service php5-fpm restart
- 修改php-fpm用戶配置 事關(guān)目錄權(quán)限
user = vagrant
group = vagrant
sudo service php5-fpm restart
- 配置Nginx default /etc/nginx/sites-available
root /var/www/html;#根目錄
# Add index.php to the list if you are using PHP
index.php index index.html index.htm index.nginx-debian.html;
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
#}
#location ~ /\.ht {
# deny all;
#}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
location ~ /\.ht {
deny all;
}
sudo nginx -c /etc/nginx/nginx.conf #start up
sudo nginx -s reload #reload