Apache+Mysql+PHP

Jun 23, 2016 pm 02:37 PM

转载自:http://blog.csdn.net/buutterfly/article/details/5630203

DedeCMS部署--怎样去部署Apache+Mysql+PHP(LAMP)?

1. Linux OS:

Linux OS:Red Hat Enterprise Linux AS release 4 (Nahant Update 6)

 

2.Deploy Apache 2.1  下载Apache

下载Apache2 source from http://httpd.apache.org/  ,直接下载在/root下,解压tar包php-5.2.13。

2.2  编译 apache

cd httpd-2.2.15,进行编译,生成Makefile

./configure --prefix=/usr/local/apache /  --指定apache安装目录

               --enable-so                    /

                 --enable-cgi                   /

                 --enable-info                 /

                 --enable-rewrite          /

                 --enable-speling           /

                 --enable-usertrack      /

                 --enable-deflate /

                 --enable-ssl                   /

--enable-mime-magic

2.3  make & make install

Make过程中可能会有一些问题,具体可以参考第5节。

Apache部署参考:http://dan.drydog.com/apache2php.html

3. Deploy Mysql 3.1下载mysql

下载mysql source from http://dev.mysql.com/ ,在Downloads页面选择 MySQL Community Server ,进入下载页面。选择 Red Hat Enterprise Linux。因为我的OS是REHL4.6 ,且为64位,则下载三个包:

MySQL-server-community-5.1.47-1.rhel4.x86_64.rpm MySQL-devel-community-5.1.47-1.rhel4.x86_64.rpm ?必须,否则apache编译的时候会出错MySQL-client-community-5.1.47-1.rhel4.x86_64.rpm

3.2 安装mysql server

rpm ?ivh MySQL-server-community-5.1.47-1.rhel4.x86_64.rpm

server安装完毕后,测试是否成功可运行netstat看Mysql端口是否打开,如打开表示服务已经启动,安装成功。

Mysql默认的端口是3306。命令如下: netstat ?nap |grep 3306

3.3 安装mysql client

rpm ?ivh MySQL-client-community-5.1.47-1.rhel4.x86_64.rpm

3.4 安装 mysql devel

rpm ?ivh MySQL-devel-community-5.1.47-1.rhel4.x86_64.rpm

3.5 登录Mysql

    [root@test1 local]# mysql

   Welcome to the MySQL monitor. Commands end with ; or /g.

   Your MySQL connection id is 1 to server version: 4.0.16-standard

   Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

   mysql>

   出现了“mysql>”提示符,恭喜你,安装成功!

   增加了密码后的登录格式如下:

   mysql -u root -p

   Enter password: (输入密码)

   其中-u后跟的是用户名,-p要求输入密码,回车后在输入密码处输入密码。

   注意:这个mysql文件在/usr/bin目录下,与后面讲的启动文件/etc/init.d/mysql不是一个文件。

3.6 修改mysql 密码

 MySQL默认没有密码,安装完毕增加密码的重要性是不言而喻的。

   1、命令

   usr/bin/mysqladmin -u root password 'new-password'

   格式:mysqladmin -u用户名 -p旧密码 password 新密码

   2、例子

   例1:给root加个密码123456。

   键入以下命令 :

   [root@test1 local]# /usr/bin/mysqladmin -u root password 123456

  注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。

   3、测试是否修改成功

   1)不用密码登录

   [root@test1 local]# mysql

   ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)

   显示错误,说明密码已经修改。

   2)用修改后的密码登录

   [root@test1 local]# mysql -u root -p

   Enter password: (输入修改后的密码123456)

   Welcome to the MySQL monitor. Commands end with ; or /g.

   Your MySQL connection id is 4 to server version: 4.0.16-standard

   Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

   mysql>

   成功!

   这是通过mysqladmin命令修改口令,也可通过修改库来更改口令。

3.7 启动和停止

1、启动

   MySQL安装完成后启动文件mysql在/etc/init.d目录下,在需要启动时运行下面命令即可。

   [root@test1 init.d]# /etc/init.d/mysql start

   2、停止

   /usr/bin/mysqladmin -u root -p shutdown

   3、自动启动

   1)察看mysql是否在自动启动列表中

   [root@test1 local]# /sbin/chkconfig --list

   2)把MySQL添加到你系统的启动服务组里面去

   [root@test1 local]# /sbin/chkconfig ?- add mysql

   3)把MySQL从启动服务组里面删除。

   [root@test1 local]# /sbin/chkconfig ?-del mysql

