zoukankan      html  css  js  c++  java
  • 服务器架设:CentOS搭建LAMP详细教程

    面,你就能看到刚刚安装的 PHP和MySQL 模块。

    6. 设置 Apache2 和 MySQL 开机启动

    chkconfig --levels 3 httpd on
    chkconfig --list httpd
    /etc/init.d/httpd restart
    
    chkconfig --levels 3 mysqld on
    chkconfig --list mysqld
    /etc/init.d/mysqld restart
    

    注意:“设置 Apache 和 MySQL 开机启动”这一步一定要做,否则是访问不了你的网站的。

    OK,一个 LAMP 服务器搭建完成。

    第二部分

    1.安装phpMyAdmin

    如果已经将PHP更新到5.2.x,可以自行安装phpMyAdmin最新版3.x。
    如果没有更新PHP的版本,由于 yum install php安装的版本为php5.1版,而phpMyAdmin-3.x只能搭配php5.2.x 使用,所以不要上传phpMyAdmin-3.x版,而应该上传较低的版本:phpMyAdmin-2.11.10版或phpMyAdmin- 2.11.9.6版,这两个较低版本的phpMyAdmin才能搭配php5.1使用。建议用如下办法:

    phpMyAdmin是一款MySQL数据库web化的管理工具。

    我们先使我们的CentOS支持RPMforge repository,因为phpMyAdmin并不在CentOS5.3官方的依赖包里:

    对于 x86_64 系统:

    wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
    rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
    

    对于 i386系统

    wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
    rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
    

    现在你就可以使用下列命令来安装phpMyAdmin了:

    yum install phpmyadmin
    

    现在我们配置下phpMyAdmin。我们改下Apache的配置文件,使的phpMyAdmin不单单是本机访问。 (即注销<Directory “/usr/share/phpmyadmin”>) 如下所示:

    #<Directory “/usr/share/phpmyadmin”>
    #  Order Deny,Allow
    #  Deny from all
    #  Allow from 127.0.0.1
    #</Directory>

    vi /etc/httpd/conf.d/phpmyadmin.conf
    

    然后登陆winscp,进入/usr/share/phpmyadmin/,然后修改里面的配置文件:config.inc.php。

    在$cfg['blowfish_secret'] = ‘ ‘,单引号里面随便填一个字符串。

    在$cfg['Servers'][$i]['controluser'] = ”,单引号里面填入root;

    在$cfg['Servers'][$i]['controlpass'] = ”,单引号里面填入你在安装mysql时所设置的密码。然后保存更改。

    重启Apache:

    /etc/init.d/httpd restart
    

    然后,你就可以通过http://domain.com/phpmyadmin/:访问phpMyAdmin了。

    2.使用putty登陆SSH

    这是给网站根目录赋予写权限

    chown root:root /var/www/html/ -R
    

    或者

    chmod -R 777 /var/www/html/
    

    安装zip文件解压工具

    yum install unzip
    

    3.在Apache配置文件中添加你的虚拟机信息

    vi /etc/httpd/conf/httpd.conf
    

    此为IPv4虚拟机配置,已包含rewrite信息,支持WordPress固定链接
    <VirtualHost 67.123.122.21:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/html
    ServerName www.abc.com
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
    <Directory “/var/www/html”>
    Options FollowSymLinks IncludesNOEXEC Indexes
    DirectoryIndex index.html index.htm index.php
    AllowOverride all
    Order Deny,Allow
    Allow from all
    </Directory>
    </VirtualHost>

    此为IPv6虚拟机配置,已包含rewrite信息
    <VirtualHost [2201:f676:2:382:0:123:1661:2]:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/html
    ServerName www.abc.com
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
    <Directory “/var/www/html”>
    Options FollowSymLinks IncludesNOEXEC Indexes
    DirectoryIndex index.html index.htm index.php
    AllowOverride all
    Order Deny,Allow
    Allow from all
    </Directory>
    </VirtualHost>

    确认Apache工作在Dual Stack模式:

    netstat -tulpn | grep :80
    

    第三部分

    实例:安装WordPress设置固定链接教程
    1.安装Wget

    yum install wget

    2.进入虚拟机所在目录

    cd /var/www/html

    3.下载WordPress到服务器并解压

    wget wget http://wordpress.org/latest.tar.gz
    tar zxvf latest.tar.gz

    4.修改WordPress目录属性

    chmod -R 777 /var/www/html/wordpress
    chgrp -R ftp /var/www/html/wordpress
    chown -R www /var/www/html/wordpress
    

    5.修改apache2的虚拟机配置文件(位于/etc/httpd/conf/httpd.conf),在<VirtualHost *:80>和</VirtualHost>中间加入下面代码

    <Directory “/var/www/html”>
    Options FollowSymLinks IncludesNOEXEC Indexes
    DirectoryIndex index.html index.htm index.php
    AllowOverride all
    Order Deny,Allow
    Allow from all
    </Directory>

    6.apache2重新加载配置:

    /etc/init.d/httpd restart

    提醒一下,本教程未提及FTP服务的安装,如果需要可以安装vsftpd或pureftpd,过程不再赘述。因为我自己觉得使用WinSCP的SFTP就够用了,没有必要安装过多的服务消耗系统资源。

  • 相关阅读:
    Sqoop
    Mediawiki
    TextMate 通用快捷键
    Wind7外接显示器选择拓展模式后,鼠标只能往右移动才能切换到外接显示器上,不能修改切换方向
    用Nginx+Lua(OpenResty)开发高性能Web应用
    netty4.0.x源码分析—bootstrap
    mysql分组合并GROUP_CONCAT
    Only POT texture can be compressed to PVRTC format
    手机屏幕左下角显示Fastboot mode是什么情况?
    判断UNITY版本号
  • 原文地址:https://www.cnblogs.com/cnsanshao/p/2158298.html
Copyright © 2011-2022 走看看