標籤:
LNMP是時下很流行的網站配置,我在配置蟬大師伺服器的時候順帶把經驗做個分享,蟬大師的網址是:http://www.ddashi.com/
1、第一步, 跟新apt-get
輸入:
sudo apt-get update
2、第二步,安裝Mysql
輸入:
sudo apt-get install mysql-server php5-mysql
安裝過程中mysql會要求你給資料庫設定密碼,輸入兩次後繼續……
輸入:
sudo mysql_install_db
繼續輸入:
sudo /usr/bin/mysql_secure_installation
會提示你輸入剛剛設定的mysql密碼,輸入即可
問你是否要更改密碼,輸入N即可
接下來Mysql會提示幾個問題,填入下邊對應的y或n即可
By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] y ... Success!Normally, root should only be allowed to connect from ‘localhost‘. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] y... Success!By default, MySQL comes with a database named ‘test‘ that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] y ... Success!Cleaning up...
3、第三步、安裝Nginx
依次輸入:
echo "deb http://ppa.launchpad.net/nginx/stable/ubuntu $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/nginx-stable.listsudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8Csudo apt-get updatesudo apt-get install nginx
啟動nginx:
sudo service nginx start
這時候你可以訪問你的網域名稱或IP地址來看看Nginx是否工作了
輸入如下命令可以知道你的IP:
ifconfig eth0 | grep inet | awk ‘{ print $2 }‘
4、第四步,安裝PHP
sudo apt-get install php5-fpm
配置PHP:
sudo nano /etc/php5/fpm/php.ini
找到, cgi.fix_pathinfo=1, 把1改為0即可,如下:
cgi.fix_pathinfo=0
接著:
sudo nano /etc/php5/fpm/pool.d/www.conf
找到, listen = 127.0.0.1:9000, 把 127.0.0.1:9000 改成 /var/run/php5-fpm.sock.
listen = /var/run/php5-fpm.sock
儲存退出,啟動PHP
sudo service php5-fpm restart
配置Nginx
sudo nano /etc/nginx/sites-available/default
啟用PHP,綁定目錄和index檔案
[...]server { listen 80; root /var/www; index index.php index.html index.htm; server_name example.com; location / { try_files $uri $uri/ /index.html; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # pass the PHP scripts to FastCGI server listening on the php-fpm socket location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}[...]
可以了,建個檔案試試吧:
sudo nano /var/www/info.php
如果覺得有價值,歡迎加我(keerol)或關注我微博(weibo/yanghongjin)
在Ubuntu 12.4 下安裝 nginx, MySQL, PHP