Mysql部署 参考:http://www.linuxidc.com/Linux/2007-12/9962p3.htm

3.8 使用mysql

(对于我们LAMP环境部署来说,可选择性的使用本节)

MySQL默认的数据文件存储目录为/var/lib/mysql。假如要把目录移到/home/data下需要进行下面几步:

   1、home目录下建立data目录

   cd /home

   mkdir data

   2、把MySQL服务进程停掉:

   mysqladmin -u root -p shutdown

   3、把/var/lib/mysql整个目录移到/home/data

   mv /var/lib/mysql /home/data/

   这样就把MySQL的数据文件移动到了/home/data/mysql下

   4、找到my.cnf配置文件

  如果/etc/目录下没有my.cnf配置文件,请到/usr/share/mysql/下找到*.cnf文件,拷贝其中一个到/etc/并改名为my.cnf)中。命令如下:

   [root@test1 mysql]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

   5、编辑MySQL的配置文件/etc/my.cnf

  为保证MySQL能够正常工作,需要指明mysql.sock文件的产生位置。修改socket=/var/lib/mysql/mysql.sock一行中等号右边的值为:/home/mysql/mysql.sock 。操作如下:

   vi  my.cnf    (用vi工具编辑my.cnf文件,找到下列数据修改之)

   # The MySQL server

    [mysqld]

    port   = 3306

    #socket  = /var/lib/mysql/mysql.sock(原内容,为了更稳妥用“#”注释此行)

    socket  = /home/data/mysql/mysql.sock   (加上此行)

   6、修改MySQL启动脚本/etc/rc.d/init.d/mysql

  最后,需要修改MySQL启动脚本/etc/rc.d/init.d/mysql,把其中datadir=/var/lib/mysql一行中,等号右边的路径改成你现在的实际存放路径:home/data/mysql。

   [root@test1 etc]# vi /etc/rc.d/init.d/mysql

   #datadir=/var/lib/mysql    (注释此行)

   datadir=/home/data/mysql   (加上此行)

   7、重新启动MySQL服务

   /etc/rc.d/init.d/mysql start

   或用reboot命令重启Linux

   如果工作正常移动就成功了,否则对照前面的7步再检查一下。

 

4. Deploy PHP

PHP的部署是整个部署最困难的一个环节,这个环节也是让我耗时,在网络上查找答案最长的部分。

4.1 下载PHP

下载 PHP source from http://www.php.net/

注意:dedecms 5.6以上版本对php5.3支持有瑕疵!如果用php5.3版本,在安装cms安装成功后,系统后台页面会提示“针对于安装完成后出现安装完出现Deprecated: Function ereg_replace() is deprecated ....”。

解决有两种方法,见第5节。

4.2 编译PHP

cd php-5.2.13,进行编译,生成Makefile。注意:这个地方的配置项需要根据自己的需要选择。

./configure /

     --with-apxs2=/usr/local/apache/bin/apxs /

     --with-mysql /

     --prefix=/usr/local/apache/php /

     --with-config-file-path=/usr/local/apache/php /

     --enable-force-cgi-redirect /

     --disable-cgi /

     --with-zlib /

     --with-gettext /

     --with-gdbm  /

  --with-gd

4.3 make & make install 4.4 cp -p .libs/libphp5.so /usr/local/apache/modules 4.5 cp php.ini

命令如下:  cp -p php.ini-recommended /usr/local/apache/php/php.ini

4.6 修改httpd.conf

修改 /usr/local/apache/conf/httpd.conf,加入以下内容:

1.

# Example:

# LoadModule foo_module modules/mod_foo.so

#

LoadModule php5_module        modules/libphp5.so

AddHandler php5-script php

2.

# DirectoryIndex: sets the file that Apache will serve if a directory

# is requested.

    #DirectoryIndex index.html

     DirectoryIndex index.php index.html index.shtml index.cgi

 

3.

    # If the AddEncoding directives above are commented-out, then you

    # probably should define those extensions to indicate media types:

    #

    AddType application/x-compress .Z

    AddType application/x-gzip .gz .tgz

    AddType application/x-httpd-php .php .phtml

AddType application/x-httpd-php-source .phps

4.7 修改完成后重新启动apache

PHP安装参考:http://dan.drydog.com/apache2php.html

 

