当前位置: 首页 > 工具软件 > lamp-boot > 使用案例 >

LAMP部署-基础

王成化
2023-12-01

mysql二进制 包 安装

[root@tyrr src]# useradd -s /sbin/nologin -M mysql
[root@tyrr src]# id mysql
uid=500(mysql) gid=500(mysql) 组=500(mysql)
[root@tyrr src]# mv mysql-5.1.73-linux-x86_64-glibc23 /usr/local/mysql
[root@tyrr src]# cd /usr/local/mysql/
[root@tyrr mysql]# ls
bin      data  include         lib  mysql-test  scripts  sql-bench
COPYING  docs  INSTALL-BINARY  man  README      share    support-files
[root@tyrr mysql]# mkdir -p /data/mysql
[root@tyrr mysql]# chown -R mysql /data/mysql/
[root@tyrr mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
WARNING: The host 'tyrr.com' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h tyrr.com password 'new-password'

Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

[root@tyrr mysql]# echo $?
0
[root@tyrr mysql]# ls /etc/my.cnf 
/etc/my.cnf
[root@tyrr mysql]# cd support-files/
[root@tyrr support-files]# cp my-large.cnf /etc/my.cnf 
cp:是否覆盖"/etc/my.cnf"? y
[root@tyrr support-files]# cp mysql.server /etc/init.d/mysqld
[root@tyrr support-files]# vim /etc/init.d/mysqld 
[root@tyrr support-files]# chkconfig --add mysqld
[root@tyrr support-files]# chkconfig mysqld on
[root@tyrr bin]# ./mysqladmin -u root password '19950801'
[root@tyrr ~]# /etc/init.d/mysqld restart
 ERROR! MySQL manager or server PID file could not be found!
Starting MySQL. SUCCESS! 

[root@tyrr bin]# ./mysql -u root -p19950801
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.73-log MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye

apache源码编译安装

[root@tyrr src]# wget http://mirrors.sohu.com/apache/httpd-2.2.32.tar.gz
--2017-03-04 02:31:08--  http://mirrors.sohu.com/apache/httpd-2.2.32.tar.gz
正在解析主机 mirrors.sohu.com... 221.236.12.140
正在连接 mirrors.sohu.com|221.236.12.140|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:7684420 (7.3M) [application/octet-stream]
正在保存至: “httpd-2.2.32.tar.gz”

100%[===================================================================================================================>] 7,684,420    698K/s   in 8.4s    

2017-03-04 02:31:17 (898 KB/s) - 已保存 “httpd-2.2.32.tar.gz” [7684420/7684420])

[root@tyrr src]# ls
httpd-2.2.32.tar.gz  httpd-2.4.25  httpd-2.4.25.tar.gz  mysql-5.1.73-linux-x86_64-glibc23.tar.gz
[root@tyrr src]# rm -fr httpd-2.4.25*
[root@tyrr src]# ls
httpd-2.2.32.tar.gz  mysql-5.1.73-linux-x86_64-glibc23.tar.gz
[root@tyrr src]# tar zxvf httpd-2.2.32.tar.gz 
httpd-2.2.32/
httpd-2.2.32/BuildAll.dsp
httpd-2.2.32/Apache.dsw
httpd-2.2.32/emacs-style
....

[root@tyrr src]# cd httpd-2.2.32
[root@tyrr httpd-2.2.32]# ./configure \
> --prefix=/usr/local/apache2 \
> --with-included-apr \
> --enable-so \
> --enable-deflate=shared \
> --enable-expires=shared \
> --enable-rewrite=shared \
> --with-pcre
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu

Configuring Apache Portable Runtime library ...
....


