本文主要记载了通过编译方式进行软件/开发环境的安装过程,其他安装方式忽略!
文章背景:
因为php和Apache等采用编译安装方式进行安装,然而编译安装方式,需要c,c++编译环境,
通过apt方式安装build-essential $ sudo apt-get install build-essential
编译安装的步骤一般分为: 编译配置 $ ./configure --XXX(参数s)
编译配置的问题:
a、在没有安装之前,对软件无法全面了解 b、如果不全全面了解,又不知道该怎么安装(附带哪些参数)
c、可以先选择一个最简单的安装方式,随着使用,多次安装来解决这个问题 该过程比较复杂,需要很复杂的具体参数配置,具体参数通过 configure --help 查看 编译 $ make 安装 $ sudo make install
**************************************
Apache 安装
1、下载 httpd-2.2.11.tar.gz 2、解压
tar zxvf httpd-2.2.11.tar.gz 在执行tar指令的路径下,会产生一个httpd-2.2.11目录
3、查看一下编译的配置信息
切换到解压之后的httpd-2.2.11目录 ./configure --help 通过本步骤可以了解有那些可以安装的模块,以及安装配置信息需要设置 进一步查看手册,也可以了解相关信息
4、进行编译配置
$ ./configure --prefix=/usr/local/apache2 \ 指定安装目录 --enable-so \ 允许使用外部so模块
--with-mpm=prefork url请求跳转策略
5、编译: $ make
6、安装:(使用sudo是因为要安装的路径/usr/local/apache2不属于个人路径) $ sudo make install 《安装完毕》
7、测试 修改httpd.conf。 将 #ServerName www.example.com:80 修改为 ServerName 127.0.0.1:80(localhost:80) 启动 sudo ./apachectl -k start 停止 sudo ./apachectl -k stop 重新起动 sudo ./apachectl -k restart (该命令有时无效,用stop+start代替)
****************************************
PHP安装
1、下载php-5.2.8.tar.gz 2、解压tar zxvf php-5.2.8.tar.gz
3、查看一下编译的配置信息 切换到解压之后的httpd-2.2.11目录 ./configure --help 通过本步骤可以了解有那些可以安装的模块,以及安装配置信息需要设置 进一步查看手册,也可以了解相关信息
4、编译配置 ./configure --prefix=/home/guandl/webenv/php528 \ --enable-mbstring \
--with-apxs2=/usr/local/apache2/bin/apxs
5 编译 make
6、安装 sudo make install 《安装完毕》
7、复制php.ini
因为一般安装后的php目录$php/lib下没有php的配置文件,需要把解压目录下的php.ini-recommended复制到php的lib目录
sudo cp php.ini-recommended /home/guandl/webenv/php528/lib/php.ini
8、修改apache 的配置文件 httpd.conf 增加一下内容 LoadModule php5_module modules/libphp5.so 安装php时候已经自动生成 AddType application/x-httpd-php .php 9、测试
编写一个php文件,如any.php <?php phpinfo(); ?>
放到apache的htdocs目录下 重新启动apache http://127.0.0.1/any.php
。
从源代码包括以下步骤。
- 1安装缺少的依赖项
添加一个MySQL用户和组
下载的源代码
解包和安装
后安装过程
- 2日安装缺少的依赖项
安装检查
以下部分,建议查看。
确保MySQL服务器
http://howtolamp.com/lamp/mysql/5.6/installing/
安装Perl GD
在终端,执行以下命令。
# yum install perl-GD
OPTIONS EXPLAINED install
Is used to install the latest version of a package or group of packages while ensuring that all dependencies are satisfied. (See Specifying package names for more information) If no package matches the given package name(s), they are assumed to be a shell glob and any matches are then installed. If the name starts with an @ character the rest of the name is used as though passed to the groupinstall command. If the name starts with a - character, then a search is done within the transaction and any matches are removed. If the name is a file, then install works like localinstall. If the name doesn’t match a package, then package "provides" are searched (Eg. "_sqlitecache.so()(64bit)") as are filelists (Eg. "/usr/bin/yum"). Also note that for filelists, wildcards will match multiple packages.
[root@localhost ~]# yum install perl-GD Loaded plugins: fastestmirror, langpacks base | 3.6 kB 00:00 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 (1/4): extras/7/x86_64/primary_db | 54 kB 00:00 (2/4): base/7/x86_64/group_gz | 154 kB 00:00 (3/4): updates/7/x86_64/primary_db | 1.7 MB 00:01 (4/4): base/7/x86_64/primary_db | 5.1 MB 00:03 Loading mirror speeds from cached hostfile * base: mirrors.skyshe.cn * extras: mirrors.zju.edu.cn * updates: mirrors.pubyun.com Resolving Dependencies --> Running transaction check ---> Package perl-GD.x86_64 0:2.49-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: perl-GD x86_64 2.49-3.el7 base 173 k Transaction Summary ================================================================================ Install 1 Package Total download size: 173 k Installed size: 394 k Is this ok [y/d/N]: y Downloading packages: warning: /var/cache/yum/x86_64/7/base/packages/perl-GD-2.49-3.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Public key for perl-GD-2.49-3.el7.x86_64.rpm is not installed perl-GD-2.49-3.el7.x86_64.rpm | 173 kB 00:00 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Importing GPG key 0xF4A80EB5: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>" Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 Package : centos-release-7-1.1503.el7.centos.2.8.x86_64 (@anaconda) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : perl-GD-2.49-3.el7.x86_64 1/1 Verifying : perl-GD-2.49-3.el7.x86_64 1/1 Installed: perl-GD.x86_64 0:2.49-3.el7 Complete! [root@localhost ~]#
在终端,改变控股RPM文件的目录。 执行以下命令。
# rpm -ivh perl-GD-2.44-3.el6.i686.rpm
OPTIONS EXPLAINED
-i
This installs a new package.
-v
Print verbose information - normally routine progress messages will be displayed.
-h
Print 50 hash marks as the package archive is unpacked. Use with -v|--verbose for a nicer display.
# useradd -r -U mysql -M -d /usr/local/mysql/data
[root@localhost ~]# useradd -r -U mysql -M -d /usr/local/mysql/data [root@localhost ~]#
。 您可以使用一个不同的安装目录或数据存储,如果你的愿望。
OPTIONS EXPLAINED
-U
Create a group with the same name as the user and add the user to this group, in case USERGROUPS_ENAB in your /etc/login.defs is set to no. (By default this is set to yes).
-r
Create as system account
-M
Do not create the user´s home directory, in case CREATE_HOME in your /etc/login.defs is set to yes. (By default this is set to no). This is used because we do not want the files and directories contained in the skeleton directory to be copied to home directory.
-d
The new user will be created using HOME_DIR as the value for the user´s login directory. The default is to append the LOGIN name to BASE_DIR and use that as the login directory name. The directory HOME_DIR does not have to exist but will not be created if it is missing.
。
。 它可以从MySQL开发区域。
。 这将启动下载
在大小。
https://edelivery.oracle.com/EPD/Search/handle_go
| Download | MySQL Cluster 7.4.6 TAR for Generic Linux (glibc2.5) x86 (64bit) | V75610-01 | 481M |
基于单元测试。 如果你现在不下载这个,在配置过程中会显示以下错误。
Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
(即,假设你有一个活跃的网络连接),配置脚本将给你以下错误。
CMake Error: Problem with tar_extract_all(): Invalid argument CMake Error: Problem extracting tar: /usr/src/mysql-5.6.19/source_downloads/gmock-1.6.0.zip
。 为当前时间,我们必须解决这个。
在大小。
# cd /usr/src
。
# tar -zxvf mysql-5.6.19.tar.gz
OPTIONS EXPLAINED
-x
extract files from an archive
-v
verbosely list files processed
-z
filter the archive through gzip
-f
use archive file or device ARCHIVE
将gmock zip文件解压到指定的目录
# unzip gmock-1.6.0.zip -d mysql-5.6.19/source_downloads
OPTIONS EXPLAINED
-d
An optional directory to which to extract files. By default, all files and subdirectories are recreated in the current directory; the -d option allows extraction in an arbitrary directory (always assuming one has permission to write to the directory). This option need not appear at the end of the command line; it is also accepted before the zipfile specification (with the normal options), immediately after the zipfile specification, or between the file(s) and the -x option. The option and directory may be concatenated without any white space between them, but note that this may cause normal shell behavior to be suppressed. In particular, ‘‘-d ~’’ (tilde) is expanded by Unix C shells into the name of the user’s home directory, but ‘‘-d~’’ is treated as a literal subdirectory ‘‘~’’ of the current directory.
目录和提取特徵的zip文件。
提取的文件。 改变目录的终端。
# cd mysql-5.6.19
http://dev.mysql.com/doc/mysql-sourcebuild-excerpt/5.6/en/source-configuration-options.html
# cmake .
cmake会检查我们的系统所需的依赖项,分配值与系统相关的变量和使用这些值来生成Makefile。
执行。
# make
、编译我们的程序代码并创建可执行文件描述的顺序。
执行make install。
# make install
OPTIONS EXPLAINED
install
install will look for the target install in Makefile, and install MySQL Server to the specified location.
。
if ! echo ${PATH} | /bin/grep -q /usr/local/mysql/bin ; then
PATH=/usr/local/mysql/bin:${PATH}
fi
。
if ( "${path}" !~ */usr/local/mysql/bin* ) then
set path = ( /usr/local/mysql/bin $path )
endif
。 所以我在我目前的终端执行下面的命令。
# source /etc/profile.d/mysql.sh
。 但这些还没有共享。 其他应用程序在运行时发现这些库,动态链接器缓存在Linux中必须更新这些库的信息。
/usr/local/mysql/lib
# echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
ldconfig运行。
# ldconfig
ld.so.conf ldconfig扫描。 d文件夹并更新共享库缓存,以便在运行时动态链接器可以找到他们。
手册。 不需要额外的变化。
安装目录
# cd /usr/local/mysql
系统授权表。 我们将恢复权限。
# chown -R mysql:mysql .
OPTIONS EXPLAINED
-R
operate on files and directories recursively
用户。
# scripts/mysql_install_db --user=mysql
OPTIONS EXPLAINED
--user
The login username to use for running mysqld. Files and directories created by mysqld will be owned by this user. You must be root to use this option. By default mysqld runs using your current login name and files and directories that it creates will be owned by you.
根目录的内容。
# chown -R root .
OPTIONS EXPLAINED
-R
operate on files and directories recursively
。
# chown -R mysql data
OPTIONS EXPLAINED
-R
operate on files and directories recursively
。
将可以访问它。
# chmod -R go-rwx data
OPTIONS EXPLAINED
-R
operate on files and directories recursively
go-rwx
Remove read,write & execute permissions for group & others
。
# cp support-files/my-default.cnf /etc/my.cnf
。
部分添加一个新行,如下所示。
user = mysql
你的机器的IP地址。
bind-address = 192.168.0.100
注意:如果我们希望MySQL服务器绑定一组选定的接口,我们可以离开MySQL服务器的默认行为,与防火墙我们不想绑定的接口。
执行mysqld_safe mysql用户。
# mysqld_safe --user=mysql &
OPTIONS EXPLAINED
--user
Run the mysqld server as the user having the name user_name or the numeric user ID user_id. (“User” in this context refers to a system login account, not a MySQL user listed in the grant tables.)
或关闭终端,打开一个新的。
。
# cp -v support-files/mysql.server /etc/rc.d/init.d/mysql
OPTIONS EXPLAINED
-v
explain what is being done
作为一个系统V init服务。
# chkconfig --add mysql
OPTIONS EXPLAINED
--add
This option adds a new service for management by chkconfig. When a new service is added, chkconfig ensures that the service has either a start or a kill entry in every runlevel. If any runlevel is missing such an entry, chkconfig creates the appropriate entry as specified by the default values in the init script. Note that default entries in LSB-delimited ’INIT INFO’ sections take precedence over the default runlevels in the initscript; if any Required-Start or Required-Stop entries are present, the start and stop priorities of the script will be adjusted to account for these dependencies.
/etc/rc.d/rc6.d/K36mysql
服务将开始在运行级2、3、4和5。
服务。
# service mysql start
OPTIONS EXPLAINED
start
starts the specified service
/usr/local/mysql/data/example.com.pid
/ tmp / mysql.sock
/etc/rc.d/init.d/mysql
3306年
列出并解释了
列出并解释了
列出并解释了
显示MySQL服务的状态
# service mysql status
显示mysqld守护进程的状态
# mysqladmin -u root -p ping
显示服务器的状态变量
# mysqladmin -u root -p status
显示服务器的状态变量和它们的值
# mysqladmin -u root -p extended-status
显示活动服务器线程的列表
# mysqladmin -u root -p processlist
显示充满processlist活动服务器线程的列表
# mysqladmin -u root -p -v processlist
显示服务器系统变量和它们的值的列表
# mysqladmin -u root -p variables
获取服务器版本信息
# mysqladmin -u root -p version