5.遇到的问题以及解决办法 5.1 error: libpng.(a|so) not found.

现象描述:

编译apache的时候提示:

checking for floorf... yes

If configure fails try --with-jpeg-dir=

configure: error: libpng.(a|so) not found.

解决办法:

通过上面的搜索其实就知道一些原因了,configure一般的搜索编译路径为/usr/lib/下,因为php默认就在/usr/lib/下找相关库文件,而x64机器上是在:/usr/lib64.这时你就可以直接把需要的库文件从/usr/lib64中拷贝到/usr/lib/中去就可以了.

那么记得要在configure前执行如下的命令:

cp -frp /usr/lib64/libjpeg.* /usr/lib/

 

5.2  error: Cannot find MySQL header files under yes

现象描述:

编译apache的时候提示:

checking for specified location of the MySQL UNIX socket... no

configure: error: Cannot find MySQL header files under yes.

Note that the MySQL client library is not bundled anymore!

解决办法:

这个是缺少了 mysql-devel 安装包,rpm ?ivh 安装devel包,前面提到过。

5.3 mysql-server,mysql-devel,mysql-client的异同

英文原版:

In most cases, you only need to install the MySQL-server and MySQL-client packages to get a functional MySQL installation. The other packages are not required for a standard installation. If you want to run a MySQL-Max server that has additional capabilities, you should also install the MySQL-Max RPM. However, you should do so only after installing the MySQL-server RPM.

 

If you get a dependency failure when trying to install the MySQL 4.0 packages (for example, ``error: removing these packages would break dependencies: libmysqlclient.so.10 is needed by ...''), you should also install the package MySQL-shared-compat, which includes both the shared libraries for backward compatibility (libmysqlclient.so.12 for MySQL 4.0 and libmysqlclient.so.10 for MySQL 3.23).

 

The following RPM packages are available:

MySQL-server-VERSION.i386.rpm The MySQL server. You will need this unless you only want to connect to a MySQL server running on another machine. Note: Server RPM files were called MySQL-VERSION.i386.rpm before MySQL 4.0.10. That is, they did not have -server in the name.

MySQL-Max-VERSION.i386.rpm The MySQL-Max server. This server has additional capabilities that the one provided in the MySQL-server RPM does not. You must install the MySQL-server RPM first, because the MySQL-Max RPM depends on it.

MySQL-client-VERSION.i386.rpm The standard MySQL client programs. You probably always want to install this package.

MySQL-bench-VERSION.i386.rpm Tests and benchmarks. Requires Perl and the DBD::mysql module.

MySQL-devel-VERSION.i386.rpm The libraries and include files that are needed if you want to compile other MySQL clients, such as the Perl modules.

MySQL-shared-VERSION.i386.rpm This package contains the shared libraries (libmysqlclient.so*) that certain languages and applications need to dynamically load and use MySQL.

MySQL-shared-compat-VERSION.i386.rpm This package includes the shared libraries for both MySQL 3.23 and MySQL 4.0. Install this package instead of MySQL-shared if you have applications installed that are dynamically linked against MySQL 3.23 but you want to upgrade to MySQL 4.0 without breaking the library dependencies. This package has been available since MySQL 4.0.13.

MySQL-embedded-VERSION.i386.rpm The embedded MySQL server library (from MySQL 4.0).

MySQL-VERSION.src.rpm This contains the source code for all of the previous packages. It can also be used to rebuild the RPMs on other architectures (for example, Alpha or SPARC).

 

中文翻译:

MySQL-VERSION.i386.rpm MySQL服务器。除非你只是想要与运行在其他机器上MySQL服务器连接,否则你将需要它。

MySQL-client-VERSION.i386.rpm 标准MySQL客户程序。你可能总是需要安装这个包。

MySQL-bench-VERSION.i386.rpm 测试和基准程序。需要Perl和msql-mysql-modules RPM。

MySQL-devel-VERSION.i386.rpm 所需的库和包含文件。如果你想要编译其他MySQL客户程序, 例如Perl模块。

MySQL-VERSION.src.rpm 包含上述所有包的源代码。它也能被用来尝试为其他硬件平台构造RPM(例如,Alpha或SPARC)。

查看一个RPM包中的所有文件:

shell>; rpm - qpl  MySQL-VERSION.i386.rpm

实施一个标准的最小安装,运行这个命令:

shell>; rpm -i MySQL-VERSION.i386.rpm  MySQL-client-VERSION.i386.rpm

 

