centos6 lnmp安装mysql_centos6.5安装lnmp环境
1.安裝nignx的源,默認cenots6沒有的。
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
如果全部軟件想要最新的那么就改yum的源吧
centos6.5適用的國內yum源:網易、搜狐
趙榮濤?2014-08-03?1510?閱讀
本人安裝的操作系統是centos 6.5,默認的yum源是centos官網的,速度慢是不用說了。所以使用yum安裝東西之前需要把yum源改為國內的。現貼上國內網易和搜狐的yum源。
設置方法如下:
1,進入yum源配置目錄
cd /etc/yum.repos.d
2,備份系統自帶的yum源
mv CentOS-Base.repo CentOS-Base.repo.bak
下載163網易的yum源:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
更改文件名
mv CentOS6-Base-163.repo CentOS-Base.repo
3,更新玩yum源后,執行下邊命令更新yum配置,使操作立即生效
yum clean all
yum makecache
但是搜狐的好像截止到筆者發布此文章時,還沒有centos6的yum源。
中科大的
1、安裝nginx
[root@localhost ~]# yum -y install nginx??????? 安裝nginx軟件
[root@localhost ~]# service nginx start???????? 啟動
[root@localhost ~]# chkconfig nginx on???????? 設置開機啟動
[root@localhost ~]# /etc/init.d/nginx restart???????? 重啟nginx服務
[root@localhost ~]# rm -rf /usr/share/nginx/html/*??????? 刪除nginx默認頁面
2、安裝mysql
[root@localhost ~]# yum install mysql mysql-server -y??????? 安裝mysql
[root@localhost ~]# /etc/init.d/mysqld start??????? 啟動mysql
[root@localhost ~]# chkconfig mysqld on??????? 設置開機啟動
[root@localhost ~]# cp /usr/share/mysql/my-medium.cnf? /etc/my.cnf??????? 拷貝配置文件,直接覆蓋原有的
[root@localhost ~]# reboot??????? 重啟系統
[root@localhost ~]# mysql_secure_installation??????? 為root設置密碼
[root@localhost ~]# /etc/init.d/mysqld stop???????? 啟動mysql
[root@localhost ~]# /etc/init.d/mysqld start???????? 停止mysql
[root@localhost ~]# service mysqld restart??????? 重啟mysql
3、安裝php
[root@localhost ~]# yum install php -y
[root@localhost ~]# yum -y install php-mysql phpgd 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
[root@localhost ~]# /etc/init.d/mysqld restart??????? 重啟mysql服務
[root@localhost ~]# /etc/init.d/nginx restart???????? 重啟nginx服務
[root@localhost ~]# /etc/rc.d/init.d/php-fpm start???? 啟動php-fpm服務
[root@localhost ~]# chkconfig php-fpm on??????? 設置開機啟動
配制
1、配置nginx支持PHP
[root@localhost ~]# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
[root@localhost ~]# vim /etc/nginx/nginx.conf
user???? nginx?? nginx;?? #修改 nginx 運行賬號為:nginx 組的 nginx 用 戶!
[root@localhost ~]# cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
[root@localhost ~]# vim /etc/nginx/conf.d/default.conf
index? index.php index.html index.htm;
location ~ \.php$ {
root?????????? html;
fastcgi_pass?? 127.0.0.1:9000;
fastcgi_index? index.php;
fastcgi_param? SCRIPT_FILENAME? $document_root$fastcgi_script_name;
fastcgi_param? PHP_VALUE "open_basedir=$document_root:/tmp/";???????????????? 添加的這行? 防止跨站
include??????? fastcgi_params;
}
#取消 FastCGI server 部分location 的注釋,并要注意 fastcgi_param 行的參數, 改為$document_root$fastcgi_script_name,或者使用絕對路徑
[root@localhost ~]# vim /etc/php.ini
date.timezone = PRC
expose_php = Off
#;open_basedir = .:/tmp/??????? 注釋掉這行
3、配置php-fpm
[root@localhost ~]# vim /etc/php-fpm.d/www.conf??????? 編輯
user = nginx??????? 編輯用戶為nginx
group = nginx??????? 修改組為nginx
[root@localhost ~]# /etc/init.d/mysqld restart??? 重啟mysql
[root@localhost ~]# /etc/init.d/nginx restart??????? 啟動nginx
[root@localhost ~]# /etc/rc.d/init.d/php-fpm restart??????? 重啟Php-fpm
測試篇
[root@localhost ~]# cd /usr/share/nginx/html/??????? 進入nginx默認網站根目錄
[root@localhost html]# cat index.php???????? 新建index.php文件
phpinfo()
?>
[root@localhost html]# chown nginx.nginx /usr/share/nginx/html/ -R???????? 設置是目錄所有者
[root@localhost html]# chmod 700 /usr/share/nginx/html/ -R??????? 設置目錄權限
備注
[root@localhost ~]# cd /usr/share/nginx/html/??????? nginx默認的程序目錄
[root@localhost ~]# chown nginx.nginx /usr/share/nginx/html/ -R??????? 權限設置
[root@localhost ~]# cd /var/lib/mysql/????????數據庫目錄是
[root@localhost ~]# chown mysql.mysql -R /var/lib/mysql/??????? 權限設置
[root@localhost html]# tail -n20 /var/log/nginx/error.log??????? 查看nginx的日志
軟件版本
[root@localhost html]# nginx -v
nginx version: nginx/1.6.2
[root@localhost html]# php -v
PHP 5.4.36 (cli) (built: Dec 22 2014 16:06:29)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
[root@localhost html]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.41-cll-lve MySQL Community Server (GPL) by Atomicorp
總結
以上是生活随笔為你收集整理的centos6 lnmp安装mysql_centos6.5安装lnmp环境的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: uniapp保存图片_Uniapp实现保
- 下一篇: java 以什么开头_判断字符串以什么开