L===Linux
A===Apache
M===MySQL
P===php
apache解压
[root@server ~]# tar -zxvf httpd-2.4.38.tar.gz -C /usr/local/src/
[root@server ~]# cd /usr/local/src/httpd-2.4.38/
编译apache
[root@server httpd-2.4.38]# ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-ssl
[root@server httpd-2.4.38]# make && make install
[root@server httpd-2.4.38]# ll /usr/local/apache2/
总用量 44
drwxr-xr-x 2 root root 4096 7月 21 09:59 bin
drwxr-xr-x 2 root root 4096 7月 21 09:59 build
drwxr-xr-x 2 root root 74 7月 21 09:59 cgi-bin
drwxr-xr-x 4 root root 79 7月 21 09:59 conf
drwxr-xr-x 3 root root 4096 7月 21 09:59 error
drwxr-sr-x 2 root root 23 1月 18 2019 htdocs
drwxr-xr-x 3 root root 8192 7月 21 09:59 icons
drwxr-xr-x 2 root root 4096 7月 21 09:59 include
drwxr-xr-x 2 root root 6 7月 21 09:59 logs
drwxr-xr-x 4 root root 28 7月 21 09:59 man
drwxr-sr-x 14 root root 8192 1月 18 2019 manual
drwxr-xr-x 2 root root 4096 7月 21 09:59 modules
apachectl启动服务
[root@server apache2]# bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.220.138. Set the 'ServerName' directive globally to suppress this message
出现这样的错误,修改下配置文件的ServerName即可
[root@server apache2]# vim /usr/local/apache2/conf/httpd.conf
添加一行ServerName IP:端口
ServerName 192.168.220.138:80
[root@server apache2]# bin/apachectl start
httpd (pid 110345) already running
[root@server apache2]# curl 192.168.220.138
<html><body><h1>It works!</h1></body></html>
#这里可以看到源码编译安装apache的运行身份是daemon
[root@server apache2]# ps aux | grep apach
root 110345 0.0 0.1 74940 2408 ? Ss 10:09 0:00 /usr/local/apache2/bin/httpd -k start
daemon 110346 0.0 0.2 494976 4944 ? Sl 10:09 0:00 /usr/local/apache2/bin/httpd -k start
daemon 110347 0.0 0.2 494976 4944 ? Sl 10:09 0:00 /usr/local/apache2/bin/httpd -k start
daemon 110348 0.0 0.2 494976 4948 ? Sl 10:09 0:00 /usr/local/apache2/bin/httpd -k start
root 110963 0.0 0.0 112728 976 pts/0 S+ 10:17 0:00 grep --color=auto apach
[root@server apache2]# id daemon
uid=2(daemon) gid=2(daemon) 组=2(daemon)
MySQL安装
[root@server ~]# tar -zxvf mysql-5.5.30.tar.gz -C /usr/local/src/
[root@server ~]# cd /usr/local/src/mysql-5.5.30/
[root@server mysql-5.5.30]# ls
BUILD configure.cmake libmysqld scripts VERSION
BUILD-CMAKE COPYING libservices sql VERSION.dep
client dbug man sql-bench vio
cmake Docs mysql-test sql-common win
CMakeCache.txt extra mysys storage zlib
CMakeFiles include packaging strings
CMakeLists.txt INSTALL-SOURCE plugin support-files
cmd-line-utils INSTALL-WIN-SOURCE README tests
config.h.cmake libmysql regex unittest
[root@server ~]# mkdir /server
#mysql5.5之后开始使用cmake进行安装
[root@server mysql-5.5.30]# cmake \
> -DCMAKE_INSTALL_PREFIX=/server/mysql-5.5 \ 指定安装目录
> -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ mysql服务器用于监听的套接字
> -DDEFAULT_CHARSET=utf8 \ mysql默认字符集
> -DDEFAULT_COLLATION=utf8_general_ci \ 默认字符校对
> -DWITH_EXTRA_CHARSETS=all \ mysql扩展支持字符集
> -DWITH_MYISAM_STORAGE_ENGINE=1 \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_MEMORY_STORAGE_ENGINE=1 \ 编译三种存储引擎:myisam innodb memory
> -DWITH_READLINE=1 \ 支持readline库
> -DENABLED_LOCAL_INFILE=1 \ 允许从本地导入文件
> -DMYSQL_DATADIR=/server/mysql/data \ 数据存放目录
> -DMYSQL_USER=mysql 运行mysql的用户
参数参考
https://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html
[root@server mysql-5.5.30]# make && make install
[root@server ~]# useradd -s /sbin/nologin mysql
[root@server ~]# chown -R mysql:mysql /server/mysql-5.5/
#复制一份配置
[root@server ~]# cp /usr/local/src/mysql-5.5.30/support-files/my-large.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
[root@server ~]# cp /usr/local/src/mysql-5.5.30/support-files/mysql.server /etc/init.d/mysqld
[root@server ~]# chmod +x !$
chmod +x /etc/init.d/mysqld
[root@server ~]# vim /etc/init.d/mysqld
46 basedir=/server/mysql-5.5/
47 datadir=/server/mysql-5.5/data/
[root@server ~]# chmod +x /usr/local/src/mysql-5.5.30/scripts/mysql_install_db
[root@server ~]# /usr/local/src/mysql-5.5.30/scripts/mysql_install_db
[root@server ~]# cd /usr/local/src/mysql-5.5.30/scripts/
[root@server scripts]# ./mysql_install_db --defaults-file=/etc/my.cnf --basedir=/server/mysql-5.5 --datadir=/server/mysql-5.5/data/ --user=mysql
[root@server scripts]# /etc/init.d/mysqld start
Starting MySQL... SUCCESS!
[root@server bin]# /server/mysql-5.5/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.30-log Source distribution
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>
[root@server bin]# echo 'PATH=$PATH:/server/mysql-5.5/bin/' >> /etc/profile
[root@server bin]# source /etc/profile
设置密码
[root@server bin]# mysqladmin -uroot password '密码'
cmake是一个跨平台的安装(编译)工具,可以用简单的语句来描述所有平台的安装(编译过程)。它能够输出各种各样的makefile或者project文件。
PHP安装
[root@server src]# tar xvf php-7.3.8.tar.bz2 -C /usr/local/src
[root@server ~]# cd !$
cd /usr/local/src/
[root@server src]# cd php-7.3.8/
[root@server php-7.3.8]# ./configure \
--prefix=/server/php-7.3 \
--with-mysqli
--with-apxs2=/usr/local/apache2/bin/apxs \ apache的apxs工具将php编译成apache的一个模块
--with-config-file-path=/server/php-7.3
[root@server php-7.3.8]# make && make install
[root@server php-7.3.8]# cp /usr/local/src/php-7.3.8/php.ini-production /server/php-7.3/php.ini
查询之前的安装配置信息
[root@server php-7.3.8]# /server/php-7.3/bin/php -i | grep configure
Configure Command => './configure' '--prefix=/server/php-7.3' '--with-mysqli' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-config-file-path=/server/php-7.3
[root@server php-7.3.8]# vim /usr/local/apache2/conf/httpd.conf
修该如下内容
256 <IfModule dir_module>
257 DirectoryIndex index.html index.php
258 </IfModule>
添加
395 AddType application/x-httpd-php .php