2019独角兽企业重金招聘Python工程师标准>>>
经常在centos下搭建 amp环境,记录一下过程。
以前受到一位”专家“级别同事的影响,编译安装的软件都指定目录,并且用普通用户安装,以为安全和方便。现在觉得默认的目录才是最好管理的,用root安装,不见得有什么问题。重要的是用什么用户运行。
1.apache httpd 2.4
需要下载 apr和apr-uti,libpcre编译安装
http://apr.apache.org/download.cgi
apr
默认就可以
./configure
apr-util
./configure --with-apr=/usr/local/apr
pcre
./configure
httpd
./configure --enable-so --enable-modules=all --with-apr=/usr/local/apr
查看编译参数/usr/local/apache2/build/config.nice
2.mysql 5.6
cmake .
依赖:ncurses-devel
编译过程十分漫长,需要耐心等待。
典型的配置 /etc/my.cnf
# For advice on how to change settings please see
#
[mysql]
socket=/var/lib/mysql/mysql.sock
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
datadir = /data/mysql
port = 3306
socket=/var/lib/mysql/mysql.sock
user=mysql
# server_id = .....
# socket = .....
log-error=/var/log/mysqld_error
pid-file=/var/run/mysql/mysqld.pid
character-set-server=utf8
default-storage-engine=INNODB
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
explicit_defaults_for_timestamp
[mysql]的配置是方便/usr/local/mysql/bin/mysql使用
当然也可以做个软链
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
初始化安装
groupadd server
useradd -g server -M -s /sbin/nologin mysql
cd /usr/local/mysql/
./scripts/mysql_install_db --defaults-file=/etc/my.cnf
mkdir /var/run/mysql/
chown mysql /var/run/mysql/
./support-files/mysql.server start
.设置密码
要先登录,把空用户删除
delete from user where user='';
再设置密码
mysqladmin -u root password
如果忘记了密码,可以在mysql.cnf添加
skip-grant-tables
3.php 5.6
enable了一些进程控制相关的扩展,用于 php cli。yii需要用pdo。写段小代码可能用到mysqli。
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-pdo-mysql=/usr/local/mysql/ --enable-mysqlnd --with-mysqli --enable-pcntl --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-gd --with-freetype-dir --with-png-dir --with-jpeg-dir --enable-zip --with-zlib --with-mcrypt --with-openssl
安装完后
cp php.ini-development /usr/local/lib/php.ini
http.conf增加
SetHandler application/x-httpd-php
参考 http://php.net/manual/en/install.unix.apache2.php