centos6伺服器YUM安裝LNMP(LINUX+NGINX+MYSQL+PHP)

來源:互聯網
上載者:User

標籤:

之前都用的lamp,這次配置一個lnmp來看看,試試Nginx是不是好用

關閉SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注釋掉
#SELINUXTYPE=targeted #注釋掉
SELINUX=disabled #增加

shutdown -r now #重啟系統

安裝ngnix

安裝GCC編譯器及相關工具
yum -y install gcc gcc-c++ autoconf automake
安裝模組依賴的庫
yum -y install zlib zlib-devel openssl openssl–devel pcre pcre-devel
更新系統時間
ntpdate time.nist.gov
讓對時服務開機啟動
chkconfig ntpd on

如果需要編譯安裝最新的
擷取ngnix版本
wget http://nginx.org/download/nginx-1.0.14.tar.gz
tar zxvf nginx-1.0.14.tar.gz
cd nginx-1.0.14

直接yum安裝
yum install -y nginx
將安裝在/usr/share/nginx/
啟動nginx
service ngnix start

安裝PHP

cd /etc/yum.repos.d
wget http://dev.centos.org/centos/5/CentOS-Testing.repo
rpm –import http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing

yum install -y php php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm

#啟動php-fpm
/etc/rc.d/init.d/php-fpm start
設定自動啟動
chkconfig php-fpm on

配置nginx支援php
cp /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
vi /etc/nginx/nginx.conf
#修改nginx運行帳號為:nginx組的nginx使用者
user nginx nginx;

cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak
vi /etc/nginx/conf.d/default.conf
#增加index.php
index index.php index.html index.htm;
取消FastCGI server部分location的注釋,並要注意fastcgi_param行的參數,改為$document_root$fastcgi_script_name,或者使用絕對路徑

配置php-fpm
cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.confbak
vi /etc/php-fpm.d/www.conf
#修改使用者為nginx
user = nginx
#修改組為nginx
group = nginx

安裝MYSQL
yum -y install mysql mysql-server
啟動mysql
service mysqld start
chkconfig mysqld on #設為開機啟動

為root賬戶設定密碼
mysql_secure_installation

重啟所有服務
service mysqld restart
service nginx restart
/etc/rc.d/init.d/php-fpm restart
測試成功

安裝ssh伺服器和subversion伺服器
yum install -y openssh-server
yum install -y subversion

centos6伺服器YUM安裝LNMP(LINUX+NGINX+MYSQL+PHP)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.