5.4 error: Cannot find libmysqlclient under /usr

现象描述:

error: Cannot find libmysqlclient under /usr

解决办法:

其实,和5.1解决办法相同。把/usr/lib64/mysql copy to /usr/lib/。

 

5.5 CMS目录权限问题

现象描述:

进入install页面后,提示有些目录没有读写权限,如下:

/usr/local/apache/htdocs/uploads

目录名           读取权限       写入权限

/      [√]读       [X] 写   ----指的是 /usr/local/apache/htdocs/uploads

/plus/*    [√]读       [X] 写

/dede/* [√]读       [X] 写

/data/*   [√]读       [√] 写

/a/*         [√]读       [√] 写

/install    [√]读       [√] 写

/special   [√]读       [√] 写

/uploads/*      [√]读       [√] 写

解决办法:

安装CMS时候,提示权限不够,需要修改uploads目录权限

 Chmod 777 uploads -R

5.6 Deprecated: Function ereg_replace() is deprecated

注意:dedecms 5.6以上版本对php5.3支持有瑕疵!如果用php5.3版本,在安装cms安装成功后,系统后台页面会提示“针对于安装完成后出现安装完出现Deprecated: Function ereg_replace() is deprecated ....”。

解决有两种方法,见第5节。

第一种:

dedecms由于技术人员的习惯问题可能针对php5.3甚至更高版本的php支持会有些错误,大家可以打开文件dede/config.php

找到define('DEDEADMIN', ereg_replace("[///]{1,}", '/', dirname(__FILE__) ) );

没有必要删除,只要在这句前面加入"//"将其隐掉就好了,然后在下面加一句

define('DEDEADMIN',strtr(dirname(__FILE__),'///','//'));

就可以了!上传覆盖,然后更新下在看看,应该解决问题!

第二种:

重新下载php5.2的包。其实这样使用也不麻烦,就是重新编译罢了,但是解决问题最直接的方法。为了防止后续再有什么问题,我就使用了php5.2重新编译了一遍。

 

对以上操作正则表达式的解释如下:

在正则表达式中,反斜线通常与其它字符一起构成特殊的结构,譬如‘/d’用来匹配数字字符,‘/s’用来匹配空白字符,‘/1’用来反向引用第一个分组捕获的文本。

可是,如果我们在正则表达式中,仅仅需要表示“反斜线”字符本身,该如何做呢?

其实,正则表达式对这个问题的处理,与字符串的处理是一样的,也就是说,在正则表达式中,必须用转义序列‘//’来表示单个反斜线。

这个规定会带来一个有趣的问题:正则表达式中单独出现的反斜线字符,在正则表达式的层面,必须以转义序列‘//’来表示,然而,每个反斜线,在表示正则表达 式的字符串中,又必须以转义序列‘//’来表示。所以,在字符串中,必须写出四个反斜线‘////’,才能对应到正则表达式中单独出现的一个反斜线字符: 在字符串处理层面,它们会被识别为两个反斜线‘//’,在正则表达式的层面,它们会被识别为单个反斜线字符‘/’。

Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

Heiße KI -Werkzeuge

Undresser.AI Undress

Undresser.AI Undress

KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover

AI Clothes Remover

Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool

Undress AI Tool

Ausziehbilder kostenlos

Clothoff.io

Clothoff.io

KI-Kleiderentferner

AI Hentai Generator

AI Hentai Generator

Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)
2 Wochen vor By 尊渡假赌尊渡假赌尊渡假赌
Repo: Wie man Teamkollegen wiederbelebt
4 Wochen vor By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Abenteuer: Wie man riesige Samen bekommt
4 Wochen vor By 尊渡假赌尊渡假赌尊渡假赌

Heiße Werkzeuge

Notepad++7.3.1

Notepad++7.3.1

Einfach zu bedienender und kostenloser Code-Editor

SublimeText3 chinesische Version

SublimeText3 chinesische Version

Chinesische Version, sehr einfach zu bedienen

Senden Sie Studio 13.0.1

Senden Sie Studio 13.0.1

Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver CS6

Dreamweaver CS6

Visuelle Webentwicklungstools

SublimeText3 Mac-Version

SublimeText3 Mac-Version

Codebearbeitungssoftware auf Gottesniveau (SublimeText3)

11 beste PHP -URL -Shortener -Skripte (kostenlos und Premium) 11 beste PHP -URL -Shortener -Skripte (kostenlos und Premium) Mar 03, 2025 am 10:49 AM

Lange URLs, die oft mit Schlüsselwörtern und Tracking -Parametern überfüllt sind, können Besucher abschrecken. Ein URL -Verkürzungsskript bietet eine Lösung, die präzise Links erstellt, die ideal für soziale Medien und andere Plattformen sind. Diese Skripte sind für einzelne Websites a wertvoll

Einführung in die Instagram -API Einführung in die Instagram -API Mar 02, 2025 am 09:32 AM

Nach seiner hochkarätigen Akquisition durch Facebook im Jahr 2012 nahm Instagram zwei APIs für den Einsatz von Drittanbietern ein. Dies sind die Instagram -Graph -API und die Instagram Basic Display -API. Ein Entwickler, der eine App erstellt, die Informationen von a benötigt

Arbeiten mit Flash -Sitzungsdaten in Laravel Arbeiten mit Flash -Sitzungsdaten in Laravel Mar 12, 2025 pm 05:08 PM

Laravel vereinfacht die Behandlung von temporären Sitzungsdaten mithilfe seiner intuitiven Flash -Methoden. Dies ist perfekt zum Anzeigen von kurzen Nachrichten, Warnungen oder Benachrichtigungen in Ihrer Anwendung. Die Daten bestehen nur für die nachfolgende Anfrage standardmäßig: $ Anfrage-

Erstellen Sie eine React -App mit einem Laravel -Back -Ende: Teil 2, reagieren Erstellen Sie eine React -App mit einem Laravel -Back -Ende: Teil 2, reagieren Mar 04, 2025 am 09:33 AM

Dies ist der zweite und letzte Teil der Serie zum Aufbau einer Reaktionsanwendung mit einem Laravel-Back-End. Im ersten Teil der Serie haben wir eine erholsame API erstellt, die Laravel für eine grundlegende Produktlistenanwendung unter Verwendung von Laravel erstellt hat. In diesem Tutorial werden wir Dev sein

Vereinfachte HTTP -Reaktion verspottet in Laravel -Tests Vereinfachte HTTP -Reaktion verspottet in Laravel -Tests Mar 12, 2025 pm 05:09 PM

Laravel bietet eine kurze HTTP -Antwortsimulationssyntax und vereinfache HTTP -Interaktionstests. Dieser Ansatz reduziert die Code -Redundanz erheblich, während Ihre Testsimulation intuitiver wird. Die grundlegende Implementierung bietet eine Vielzahl von Verknüpfungen zum Antworttyp: Verwenden Sie Illuminate \ Support \ facades \ http; Http :: fake ([ 'Google.com' => 'Hallo Welt',, 'github.com' => ['foo' => 'bar'], 'Forge.laravel.com' =>

Curl in PHP: So verwenden Sie die PHP -Curl -Erweiterung in REST -APIs Curl in PHP: So verwenden Sie die PHP -Curl -Erweiterung in REST -APIs Mar 14, 2025 am 11:42 AM

Die PHP Client -URL -Erweiterung (CURL) ist ein leistungsstarkes Tool für Entwickler, das eine nahtlose Interaktion mit Remote -Servern und REST -APIs ermöglicht. Durch die Nutzung von Libcurl, einer angesehenen Bibliothek mit Multi-Protokoll-Dateien, erleichtert PHP Curl effiziente Execu

12 Beste PHP -Chat -Skripte auf Codecanyon 12 Beste PHP -Chat -Skripte auf Codecanyon Mar 13, 2025 pm 12:08 PM

Möchten Sie den dringlichsten Problemen Ihrer Kunden in Echtzeit und Sofortlösungen anbieten? Mit Live-Chat können Sie Echtzeitgespräche mit Kunden führen und ihre Probleme sofort lösen. Sie ermöglichen es Ihnen, Ihrem Brauch einen schnelleren Service zu bieten

Ankündigung von 2025 PHP Situation Survey Ankündigung von 2025 PHP Situation Survey Mar 03, 2025 pm 04:20 PM

Die 2025 PHP Landscape Survey untersucht die aktuellen PHP -Entwicklungstrends. Es untersucht Framework -Nutzung, Bereitstellungsmethoden und Herausforderungen, die darauf abzielen, Entwicklern und Unternehmen Einblicke zu geben. Die Umfrage erwartet das Wachstum der modernen PHP -Versio

See all articles