Linux装配—15.LAMP

安装过程

- 安装依赖

- 安装mysql

- 安装apache

- 安装php

 

安装依赖

- 安装依赖就是安装包组以及特殊依赖包
| Development Tools
| Desktop
| Desktop Platform
| Desktop Platform Development

- 安装
| [root@wg ~]# yum -y groupinstall "Development Tools"
| [root@wg ~]# yum -y install pcre-devel openssl-devel 

 

安装MySQL

¤ 为省事mysql用的tar包安装,apache用的编译安装 ¤ 

[root@wg opt]# tar xvf 5.7.35-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@wg local]# ln -sv mysql-5.7.35-linux-glibc2.12-x86_64/ mysql
[root@wg local]# mkdir -p /data/mysql/3306/{data,log,tmp,mysqld}
[root@wg local]# useradd -r -s /sbin/nologin mysql
[root@wg local]# chown -R mysql:mysql mysql/ /data/mysql/ 
[root@wg local]# chmod -R 755 mysql/ /data/mysql/
[root@wg local]# vi /etc/my.cnf
| [mysqld]
| symbolic-links=0                     
| datadir=/data/mysql/3306/data
| socket=/data/mysql/3306/tmp/mysql.sock
| log-error=/data/mysql/3306/log/mysqld.log
| pid-file=/data/mysql/3306/mysqld/mysqld.pid
|
| [client]
| socket=/data/mysql/3306/tmp/mysql.sock
|
| # 复制后,别忘了用:set list清理下特殊标记
[root@wg local]# reboot

[root@wg local]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/data/mysql/3306/data
[root@wg local]# grep "temporary password" /data/mysql/3306/log/mysqld.log
20... password is generated for root@localhost: =yaa,UXW?7R)

[root@wg local]# vi /usr/lib/systemd/system/mysqld.service
| [Unit]
| Description=MySQL Server	   // 服务描述或名称
| Documentation=man:mysqld(8)      // 帮助文档,下同
| Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
| After=network.target	           // 启动顺序,在network之后
| After=syslog.target	        
| 
| [Install]
| WantedBy=multi-user.target	   // 开机启动功能	
| 
| [Service]
| User=mysql		           // 用户
| Group=mysql			   // 用户组
| Type=forking                     // ExecStart产生子进程成为服务的主进程。启动完后父进程退出。
| PIDFile=/data/mysql/3306/mysqld/mysqld.pid	// pid文件
| # Disable service start and stop timeout logic of systemd for mysqld service.
| TimeoutSec=0
| # Execute pre and post scripts as root
| PermissionsStartOnly=true
| # Needed to create system tables
| ExecStartPre=/usr/local/mysql/bin/mysqld_pre_systemd
| # Start main service
| ExecStart=/usr/local/mysql/bin/mysqld --daemonize --pid-file=/data/mysql/3306/mysqld/mysqld.pid $MYSQLD_OPTS
| # Use this to switch malloc implementation
| EnvironmentFile=-/etc/sysconfig/mysql
| # Sets open_files_limit
| LimitNOFILE = 5000
| Restart=on-failure
| RestartPreventExitStatus=1
| PrivateTmp=false
|
| # 大部分无卵用,图省事全复制了。同样,别忘了用:set list清理下特殊标记
| # EnvironmentFile这里有遗留问题

[root@wg ~]# systemctl daemon-reload
[root@wg ~]# systemctl start mysqld
[root@wg ~]# systemctl enable mysqld

[root@wg ~]# echo 'export PATH=$PATH:/usr/local/mysql/bin/' > /etc/profile.d/mysql.sh
[root@wg ~]# source /etc/profile.d/mysql.sh
[root@wg ~]# grep 'temporary password' /data/mysql/3306/log/mysqld.log
2020....password is generated for root@localhost: 3adC1f<)pe#x

[root@wg ~]# mysql -uroot -p'3adC1f<)pe#x'
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '12345';
mysql> exit
[root@wg ~]# mysql -uroot -p12345
mysql> grant all privileges on *.* to 'root'@'%' identified by '12345' with grant option;
mysql> flush privileges; 
mysql> exit

[root@wg ~]# ln -sv /usr/local/mysql/include/ /usr/include/mysql
[root@wg ~]# echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql57.conf
[root@wg ~]# ldconfig
[root@wg ~]# vi /etc/man_db.conf     // 麻批,帮助文档跟6比都变了...
| MANDATORY_MANPATH    /usr/local/mysql/man

 

安装Apache

[root@wg opt]# tar xvf httpd-2.2.29.tar
[root@wg opt]# tar xvf apr-util-1.6.1.tar
[root@wg opt]# tar xvf apr-1.7.0.tar
[root@wg opt]# cp -r apr-1.7.0 httpd-2.2.29/srclib/apr
[root@wg opt]# cp -r apr-util-1.6.1 httpd-2.2.29/srclib/apr-util
[root@wg httpd-2.2.29]# ./configure --prefix=/usr/local/apache2 --sysconfdir=/etc \
                      > --enable-so -enable-ssl -enable-cgi --enable-rewrite \
                      > --enable-modules=all --enable-mpms-shared=all --with-mpm=event \
                      > --with-zlib --with-pcre --with-apr=/opt/httpd-2.2.29/srclib/apr \
                      > --with-apr-util=/opt/httpd-2.2.29/srclib/apr-util --with-included-apr

[root@wg httpd-2.2.29]# make && make install
[root@wg bin]# /usr/local/apache2/bin/apachectl start
AH00558: httpd: Could not reliably determine ...

[root@wg bin]# vi /etc/httpd.conf
| ServerName localhost:80

[root@wg bin]# /usr/local/apache2/bin/apachectl start
httpd (pid 56264) already running

[root@wg bin]# systemctl status httpd
Unit httpd.service could not be found.

[root@wg ~]# vi /usr/lib/systemd/system/httpd.service
| [Unit]
| Description=Start httpd
| 
| [Service]
| Type=simple
| EnvironmentFile=/etc/httpd.conf
| ExecStart=/usr/local/apache2/bin/httpd -k start -DFOREGROUND
| ExecReload=/usr/local/apache2/bin/httpd -k graceful
| ExecStop=/bin/kill -WINCH ${MAINPID}
| 
| [Install]
| WantedBy=multi-user.target

[root@wg httpd-2.2.29]# cd /etc/profile.d
[root@wg]# vi http.sh
| export PATH=$PATH:/usr/local/apache2/bin

[root@wg profile.d]# source /etc/profile
[root@wg profile.d]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/apache2/bin

[root@wg profile.d]# apachectl stop
[root@wg profile.d]# apachectl start
[root@wg ~]# ln -sv /usr/local/apache2/include /usr/include/httpd
"/usr/include/httpd" -> "/usr/local/apache2/include"

[root@wg ~]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf

[root@wg ~]# echo "/usr/local/apache2/lib" >> /etc/ld.so.conf.d/http_lib.conf
# http.conf是主配置文件,给库配置文件命名为http_lib.conf

[root@wg ~]# ldconfig -v 
/usr/local/apache2/lib:
        libaprutil-1.so.0 -> libaprutil-1.so.0.6.1
        libapr-1.so.0 -> libapr-1.so.0.7.0

[root@wg /]# vi man_db.conf     // centos6是man.config
| MANDATORY_MANPATH   /usr/local/apache2/man

[root@wg ~]# systemctl daemon-reload
[root@wg ~]# systemctl restart httpd

 

安装PHP

上一篇:D5:Grocery Problem(杂货问题,附题解)


下一篇:Golang sync.WaitGroup 源码分析