lamp

来源:互联网 发布:淘宝九块九专区在哪里 编辑:程序博客网 时间:2024/06/03 21:18

1 apache enable proxy

$ ./configure --prefix=PREFIX --enable-proxy
$ make
$ make install
$ PREFIX/bin/apachectl start


2 lamp

LAMP means Linux Apache Mysql Php

To install Mysql:sudo apt-get install mysql-server

At the installation you be will asked to provide a root password for Mysql.

To install php:sudo apt-get install php5 libapache2-mod-php5

After this installation restart Apache [sudo /etc /init.d/apache2 restart] don’t write brackets.

Now make a phpinfo.php file and save that in /var/www to do this use [sudo gedit /var/www/phpinfo.php] write a code in this file

<?phpphpinfo();?>

Now open http://127.0.0.1/phpinfo.php

To install phpmyadmin: sudo apt-get install phpmyadmin


3

/*** step 1 start ***/

We will need OpenSSL library: openssl-0.9.7e.tar.gz

Compilation of OpenSSL:

su

cd /usr/local/src

tar -zxvf openssl-0.9.7e.tar.gz

cd openssl-0.9.7e

./config --prefix=/usr/local

make

sudo make install

 

 

Create a private key and place it into directory /home/ssl:

sudo mkdir /home/ssl

cd /home/ssl

sudo /usr/bin/openssl genrsa -des3 -rand \ 

  some_big_file_1:some_big_file_2 \

  -out localhost.key 1024

Enter pass phrase for localhost.key:pass

Next, we will create a private key without a pass-phrase, this is less secure, but it allows us to bootup the server without manually entering the pass-phrase every time…

sudo /usr/bin/openssl rsa \

  -in localhost.key \

  -out localhost.key.unsecure

We will also create a request file that will be emailed to proper certification authority for getting a trusted SSL certificate (if needed) under file localhost.key.csr:

sudo /usr/bin/openssl req -new \

  -key localhost.key \

  -out localhost.key.csr

Coutry Name:

State:

Locality:

Organization:

Unit:

Common name:(yours)

Email:(yours)

Challenge:pass

optional company:

 

While waiting for the certification authority, we can create a temporary self-signed certificate, good for 30 days:

sudo /usr/bin/openssl x509 -req \

  -days 30 \

  -in localhost.key.csr \

  -signkey localhost.key \

  -out localhost.cert 

sudo chmod 400 localhost.cert

sudo chmod 400 localhost.key

sudo chmod 400 localhost.key.unsecure

after that, there's 4 files generated with prefix localhost

/*** step 1 end ***/

Compile MySQL 4.1.10 database from source:

 

MySQL 4.1.10 source codes - mysql-4.1.10.tar.gz

libtermcap library (most distros have it already) - libtermcap-2.0.8-35.i386.rpm

libtermcap-devel library (most distros have it already) - libtermcap-devel-2.0.8-35.i386.rpm

MySQL 4.1.10 has a completely different communication protocol and associated PHP mysqli functions. If your scripts were not designed for MySQL 4.1, you shall rather get MySQL release 4.0.23, to stay 100% compatible! Compilation options for MYSQL 4.0.23 will be the same, just remove one line with mysqli from PHP ./configure script.

However for any new development, MySQL 4.1.10 is recommended.

/*** step 2 start ***/

(refer to the guide of mysql)

sudo apt-get install cmake

# Preconfiguration setup

shell> sudo groupadd mysql

shell> sudo useradd -r -g mysql mysql

# Beginning of source-build specific instructions

shell> tar zxvf mysql-VERSION.tar.gz

shell> cd mysql-VERSION

shell> cmake .

shell> make

shell> sudo make install

# End of source-build specific instructions

# Postinstallation setup

Reinstall mysql, when run mysql_install_db, there's an error indicate:

 

FATAL ERROR: Could not find mysqld.

 

The solution is:

 

Since there's a my.cnf in /etc/mysql/ 