[root@tyrr httpd-2.2.32]# make
Making all in srclib
make[1]: Entering directory `/usr/local/src/httpd-2.2.32/srclib'
Making all in apr
make[2]: Entering directory `/usr/local/src/httpd-2.2.32/srclib/apr'
make[3]: Entering directory `/usr/local/src/httpd-2.2.32/srclib/apr'
/usr/local/src/httpd-2.2.32/srclib/apr/build/mkdir.sh tools
-o tools/gen_test_char.lo -c tools/gen_test_char.c && touch tools/gen_test_char.lo
o-install    -o tools/gen_test_char tools/gen_test_char.lo    -lrt -lcrypt  -lpthread
/usr/local/src/httpd-2.2.32/srclib/apr/build/mkdir.sh include/private
.....

[root@tyrr httpd-2.2.32]# make install
Making install in srclib
make[1]: Entering directory `/usr/local/src/httpd-2.2.32/srclib'
Making install in apr
make[2]: Entering directory `/usr/local/src/httpd-2.2.32/srclib/apr'
make[3]: Entering directory `/usr/local/src/httpd-2.2.32/srclib/apr'
make[3]: Nothing to be done for `local-all'.
make[3]: Leaving directory `/usr/local/src/httpd-2.2.32/srclib/apr'
/usr/local/src/httpd-2.2.32/srclib/apr/build/mkdir.sh /usr/local/apache2/lib /usr/local/apache2/bin /usr/local/apache2/build \
             /usr/local/apache2/lib/pkgconfig /usr/local/apache2/include
mkdir /usr/local/apache2
mkdir /usr/local/apache2/lib
....
[root@tyrr httpd-2.2.32]# cd /usr/local/
[root@tyrr local]# cd apache2/
[root@tyrr apache2]# cd bin/
[root@tyrr bin]# ./apachectl start
httpd: apr_sockaddr_info_get() failed for tyrr.com
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[root@tyrr bin]# vim /etc/hosts
[root@tyrr bin]# ./apachectl start
httpd: apr_sockaddr_info_get() failed for tyrr.com
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
httpd (pid 39420) already runnin

[root@tyrr bin]# /etc/init.d/iptables stop
iptables:将链设置为政策 ACCEPT:filter                    [确定]
iptables:清除防火墙规则:                                 [确定]
iptables:正在卸载模块:                                   [确定]

[root@tyrr bin]# ps aux |grep apache
root      39420  0.0  0.1  39708  1884 ?        Ss   02:47   0:00 /usr/local/apache2/bin/httpd -k start
daemon    39421  0.0  0.1  39708  1292 ?        S    02:47   0:00 /usr/local/apache2/bin/httpd -k start
daemon    39422  0.0  0.1  39708  1292 ?        S    02:47   0:00 /usr/local/apache2/bin/httpd -k start
daemon    39423  0.0  0.1  39708  1476 ?        S    02:47   0:00 /usr/local/apache2/bin/httpd -k start
daemon    39424  0.0  0.1  39708  1880 ?        S    02:47   0:00 /usr/local/apache2/bin/httpd -k start
daemon    39425  0.0  0.1  39708  1476 ?        S    02:47   0:00 /usr/local/apache2/bin/httpd -k start
daemon    39496  0.0  0.1  39708  1292 ?        S    02:50   0:00 /usr/local/apache2/bin/httpd -k start
root      39498  0.0  0.0 103324   888 pts/0    S+   02:51   0:00 grep apache

[root@tyrr bin]# ./apachectl -M
httpd: apr_sockaddr_info_get() failed for tyrr.com
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Loaded Modules:
 core_module (static)
 authn_file_module (static)
 authn_default_module (static)
 ...
Syntax OK

[root@tyrr bin]# ./apachectl -l
Compiled in modules:
  core.c
  mod_authn_file.c
  mod_authn_default.c
  mod_authz_host.c
  ...
[root@tyrr bin]# ./apachectl -t
httpd: apr_sockaddr_info_get() failed for tyrr.com
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Syntax OK
[root@tyrr bin]# ./apachectl restart
httpd: apr_sockaddr_info_get() failed for tyrr.com
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[root@tyrr bin]# cd ..
[root@tyrr apache2]# vim conf/httpd.conf 
[root@tyrr apache2]# ./bin/apachectl -t
Syntax OK
[root@tyrr apache2]# ./bin/apachectl restart
[root@tyrr apache2]# ./bin/apachectl graceful
[root@tyrr apache2]# ./bin/apachectl -l |grep pre
  prefork.c

源码编译安装php 5.4.36

[root@tyrr src]# wget http://mirrors.sohu.com/php/php-5.4.36.tar.gz
--2017-03-04 03:17:56--  http://mirrors.sohu.com/php/php-5.4.36.tar.gz
正在解析主机 mirrors.sohu.com... 221.236.12.140
正在连接 mirrors.sohu.com|221.236.12.140|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:14708270 (14M) [application/octet-stream]
正在保存至: “php-5.4.36.tar.gz”

