Install Nginx with PHP5 and MySQL (LEMP) in Ubuntu 13.10 Ser
This tutorial shows you how to install LEMP stack in Ubuntu 13.10. LEMP stands for Linux , Nginx (pronounced “engine x”), MySQL and PHP . The nginx project started with a strong focus on high concurrency, high performance and low memory
This tutorial shows you how to install LEMP stack in Ubuntu 13.10. LEMP stands for Linux, Nginx (pronounced “engine x”), MySQL and PHP. The nginx project started with a strong focus on high concurrency, high performance and low memory usage. So it’s a good alternative to Apache webserver for building websites on low memory hosts.
Tutorial Objectives:
- Install Nginx, Php5, MySQL (LEMP) in Ubuntu 13.10 Server
- Enjoy!
To get started, first login your Ubuntu Server and follow the steps below:
1. Intall MySQL
MySQL is a database management system which stores and organizes references to the information the webserver needs.
To install it, run command:
sudo apt-get install mysql-server mysql-client
While the installing process, you’ll be asked to type a password for MySQL root user.
2. Install Nginx
Nginx is available in Ubuntu’s repository, run command below to install it:
sudo apt-get install nginx
Or you can install the latest stable version from Nginx PPA:
sudo apt-get install python-software-properties sudo add-apt-repository ppa:nginx/stable sudo apt-get update sudo apt-get install nginx
Once installed, start Nginx by:
sudo service nginx start
To check out if nginx is working, go to http://serverip:
nginx is working ubuntu 13.10
3. Install PHP5
PHP is a reflective programming language, which makes it possible for all these different parts to work together.
We can make PHP5 work in nginx through PHP-FPM, which is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites.
Run command below to install php5-fpm:
sudo apt-get install php5-fpm
4. Setup Nginx
The nginx configuration is in /etc/nginx/nginx.conf, read this configuration example.
Now, let’s modify the default site example:
sudo vi /etc/nginx/sites-available/default
Here you can define root directory (to put WordPress files there), your site domain, as well as other settings. See the example below:
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name localhost; location / { try_files $uri $uri/ /index.php; } location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; allow ::1; deny all; } # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { # With php5-fpm: try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } }
After that, reload Nginx:
sudo service nginx reload
4. Check out if PHP is working
Create the test file:
sudo vi /usr/share/nginx/html/info.php
Add following lines and save the file:
<?php phpinfo(); ?>
Go to http://serverip/info.php in client’s web browser and you’ll see:
php is working
5. Get MySQL working with PHP
Install Xcache, a free and open PHP opcode cacher for caching and optimizing PHP intermediate code, as well as other PHP modules:
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-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-xcache
Then restart php5:
sudo service php5-fpm restart
Now reload http://serverip/info.php page and scroll down to find out if there’s a div about MySQL:
mysql is working with php
Now your LEMP server is up and running, see how to install wordpress on Ubuntu 13.10
确实好文,感谢原作者。

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

如何在 Windows 中配置 Nginx?安裝 Nginx 並創建虛擬主機配置。修改主配置文件並包含虛擬主機配置。啟動或重新加載 Nginx。測試配置並查看網站。選擇性啟用 SSL 並配置 SSL 證書。選擇性設置防火牆允許 80 和 443 端口流量。

Docker 容器啟動步驟:拉取容器鏡像:運行 "docker pull [鏡像名稱]"。創建容器:使用 "docker create [選項] [鏡像名稱] [命令和參數]"。啟動容器:執行 "docker start [容器名稱或 ID]"。檢查容器狀態:通過 "docker ps" 驗證容器是否正在運行。

可以通過以下步驟查詢 Docker 容器名稱:列出所有容器(docker ps)。篩選容器列表(使用 grep 命令)。獲取容器名稱(位於 "NAMES" 列中)。

確認 Nginx 是否啟動的方法:1. 使用命令行:systemctl status nginx(Linux/Unix)、netstat -ano | findstr 80(Windows);2. 檢查端口 80 是否開放;3. 查看系統日誌中 Nginx 啟動消息;4. 使用第三方工具,如 Nagios、Zabbix、Icinga。

在 Docker 中創建容器: 1. 拉取鏡像: docker pull [鏡像名] 2. 創建容器: docker run [選項] [鏡像名] [命令] 3. 啟動容器: docker start [容器名]

可以查詢 Nginx 版本的方法有:使用 nginx -v 命令;查看 nginx.conf 文件中的 version 指令;打開 Nginx 錯誤頁,查看頁面的標題。

在雲服務器上配置 Nginx 域名的方法:創建 A 記錄,指向雲服務器的公共 IP 地址。在 Nginx 配置文件中添加虛擬主機塊,指定偵聽端口、域名和網站根目錄。重啟 Nginx 以應用更改。訪問域名測試配置。其他注意事項:安裝 SSL 證書啟用 HTTPS、確保防火牆允許 80 端口流量、等待 DNS 解析生效。

當 Nginx 服務器宕機時,可執行以下故障排除步驟:檢查 nginx 進程是否正在運行。查看錯誤日誌以獲取錯誤消息。檢查 nginx 配置語法正確性。確保 nginx 具有訪問文件所需的權限。檢查文件描述符打開限制。確認 nginx 正在偵聽正確的端口。添加防火牆規則以允許nginx流量。檢查反向代理設置,包括後端服務器可用性。如需進一步幫助,請聯繫技術支持。