you'd

sudo mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak 

 

sudo cp support-files/my-medium.cnf /etc/my.cnf

 

shell> cd /usr/local/mysql

shell> sudo chown -R mysql .

shell> sudo chgrp -R mysql .

shell> sudo scripts/mysql_install_db --user=mysql

shell> sudo chown -R root .

shell> sudo chown -R mysql data

# Next command is optional

shell> sudo cp support-files/my-medium.cnf /etc/my.cnf

shell> sudo bin/mysqld_safe --user=mysql &

# Next command is optional

shell> sudo cp support-files/mysql.server /etc/init.d/mysql.server

 

/*** step 2 end ***/

 

Compiling MySQL from source, and creating user / group called mysql:

cd /usr/local/src

tar -zxvf mysql-4.1.10.tar.gz

cd mysql-4.1.10

./configure \

  --prefix=/usr/local/mysql \

  --with-unix-sock-path=/tmp/mysql.sock \

  --with-charset=utf8

make

make install

groupadd mysql

useradd -g mysql mysql

cp support-files/my-medium.cnf /etc/my.cnf

cd /usr/local/mysql

bin/mysql_install_db --user=mysql

chown -R root  .

chown -R mysql var

chgrp -R mysql .

MySQL configuration file /etc/my.cnf can (for our local testing) look like this:

[client]

port = 3306

socket = /tmp/mysql.sock

[mysqld]

port = 3306

socket = /tmp/mysql.sock

skip-locking

key_buffer = 16K

max_allowed_packet = 1M

table_cache = 4

sort_buffer_size = 64K

net_buffer_length = 2K

thread_stack = 64K

skip-networking

server-id = 1

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

[isamchk]

key_buffer = 8M

sort_buffer_size = 8M

[myisamchk]

key_buffer = 8M

sort_buffer_size = 8M

[mysqlhotcopy]

interactive-timeout

Compile from source Apache 2.0.53 web server:

 

Quite a few web-hosting companies still use Apache 1.3.x, but time of Apache 2.0 incompatibilities and problems is long gone, so 2.0 is a better choice now.

We will need Apache 2.0.53 source codes - httpd-2.0.53.tar.gz

RPM: libxml2 library (most distros have it already) - libxml2-devel-2.6.7-28.i586.rpm

RPM: zlib library (most distros have it already) - zlib-devel-1.2.1-70.i586.rpm

RPM: readline-devel library (most distros have it already) - readline-devel-4.3-306.i586.rpm

/*** step 3 start ***/

And compile it:

cd /usr/local/src

tar -zxvf httpd-2.0.53.tar.gz

cd httpd-2.0.53

./configure \

   --prefix=/usr/local/apache2 \

   --enable-so \

   --enable-auth-digest \

   --enable-rewrite \

   --enable-setenvif \

   --enable-mime \

   --enable-deflate \

   --enable-ssl \

   --with-ssl=/usr/local \

   --enable-headers \

   --enable-proxy

make

sudo make install

And we well add support for PHP 5 (as a module):

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php .php

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

We also have to allow / create basic mod_rewrite rules:

<Directory "/home/www">

 Options Indexes Includes FollowSymLinks MultiViews

 AllowOverride All

 Order allow,deny

 Allow from all

</Directory>

And dissalow clients to access .htaccess:

<Files ~ "^.ht">

   Order allow,deny

   Deny from all

</Files>

Next, if using SSL (on standard port 443), we will have to modify file /usr/local/apache2/conf/ssl.conf as follows (just replace the file content with this):

Listen 443

<VirtualHost _default_:443>

 ServerName localhost

 SSLEngine on

 SSLCertificateFile /home/ssl/localhost.cert

 SSLCertificateKeyFile /home/ssl/localhost.key.unsecure

</VirtualHost>

/*** step 3 end ***/

/*** step 4 start ***/

Compile from source PHP 5.0.3:

 

