linux 基础学习编译安装php+mysql+python3+memcached+radis+rabbitmq+libevent+tcl+gcc+erlang
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 基础学习编译安装php+mysql+python3+memcached+radis+rabbitmq+libevent+tcl+gcc+erlang相关的知识,希望对你有一定的参考价值。
CentOS 6.9 编译安装 Nginx+PHP+MYSQL
0x01 环境约束
源码位置 /home/[用户文件夹]
源码编译安装位置 /usr/local/[软件名]
CentOS6.9 x86 - 64 最小化安装 配置好网络 用户 使用Xshell登录
0x02 软件下载
内网地址:
http://192.168.20.252/src/php.tar.gz
http://192.168.20.252/src/cmake.tar.gz
http://192.168.20.252/src/libmcrypt.tar.gz
http://192.168.20.252/src/mysql.tar.gz
http://192.168.20.252/src/nginx.tar.gz
http://192.168.20.252/src/pcre.tar.gz
0x03 安装前的准备
使用用户登录主机
su #将当前用户提升至root权限
yum update -y # 安装当前操作系统的最新补丁,确保系统是最新的
#以下是安装依赖组件,编译工具,库文件
yum install -y make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libg
omp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel libXpm* freetype lib libpng libpng-devel libxml2-devel wget screen cyrus-sasl-devel.x86_64
0x04 安装cmake
tar zxvf cmake.tar.gz
cd cmake-[tab]
./configure && make && make install
0x05 安装MySQL
groupadd mysql #添加mysql用户组
useradd -s /sbin/nologin -g mysql -r mysql #创建用户 mysql 并加入到mysql用户组 ,不允许mysql用户直接登录系统
mkdir -p /data/mysql #创建MySQL数据库文件存放目录
chown -R mysql:mysql /data/mysql #设置权限
tar zxvf mysql.tar.gz
cd mysql-
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql/ -DSYSCONFDIR=/etc #编译器编译前配置检查
make && make install #编译和安装
cd /usr/local/mysql
cp ./support-files/my-default.cnf /etc/my.cnf #拷贝配置文件
vi /etc/my.cnf #编辑配置文件 在[mysqld]部分添加
datadir = /data/mysql #添加mysql数据库路径
./scripts/mysql_install_db --user=mysql #生成mysql系统数据库
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #把mysql加入到系统服务
chmod 755 /etc/init.d/mysqld #增加执行权限
chkconfig mysqld on #开机启动该服务
vi /etc/rc.d/init.d/mysqld #编辑服务启动脚本
basedir = /usr/local/mysql
datadir = /data/mysql
service mysqld start #启动mysql服务
vi /etc/profile #编辑系统环境变量 在末尾增加如下环境变量
export PATH = $PATH:/usr/local/mysql/bin
source /etc/profile #系统环境变量生效
#下面把mysql的库文件添加到系统的默认位置中,这样在编译php的时候,不用制定mysql的库文件地址
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
reboot #第一次重启
mysql_secure_installation #设置MySQL的 root用户密码
service mysqld restart #重启mysql服务
0x06 安装PCRE
tar zxvf pcre.tar.gz
cd pcre-
./configure --prefix=/usr/local/pcre && make && make install
0x07 安装nginx
groupadd www
useradd -s /sbin/nologin -g www -r www
tar zxvf nginx.tar.gz
cd nginx-
./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-openssl=/usr/ --with-pcre=/home/jue/pcre-8.41/
make && make install
vi /etc/init.d/nginx
[复制nginx启动脚本]
chmod 775 /etc/rc.d/init.d/nginx #设置运行权限
chkconfig nginx on
/etc/rc.d/init.d/nginx restart #重启nginx 只是为了测试
service nginx restart #重启nginx服务
0x08 安装 libmcrypt
tar zxvf libmcrypt.tar.gz
cd libmcrypt-
./configure && make && make install
0x09 安装php
tar zxvf php.tar.gz
cd php-
mkdir -p /usr/local/php
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-pear --with-gettext --enable-session --with-mcrypt --with-curl
make && make install
cp php.ini-production /usr/local/php/etc/php.ini
rm -rf /etc/php.ini
ln -s /usr/local/php/etc/php.ini /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
vi /usr/local/php/etc/php-fpm.conf #在这个文件中设置 3项
user = www
group = www
pid = run/php-fpm.pid #去掉了前面的分号
cp /home/feng/php-5.6.31/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod 755 /etc/rc.d/init.d/php-fpm
chkconfig php-fpm on
vi /etc/php.ini
data.timezone = RPC #设置时区
0x10 配置nginx支持php
mkdir -p /home/wwwroot
chown -R www:www /home/wwwroot
vi /usr/local/nginx/conf/nginx.conf
user www www;
root /home/wwwroot #web根目录
index index.php index.html index.htm; #添加index.php
location ~ \.php$ {
root /home/wwwroot;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
/etc/init.d/nginx restart
0x11 测试
cd /home/wwwroot
vi index.php
<?php phpinfo();?>
chown -R www:www /home/wwwroot
curl http://127.0.0.1/
curl http://localhost/
配置python3
# wget http://192.168.40.66/python3.tar.gz
tar -zxvf python3.tar.gz
cd Python-3.6.2/
./configure --prefix=/usr/local/python3 && make && make install
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
cd /home/ht
配置libevent 与 memcached
99 wget http://192.168.100.252/src/libevent.tar.gz
100 wget http://192.168.100.252/src/memcached.tar.gz
102 tar -zxvf libevent.tar.gz
103 cd libevent-2.1.8-stable/
104 ./configure --prefix=/usr/local/libevent
105 make && make install
106 cd ..
108 tar -zxvf memcached.tar.gz
109 cd memcached-1.5.0/
111 ./configure --prefix=/usr/local/memcached --enable-sasl --with-libevent=/usr/local/libevent && make && make install
cd /usr/local/python3/bin
./pip3.6 install python3-memcached
配置gcc
209 wget http://192.168.100.252/src/gcc.tar.gz
210 tar -zxvf gcc.tar.gz
211 mkdir gccmake
213 cd gcc-4.9.4/
214 vi ./contrib/download_prerequisites
wget http://192.168.100.252/src/gcc/$MPFR.tar.bz2 || exit 1 (配置文件,改URL)
215 ./contrib/download_prerequisites
216 cd ..
220 cd gccmake
221 ../gcc-4.9.4/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
223 make && make install
配置redis
cd /home/ht
224 wget http://192.168.100.252/src/tcl.tar.gz
225 wget http://192.168.100.252/src/redis.tar.gz
232 tar -zxvf tcl.tar.gz
234 cd tcl8.6.6/
236 cd /home/ht
237 rm -rf /usr/lib64/libstdc
239 cp /home/ht/soft/gccmake/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so /usr/lib64/libstdc++.so.
240 rm -rf /usr/lib64/libstdc++.so.6
241 ln -sv /usr/lib64/libstdc++.so /usr/lib64/libstdc++.so.6
242 gcc -v
243 cd /home/ht
246 cd tcl8.6.6/
247 cd unix
./configure
252 make install && make install-private-headers
253 cd ..
255 tar -zxvf redis.tar.gz
257 cd redis-3.2.10/
258 make PREFIX=/usr/local/redis install
259 cd /usr/local/redis/
260 mkdir conf
261 cd /home/jue/
263 cd redis-3.2.10/
265 cp redis.conf /usr/local/redis/conf
266 cd ..
268 ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
269 ln -s /usr/local/mysql/include/mysql /usr/include/mysql
288 ./pip3.6 install python-redis (在 /usr/local/python3/bin 下)
配置erlang
394 cd /home/ht
395 ls
396 mkdir rabbit
cd rabbit
399 wget http://192.168.100.252/src/rabbitmq.tar.xz
400 wget http://192.168.100.252/src/otp.tar.gz
401 yum install kernel-devel m4 ncurses-devel openssl-devel
408 tar -zxvf otp.tar.gz
411 cd otp_src_20.0/
412 ./configure --prefix=/usr/local/erlang --with-ssl --enable-threads --enable-smmp-support --enable-kernel-poll --enable-hipe --without-javac
416 make && make install
配置rabbit
450 cd /usr/bin
452 rm -rf python python2
453 ll python*
455 vim yum
470 cd /usr/bin
471 ln -sv /usr/local/python3/bin/python3.6 /usr/bin/python
484 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo ( 视察情况)(yum源)
485 yum makecache(yum缓存)
525 vi /etc/profile
526 source /etc/profile
cd rabbit
442 tar -xvf rabbitmq.tar.xz
534 cd rabbitmq-server-3.6.10/
537 yum install zip rsync libxslt -y
538 make PREFIX=/usr/local/rabbitmq install
make && make install
539 cd /usr/local/python3/bin
541 ./pip3.6 install simplejson
以上是关于linux 基础学习编译安装php+mysql+python3+memcached+radis+rabbitmq+libevent+tcl+gcc+erlang的主要内容,如果未能解决你的问题,请参考以下文章