一直用ubuntu作为开发环境,喜欢折腾,桌面玩挂,系统玩崩是经常的事,这里记录下ubuntu下使用apt-get快速搭建LNMP环境.
安装mysql-server和mysql-client
apt-get install mysql-server mysql-client
安装nginx
apt-get install nginx
nginx相关操作命令
sudo service nginx start
sudo service nginx stop
sudo service nginx restart
sudo service nginx reload
安装php和php-fpm和php扩展
sudo apt-get install php5-fpm
sudo apt-get install php5-cli
#安装相关扩展
sudo apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-sqlite php5-tidy php5-xmlrpc php5-xsl
php-fpm操作命令
sudo service php5-fpm stop
sudo service php5-fpm start
sudo service php5-fpm restart
sudo service php5-fpm status
安装redis-server和php redis扩展:
sudo apt-get install redis-server
sudo apt-get install php5-redis
最后,nginx.conf添加一个server(codeigniter框架为例)
server {
listen 80;
server_name www.test.com;
root /var/www/html/;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php($|/) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}