For compiling PHP, we will need quite a few external libraries, like libcurl, libiconv, libjpeg, libpng, and few others, which we have to download and compile first:

PHP 5.0.3 itself - php-5.0.3.tar.bz2

CURL library - curl-7.12.1.tar.gz

libiconv library - libiconv-1.9.2.tar.gz

JPEG library: jpegsrc.v6b.tar.gz

PNG library: libpng-1.2.8.tar.gz

cpdflib library: clibpdf202r1.tar.gz

Freetype 2 library: freetype-2.1.9.tar.bz2

/*** 4.1 ***/

Compile libiconv from source:

cd /usr/local/src

tar -zxvf libiconv-1.9.2.tar.gz

cd libiconv-1.9.2

./configure --prefix=/usr/local

make

sudo make install

/*** 4.2 ***/

Compile libjpeg from source:

cd /usr/local/src

tar -zxvf jpegsrc.v6b.tar.gz

cd jpeg-6b

./configure --prefix=/usr/local

make

sudo make install

sudo make install-lib

/*** 4.3 ***/

Compile libpng from source:

cd /usr/local/src

tar -zxvf libpng-1.2.8.tar.gz

cd libpng-1.2.8

./configure

make

sudo make install

/*** 4.4 ***/

Compile cpdflib from source:

cd /usr/local/src

tar -zxvf clibpdf202r1.tar.gz

cd ClibPDF/source

cp Makefile.Linux makefile

make

sudo make install

/*** 4.5 ***/

Compile curl from source:

cd /usr/local/src

tar -zxvf curl-7.12.1.tar.gz

cd curl-7.12.1

./configure --prefix=/usr/local

make

sudo make install

/*** 4.6 ***/

Compile freetype 2 from source:

cd /usr/local/src

tar -jxvf freetype-2.1.9.tar.bz2

cd freetype-2.1.9

./configure --prefix=/usr/local

make

sudo make install

/*** 4.7 ***/

Next, we will compile PHP, with support for MySQL, iconv, curl, zlib, gd2, mbstring, SSL and many other modules:

cd /usr/local/src

tar -jxvf php-5.0.3.tar.bz2

cd php-5.0.3

./configure \

  --with-apxs2=/usr/local/apache2/bin/apxs \

  --with-mysql=/usr/local/mysql  \

  --with-mysqli=/usr/local/mysql/bin/mysql_config  \

  --with-mysql-sock=/tmp/mysql.sock \

  --with-sqlite \

  --enable-sqlite-utf8 \

  --with-zlib \

  --with-zlib-dir \

  --with-bz2 \

  --with-gd \

  --enable-gd-native-ttf \

  --with-jpeg-dir=/usr/local \

  --with-png-dir=/usr/local \

  --with-freetype-dir=/usr/local \

  --with-iconv=/usr/local \

  --with-curl=/usr/local \

  --with-gettext \

  --with-config-file-path=/usr/local/apache2/conf \

  --enable-ftp \

  --enable-mbstring 

make

sudo make install

sudo cp php.ini-production /usr/local/apache2/conf/php.ini

/*** step 4 end ***/

How to start Apache and MySQL at bootup?

/*** step 5 start ***/

sudo /usr/local/mysql/support-files/mysql.server start

sudo /usr/local/apache2/bin/apachectl start

 

/*** step 5 end ***/



err mysql server has gone away



OS:win7

mysql:5.1

使用navicat时候,出现这个错误。

根据

http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_wait_timeout

查看了默认时间(my.ini)中,发现

Command-Line Format--wait_timeout=#System VariableNamewait_timeoutVariable ScopeGlobal, SessionDynamic VariableYesPermitted Values (Windows)TypeintegerDefault28800Min Value1Max Value2147483Permitted Values (Other)TypeintegerDefault28800Min Value1Max Value31536000


当前不应该超时,这个应该是mysql5.1的bug

在my.ini中增加

wait_timeout=80000

单位是秒

0 0