100%[===================================================================================================================>] 14,708,270  1.11M/s   in 18s     

2017-03-04 03:18:14 (801 KB/s) - 已保存 “php-5.4.36.tar.gz” [14708270/14708270])

[root@tyrr src]# ls
httpd-2.2.32  httpd-2.2.32.tar.gz  mysql-5.1.73-linux-x86_64-glibc23.tar.gz  php-5.4.36.tar.gz
[root@tyrr src]# tar zxvf php-5.4.36.tar.gz 
php-5.4.36/
php-5.4.36/.gdbinit
php-5.4.36/.gitattributes
php-5.4.36/.gitignore
php-5.4.36/.travis.yml
...
在编译之前 
要解决软件依赖性:
[root@styrr ~]# yum install libxml2-devel net-snmp-devel curl-devel libpng-devel libjpeg-devel freetype-devel gmp-devel openldap-devel

[root@tyrr php-5.4.36]# ./configure \
> --prefix=/usr/local/lnmp/php \
> --with-config-file-path=/usr/local/lnmp/php/etc \
> --with-mysql=/usr/local/lnmp/mysql/ \
> --with-mysqli=/usr/local/lnmp/mysql/bin/mysql_config \
> --with-openssl --with-snmp --with-gd --with-zlib \
> --with-curl --with-libxml-dir --with-png-dir \
> --with-jpeg-dir --with-freetype-dir --without-pear \
> --with-gettext --with-gmp --enable-inline-optimization \
> --enable-soap --enable-ftp --enable-sockets --enable-mbstring \
> --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mhash

> --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mhash

thout-pear --with-gettext --with-gmp --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring \
> 
....
.....
Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
[root@tyrr php-5.4.36]# make
xt/curl/interface.c -o ext/curl/interface.lo 
/usr/local/src/php-5.4.36/ext/curl/interface.c: 在函数‘zif_curl_getinfo’中:
ruct curl_slist * for this info
ruct curl_slist * for this info
/usr/local/src/php-5.4.36/ext/curl/interface.c: 在函数‘_php_curl_setopt’中:
s option
.....
....
'
[root@tyrr php-5.4.36]# make install
Installing PHP CLI binary:        /usr/local/php/bin/
Installing PHP CLI man page:      /usr/local/php/php/man/man1/
Installing PHP FPM binary:        /usr/local/php/sbin/
Installing PHP FPM config:        /usr/local/php/etc/
Installing PHP FPM man page:      /usr/local/php/php/man/man8/
Installing PHP FPM status page:      /usr/local/php/php/fpm/
Installing PHP CGI binary:        /usr/local/php/bin/
Installing PHP CGI man page:      /usr/local/php/php/man/man1/
Installing build environment:     /usr/local/php/lib/php/build/
Installing header files:          /usr/local/php/include/php/
Installing helper programs:       /usr/local/php/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php/php/man/man1/
  page: phpize.1
  page: php-config.1
/usr/local/src/php-5.4.36/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f /usr/local/php/bin/phar.phar /usr/local/php/bin/phar
Installing PDO headers:          /usr/local/php/include/php/ext/pdo/

[root@tyrr php-5.4.36]# cp php.ini-production /usr/local/php/etc/php.ini
[root@tyrr php-5.4.36]# cp sapi/fpm/init.d.php-fpm /etc/init.d/fpm
[root@tyrr php-5.4.36]# chmod +x /etc/init.d/fpm
[root@tyrr php-5.4.36]# cd /usr/local/php/etc/
[root@tyrr etc]# ls
php-fpm.conf.default  php.ini
[root@tyrr etc]# cp php-fpm.conf.default php-fpm.conf
[root@tyrr etc]# vim php-fpm.conf
25 pid = run/php-fpm.pid
[root@tyrr etc]# vim php.ini
909 date.timezone = Asia/Shanghai
[root@tyrr etc]# /etc/init.d/fpm start
Starting php-fpm  done

在安装过程有 有一些包的依赖性要解决 整理成文档 为以上总结

 类似资料: