CentOS配置Lamp
1.安裝Apache
自帶Apache
centos6.4本身自帶Apache,默認(rèn)沒(méi)有開(kāi)啟
[root@ceshi Desktop]# rpm -q httpd
httpd-2.2.15-26.el6.centos.i686
[root@ceshi Desktop]# rpm -qa | grep httpd
httpd-tools-2.2.15-26.el6.centos.i686
httpd-2.2.15-26.el6.centos.i686
用不用安裝擴(kuò)展呢?
[root@ceshi Desktop]# yum search all httpd
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
- base: mirrors.yun-idc.com
- extras: mirrors.yun-idc.com
updates: mirrors.tuna.tsinghua.edu.cn
============================================================================ Matched: httpd ============================================================================
libmicrohttpd-doc.noarch : Documentation for libmicrohttpd
httpd-devel.i686 : Development interfaces for the Apache HTTP server
httpd-manual.noarch : Documentation for the Apache HTTP server
httpd-tools.i686 : Tools for use with the Apache HTTP Server
libmicrohttpd.i686 : Lightweight library for embedding a webserver in applications
libmicrohttpd-devel.i686 : Development files for libmicrohttpd
httpd.i686 : Apache HTTP Server
mod_dav_svn.i686 : Apache httpd module for Subversion server
mod_dnssd.i686 : An Apache HTTPD module which adds Zeroconf support
mod_auth_mellon.i686 : A SAML 2.0 authentication module for the Apache Httpd Server
mod_lookup_identity.i686 : Apache module to retrieve additional information about the authenticated user
mod_ssl.i686 : SSL/TLS module for the Apache HTTP Server開(kāi)啟Apache服務(wù)
參考http://blog.sina.com.cn/s/blog_70ac6bec01018mqs.html
如果apache安裝成為linux的服務(wù)的話,可以用以下命令操作:
service httpd start 啟動(dòng)
service httpd restart 重新啟動(dòng)
service httpd stop 停止服務(wù)設(shè)置Apache服務(wù)為開(kāi)機(jī)啟動(dòng)
參考http://www.cnblogs.com/Anker/p/3551508.html
http://www.jb51.net/article/74603.htmchkconfig --list | grep httpd
chkcongfig httpd on 設(shè)置httpd每次開(kāi)機(jī)自己?jiǎn)?dòng),但并不現(xiàn)在就啟動(dòng)。運(yùn)行級(jí)別2345都為on
service httpd start 現(xiàn)在啟動(dòng)httpd服務(wù),但是下次開(kāi)機(jī)不會(huì)自動(dòng)啟動(dòng)此時(shí)只能虛擬機(jī)本機(jī)訪問(wèn)80端口,因?yàn)閕ptables中沒(méi)有開(kāi)放80端口
此時(shí)iptables的運(yùn)行級(jí)別2345都是on
關(guān)閉iptables
關(guān)閉命令: service iptables stop
永久關(guān)閉防火墻:chkconfig iptables off
查看iptables狀態(tài) :service iptables status查看當(dāng)前iptables狀態(tài)
iptables -L -n
service iptables status
此時(shí)在物理機(jī)用nmap掃描只能掃面到一個(gè)22端口iptables中添加80端口
參考
http://blog.csdn.net/youcharming/article/details/41986709
http://www.2cto.com/os/201304/201164.html/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/etc/rc.d/init.d/iptables save 或者 service iptables save #保存配置
/etc/rc.d/init.d/iptables restart 或者 service iptables restart #重啟服務(wù)重裝Apache
直接yum install httpd 會(huì)對(duì)本身安裝的Apache進(jìn)行升級(jí)。現(xiàn)在只有2.2版本的
要想安裝2.4版本的可以下載安裝包自己安裝
2.安裝mysql
用戶名 root
密碼 root
參考
http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html
http://www.cnblogs.com/zgaspnet/p/3967002.html
http://jingyan.baidu.com/article/acf728fd10c3d6f8e510a3ef.html
http://jingyan.baidu.com/article/c74d600079be530f6a595dc3.html
有內(nèi)容可借鑒
自帶mysql
本虛擬機(jī)的mysql是通過(guò)rpm 安裝的不是原版自帶的
查看安裝的mysql
rpm -qa | grep mysql
yum search all mysql
[root@ceshi Desktop]# rpm -qa | grep mysql
mysql-5.1.73-3.el6_5.i686
mysql-server-5.1.73-3.el6_5.i686
mysql-libs-5.1.73-3.el6_5.i686
本centos默認(rèn)沒(méi)有安裝mysql-devel
mysql -u root root空密碼登陸
select user,host,password from mysql.user; 查看用戶信息
show databases;
設(shè)置root用戶的密碼
set password for root@localhost=password ('在這里填入root密碼');
set password for root@127.0.0.1=password ('在這里填入root密碼');
set password for root@localhost.localdomain=password ('在這里填入root密碼'); 綠色的是主機(jī)名
此時(shí)匿名賬號(hào)是可以登陸的,但是為什么只顯示2個(gè)數(shù)據(jù)庫(kù)呢?
mysql -u -p
mysql> show databases;
+----------------------------------+
| Database |
+----------------------------------+
| information_schema |
| test |
+----------------------------------+
刪除匿名登錄賬號(hào)
delete from mysql.user where user='';
刷新
flush privileges;
CREATE USER 'root'@'%' IDENTIFIED BY '您的密碼'; ← 增加root用戶指定可以任意IP登錄,如果想限制只能讓指定IP登錄請(qǐng)把%替換成IP地址
GRANT ALL PRIVILEGES ON * . * TO 'root'@'%' IDENTIFIED BY '你的密碼' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; ← 給新添加的root增加權(quán)限
刷新
flush privileges;
3.安裝php
參考 http://www.cnblogs.com/liulun/p/3535346.htmlyum方式安裝 查看是否安裝 rpm -qi php 本centos6.4 默認(rèn)沒(méi)有安裝安裝php yum install php (沒(méi)有安裝php-devel)重啟apache使php生效 /etc/init.d/httpd restart此時(shí)可以在目錄:/var/www/html/下建立一個(gè)PHP文件 代碼:<?php phpinfo(); ?> 訪問(wèn)此文件成功安裝php擴(kuò)展yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc(yum search all php 搜索所有擴(kuò)張) 安裝包安裝4.安裝phpmyadmin
yum方式安裝
參考
http://blog.csdn.net/rachel_luo/article/details/8692744
http://www.cnblogs.com/shenliang123/p/3829044.html
http://blog.csdn.net/rachel_luo/article/details/8692744
http://blog.csdn.net/licongcong_0224/article/details/15041939
轉(zhuǎn)載于:https://www.cnblogs.com/lnxcode/p/11139119.html
總結(jié)
以上是生活随笔為你收集整理的CentOS配置Lamp的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Win10自动更新关闭方法
- 下一篇: FastJsonUtils 需要fast