准备工作
网络设置
相关教程:http://www.jianshu.com/p/e6ba699b5992
ifcfg-enp0s3配置
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s3
UUID=8a0822ab-f63d-4d41-a2b8-6512a299287a
DEVICE=enp0s3
ONBOOT=yes
ifcfg-enp0s8配置
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s8
UUID=4e67634f-a430-41a6-a8c9-1e65fb728e36
DEVICE=enp0s8
ONBOOT=yes
IPADDR=192.168.56.100
NETMASK=255.255.255.0
安装增强工具
启动虚拟机,点击“设备” => “安装增强功能”
运行以下命令
yum install kernel-devel gcc
安装完成后,做一个连接
ln -s /usr/src/kernels/3.10.0-514.el7.x86_64 /usr/src/linux
挂载光盘,安装
mount /dev/cdrom /mnt
cd /mnt
./VBoxLinuxAdditions.run
设置开机自动挂载(我没有做这一步)
vi /etc/rc.d/rc.local
在最后加上
mount -t vboxsf shared /mnt
建立相关目录
ln -s /media/sf_Project /data/www
mkdir -p /var/setup
mkdir -p /var/software
mkdir -p /data/www/logs/nginx
mkdir -p /data/www/logs/mysql
mkdir -p /data/www/logs/php
nginx
下载必要文件
cd /var/setup
wget http://nginx.org/download/nginx-1.11.10.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
wget http://zlib.net/zlib-1.2.11.tar.gz
wget http://www.canonware.com/download/jemalloc/jemalloc-4.2.1.tar.bz2
安装依赖
yum install zlib-devel openssl-devel -y
安装PCRE
cd /var/setup/
tar zvxf pcre-8.40.tar.gz
cd pcre-8.40/
./configure
make && make install
安装zlib
cd /var/setup/
tar zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install
安装jemalloc
cd /var/setup/
tar xjf jemalloc-4.2.1.tar.bz2
cd jemalloc-4.2.1/
./configure
make && make install
echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
ldconfig
配置
用户配置
groupadd www
useradd -g www www -s /sbin/nologin
chown -R www:www /data/www
添加用户组
usermod -a -G vboxsf www
usermod -a -G vboxsf nobody
关闭防火墙
systemctl stop firewalld.service
关闭开机启动
systemctl disable firewalld.service
安装nginx
cd /var/setup/
tar zxvf nginx-1.11.10.tar.gz
cd nginx-1.11.10/
./configure --prefix=/var/software/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/var/setup/openssl-1.1.0e --with-zlib=/var/setup/zlib-1.2.11 --with-pcre=/var/setup/pcre-8.40 --with-ld-opt="-ljemalloc"
make && make install
配置nginx
vim /var/software/nginx/conf/nginx.conf
修改前几行为:
user www www;
worker_processes auto;
error_log /data/www/logs/nginx/error.log crit;
pid /run/nginx.pid;
events{
use epoll;
worker_connections 65535;
}
找到,并修改 root 行的内容
location / {
root /data/www;
index index.html index.htm;
}
测试和运行
cd /var/software/nginx
ldconfig
/var/software/nginx/sbin/nginx -c /var/software/nginx/conf/nginx.conf -t
若显示以下信息,则表示配置是正常的
nginx: the configuration file /var/software/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /var/software/nginx/conf/nginx.conf test is successful
查看jemalloc是否生效,需要先启动nginx
/var/software/nginx/sbin/nginx -c /var/software/nginx/conf/nginx.conf
lsof -n | grep jemalloc
若显示以下信息,则表示jemalloc正常
nginx 21925 root mem REG 253,0 2531464 51238929 /usr/local/lib/libjemalloc.so.2
nginx 21926 www mem REG 253,0 2531464 51238929 /usr/local/lib/libjemalloc.so.2
nginx 21927 www mem REG 253,0 2531464 51238929 /usr/local/lib/libjemalloc.so.2
建立测试首页
touch /data/www/index.html
vim /data/www/index.html
输入以下内容
<html>
<head><title>nginx index.html</title></head>
<body>
<h1>index.html</h1>
</body>
</html>
浏览器打开,http://192.168.56.100,显示页面则代表正常
作为服务,开机后启动
vim /usr/lib/systemd/system/nginx.service
填入以下内容
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/var/software/nginx/sbin/nginx -c /var/software/nginx/conf/nginx.conf -t
ExecStart=/var/software/nginx/sbin/nginx -c /var/software/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
设置生效
systemctl enable nginx.service
systemctl list-unit-files | grep enabled | grep nginx
启动服务
/var/software/nginx/sbin/nginx -s stop
systemctl daemon-reload
systemctl start nginx.service
systemctl status nginx.service -l
ps -ef | grep nginx
lsof -n | grep jemalloc
常用命令
systemctl start|stop|reload|status nginx.service
安装MySQL
安装必要软件
yum –y install perl perl-devel perl-Module-Install.noarch libaio libaio-devel
下载源码
cd /var/setup
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.28-linux-glibc2.5-x86_64.tar.gz
tar zxvf mysql-5.6.28-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.28-linux-glibc2.5-x86_64 /var/software/mysql
创建用户
groupadd mysql
useradd -r -g mysql mysql
添加用户组
usermod -a -G vboxsf mysql
安装
cd /var/software/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql --basedir=/var/software/mysql --datadir=/var/software/mysql/data
修改配置
vim /var/software/mysql/my.cnf
找到,并修改为
[mysqld]
datadir=/var/software/mysql/data
[mysqld_safe]
log-error=/data/www/logs/mariadb.log
pid-file=/var/software/mysql/mariadb.pid
找到
socket=/var/lib/mysql/mysql.sock
修改为
socket=/tmp/mysql.sock
启动
./bin/mysqld_safe --user=mysql
设置账号密码
/var/software/mysql/bin/mysqladmin -u root password '123456'
/var/software/mysql/bin/mysqladmin -u root -p -h localhost.localdomain password '123456'
配置root账号权限
/var/software/mysql/bin/mysql -u root -p
执行以下命令。记住下面的123456是root的密码
CREATE USER 'root'@'%' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
启动配置
ln -s /var/software/mysql/support-files/mysql.server /etc/init.d/
vim /etc/init.d/mysql.server
找到 basedir, datadir, mysqld_pid_file_path,修改为
basedir=/var/software/mysql
datadir=/var/software/mysql/data
mysqld_pid_file_path=/var/software/mysql/mysql.pid
自启动
chkconfig mysql.server on
常用命令
/etc/init.d/mysql.server start|stop|restart|reload|status
安装memcached
安装
yum install libevent-devel
cd /var/setup/
wget http://www.memcached.org/files/memcached-1.4.35.tar.gz
tar zxvf memcached-1.4.35.tar.gz
cd memcached-1.4.35/
./configure
make && make install
开机自启动
vim /etc/init.d/memcached
输入以下内容
#!/bin/sh
#
# memcached: MemCached Daemon
#
# chkconfig: - 90 25
# description: MemCached Daemon
#
# Source function library.
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network
start()
{
echo -n $"Starting memcached: "
daemon /usr/local/bin/memcached -u daemon -d -m 4096 -l 127.0.0.1 -p 11211
echo
}
stop()
{
echo -n $"Shutting down memcached: "
killproc memcached
echo
}
[ -f /usr/local/bin/memcached ] || exit 0
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
;;
condrestart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|condrestart}"
exit 1
esac
exit 0
设置
chmod +x /etc/init.d/memcached
chkconfig --add memcached
chkconfig --level 235 memcached on
常用操作
/etc/rc.d/init.d/memcached start|stop|restart|reload|condrestart
注意
若memcached启动后仍无法连接,请修改/etc/init.d/memcached里面的host 和端口是否正确
安装PHP5.6
预安装
yum -y install make cmake automake autoconf kernel-devel ncurses-devel libxml2-devel curl-devel libjpeg-devel libpng-devel pcre-devel libtool-libs freetype-devel gd zlib-devel file bison patch mlocate flex diffutils readline-devel glibc-devel glib2-devel bzip2-devel gettext-devel libcap-devel libmcrypt-devel openldap openldap-devel libxslt-devel libldap libldap-devel epel-release php-mcrypt
安装
cd /var/setup
wget http://am1.php.net/distributions/php-5.6.30.tar.gz
tar zxvf php-5.6.30.tar.gz
cd php-5.6.30
./configure --prefix=/var/software/php/ --with-config-file-path=/var/software/php/etc/ --with-mysql=/var/software/mysql/ --with-mysqli=/var/software/mysql/bin/mysql_config --with-zlib --with-curl --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mbstring=all --with-openssl --with-gd --with-pdo-mysql=/var/software/mysql
make && make install
修改ini配置
cp php.ini-production /var/software/php/etc/php.ini
vim /var/software/php/etc/php.ini
找到error_log,并设置为
error_log=/data/www/logs/php/php_errors.log
找到date.timezone,并设置为
date.timezone = Asia/shanghai
加入扩展地址
extension_dir = "/var/software/php/lib/php/extensions/no-debug-non-zts-20131226"
修改fpm配置
cd /var/software/php
cp etc/php-fpm.conf.default etc/php-fpm.conf
vim etc/php-fpm.conf
找到error_log,并设置为
error_log = /data/www/logs/php/php-fpm.log
开机自启动
cp /var/setup/php-5.6.30/sapi/fpm/init.d.php-fpm /etc/init.d/php56-fpm
chmod +x /etc/init.d/php56-fpm
chkconfig php56-fpm on
安装memcache扩展
cd /var/setup/
wget https://pecl.php.net/get/memcache-2.2.7.tgz
tar zvxf memcache-2.2.7.tgz
cd memcache-2.2.7/
/var/software/php/bin/phpize
./configure --with-php-config=/var/software/php/bin/php-config
make && make install
修改php.ini
vim /var/software/php/etc/php.ini
加入
extension=memcache.so
安装rabbitmq扩展
yum install librabbitmq-devel
cd /var/setup/
wget https://pecl.php.net/get/amqp-1.8.0.tgz
tar zvxf amqp-1.8.0.tgz
cd amqp-1.8.0/
/var/software/php/bin/phpize
./configure --with-php-config=/var/software/php/bin/php-config
make && make install
修改php.ini
vim /var/software/php/etc/php.ini
加入
extension=amqp.so
安装phalcon扩展
cd /var/setup/
wget https://github.com/phalcon/cphalcon/archive/phalcon-v2.0.9.tar.gz
tar zxvf phalcon-v2.0.9.tar.gz
cd cphalcon-phalcon-v2.0.9/build/64bits/
/var/software/php/bin/phpize
./configure --with-php-config=/var/software/php/bin/php-config
make && make install
修改php.ini
vim /var/software/php/etc/php.ini
加入
extension=phalcon.so
安装zip扩展
cd /var/setup/php-5.6.30/ext/zip/
/var/software/php/bin/phpize
./configure --with-php-config=/var/software/php/bin/php-config
make && make install
修改php.ini
vim /var/software/php/etc/php.ini
加入
extension=zip.so
安装xdebug
cd /var/setup/
wget https://pecl.php.net/get/xdebug-2.5.1.tgz
tar zxvf xdebug-2.5.1.tgz
cd xdebug-2.5.1/
/var/software/php/bin/phpize
./configure --with-php-config=/var/software/php/bin/php-config
make && make install
修改php.ini
vim /var/software/php/etc/php.ini
相关配置内容
zend_extension=/var/software/php/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
; Remote settings
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
; 注意!!!!这里的IP,是宿主机的IP(也就是苹果系统跟virtualbox的建立host-only的连接的IP)
xdebug.remote_host="192.168.56.1"
xdebug.remote_port=9001
; General
xdebug.collect_includes=on
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.default_enable=on
xdebug.extended_info=1
xdebug.manual_url=http://www.php.net
xdebug.show_local_vars=0
xdebug.show_mem_delta=0
xdebug.max_nesting_level=100
;xdebug.idekey=
; Trace options
xdebug.auto_trace=0
xdebug.trace_format=0
xdebug.trace_output_dir=/data/www/logs/php/xdebug
xdebug.trace_options=0
xdebug.trace_output_name="xdebug_trace_%t"
; Profiling
xdebug.profiler_enable=0
xdebug.profiler_append=0
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_dir=/data/www/logs/php/xdebug
xdebug.profiler_output_name="xdebug_profiler_%t"
通过netbeans IDE进行命令行调试设置
vim ~/.bash_profile
加入
export XDEBUG_CONFIG="idekey=netbeans-xdebug"
安装memcached扩展
安装libmemcached
cd /var/setup
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18/
./configure
make && make install
安装扩展,pecl上的3.0版本会出现编译不过的情况,只能使用2.2版本
cd /var/setup
wget https://pecl.php.net/get/memcached-2.2.0.tgz
tar zxvf memcached-2.2.0.tgz
cd memcached-2.2.0/
/var/software/php/bin/phpize
./configure --with-php-config=/var/software/php/bin/php-config
make && make install
修改php.ini
vim /var/software/php/etc/php.ini
加入
extension=memcached.so
安装mcrypt
yum install libmcrypt-devel
cd /var/setup/php-5.6.30/ext/mcrypt
/var/software/php/bin/phpize
./configure -with-php-config=/var/software/php/bin/php-config
make && make install
修改php.ini
vim /var/software/php/etc/php.ini
加入
extension=mcrypt.so
安装swoole
安装hiredis
cd /var/setup/
wget https://github.com/redis/hiredis/archive/v0.13.3.tar.gz
tar zxvf v0.13.3.tar.gz
cd hiredis-0.13.3/
make -j
make install
ldconfig
cd /var/setup
git clone https://github.com/swoole/swoole-src.git
cd swoole-src
checkout某个特定的tag作为分支编译
git checkout tags/v2.0.6 -b v2.0.6
/var/software/php/bin/phpize
./configure -with-php-config=/var/software/php/bin/php-config --enable-coroutin
make && make install
修改php.ini
vim /var/software/php/etc/php.ini
加入
extension=swoole.so
安装pcntl扩展
cd /var/setup/php-5.6.30/ext/pcntl
/var/software/php/bin/phpize
./configure -with-php-config=/var/software/php/bin/php-config
make && make install
修改php.ini
vim /var/software/php/etc/php.ini
加入
extension=pcntl.so
安装socket扩展
cd /var/setup/php-5.6.30/ext/sockets/
/var/software/php/bin/phpize
./configure -with-php-config=/var/software/php/bin/php-config
make && make install
修改php.ini
vim /var/software/php/etc/php.ini
加入
extension=sockets.so
安装redis扩展
cd /var/setup
wget https://pecl.php.net/get/redis-3.1.1.tgz
tar zxvf redis-3.1.1.tgz
cd redis-3.1.1/
make clean
/var/software/php/bin/phpize
./configure --with-php-config=/var/software/php/bin/php-config
make && make install
修改php.ini
vim /var/software/php/etc/php.ini
加入
extension=redis.so
安装inotify扩展
cd /var/setup
wget https://pecl.php.net/get/inotify-0.1.6.tgz
tar zxvf inotify-0.1.6.tgz
cd inotify-0.1.6/
make clean
/var/software/php/bin/phpize
./configure --with-php-config=/var/software/php/bin/php-config
make && make install
修改php.ini
vim /var/software/php/etc/php.ini
加入
extension=inotify.so
安装composer
cd /var/software/
mkdir /var/software/composer56
cd /var/software/composer56
curl -s http://getcomposer.org/installer | /var/software/php/bin/php
常用命令
/var/software/php/bin/php composer.phar install
安装PHP7.1
安装
cd /var/setup
wget http://cn2.php.net/distributions/php-7.1.2.tar.gz
tar zxvf php-7.1.2.tar.gz
cd php-7.1.2
./configure --prefix=/var/software/php71/ --with-config-file-path=/var/software/php71/etc/ --with-mysqli=/var/software/mysql/bin/mysql_config --with-zlib --with-curl --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mbstring=all --with-openssl --with-gd --with-pdo-mysql=/var/software/mysql
make && make install
修改ini配置
cp php.ini-production /var/software/php71/etc/php.ini
vim /var/software/php71/etc/php.ini
找到error_log,并设置为
error_log=/data/www/logs/php/php71_errors.log
找到date.timezone,并设置为
date.timezone = Asia/shanghai
加入扩展地址
extension_dir = "/var/software/php71/lib/php/extensions/no-debug-non-zts-20160303"
修改fpm配置
cd /var/software/php71
cp etc/php-fpm.conf.default etc/php-fpm.conf
vim etc/php-fpm.conf
找到error_log,并设置为
error_log = /data/www/logs/php/php71-fpm.log
修改fpm的监听端口
vim /var/software/php71/etc/php-fpm.d/www.conf.default
找到listen的端口,并设置为
listen = 127.0.0.1:9071
开机自启动
cp /var/setup/php-7.1.2/sapi/fpm/init.d.php-fpm /etc/init.d/php71-fpm
chmod +x /etc/init.d/php71-fpm
chkconfig php71-fpm on
安装rabbitmq扩展
yum install librabbitmq-devel
cd /var/setup/
wget https://pecl.php.net/get/amqp-1.8.0.tgz
tar zvxf amqp-1.8.0.tgz
cd amqp-1.8.0/
/var/software/php71/bin/phpize
./configure --with-php-config=/var/software/php71/bin/php-config
make && make install
修改php.ini
vim /var/software/php71/etc/php.ini
加入
extension=amqp.so
安装zip扩展
cd /var/setup/php-7.1.2/ext/zip/
/var/software/php71/bin/phpize
./configure --with-php-config=/var/software/php71/bin/php-config
make && make install
修改php.ini
vim /var/software/php71/etc/php.ini
加入
extension=zip.so
安装xdebug
cd /var/setup/xdebug-2.5.1/
make clean
/var/software/php71/bin/phpize
./configure --with-php-config=/var/software/php71/bin/php-config
make && make install
修改php.ini
vim /var/software/php71/etc/php.ini
相关配置内容
zend_extension=/var/software/php71/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
; Remote settings
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
; 注意!!!!这里的IP,是宿主机的IP(也就是苹果系统跟virtualbox的建立host-only的连接的IP)
xdebug.remote_host="192.168.56.1"
xdebug.remote_port=9002
; General
xdebug.collect_includes=on
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.default_enable=on
xdebug.extended_info=1
xdebug.manual_url=http://www.php.net
xdebug.show_local_vars=0
xdebug.show_mem_delta=0
xdebug.max_nesting_level=100
;xdebug.idekey=
; Trace options
xdebug.auto_trace=0
xdebug.trace_format=0
xdebug.trace_output_dir=/data/www/logs/php/xdebug71
xdebug.trace_options=0
xdebug.trace_output_name="xdebug_trace_%t"
; Profiling
xdebug.profiler_enable=0
xdebug.profiler_append=0
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_dir=/data/www/logs/php/xdebug71
xdebug.profiler_output_name="xdebug71_profiler_%t"
安装memcached扩展
安装扩展
cd /var/setup
wget https://pecl.php.net/get/memcached-3.0.3.tgz
tar zxvf memcached-3.0.3.tgz
cd memcached-3.0.3/
/var/software/php71/bin/phpize
./configure --with-php-config=/var/software/php71/bin/php-config
make && make install
修改php.ini
vim /var/software/php71/etc/php.ini
加入
extension=memcached.so
mcrypt的安装
cd /var/setup/php-7.1.2/ext/mcrypt
/var/software/php71/bin/phpize
./configure -with-php-config=/var/software/php71/bin/php-config
make && make install
修改php.ini
vim /var/software/php71/etc/php.ini
加入
extension=mcrypt.so
安装pcntl扩展
cd /var/setup/php-7.1.2/ext/pcntl
/var/software/php71/bin/phpize
./configure -with-php-config=/var/software/php71/bin/php-config
make && make install
修改php.ini
vim /var/software/php71/etc/php.ini
加入
extension=pcntl.so
安装socket扩展
cd /var/setup/php-7.1.2/ext/sockets/
/var/software/php71/bin/phpize
./configure -with-php-config=/var/software/php71/bin/php-config
make && make install
修改php.ini
vim /var/software/php71/etc/php.ini
加入
extension=sockets.so
安装redis扩展
cd /var/setup
wget https://pecl.php.net/get/redis-3.1.1.tgz
tar zxvf redis-3.1.1.tgz
cd redis-3.1.1/
/var/software/php71/bin/phpize
./configure --with-php-config=/var/software/php71/bin/php-config
make && make install
修改php.ini
vim /var/software/php71/etc/php.ini
加入
extension=redis.so
安装inotify扩展
cd /var/setup
wget https://pecl.php.net/get/inotify-2.0.0.tgz
tar zxvf inotify-2.0.0.tgz
cd inotify-2.0.0/
/var/software/php71/bin/phpize
./configure --with-php-config=/var/software/php71/bin/php-config
make && make install
修改php.ini
vim /var/software/php71/etc/php.ini
加入
extension=inotify.so
安装swoole
安装hiredis
cd /var/setup/
wget https://github.com/redis/hiredis/archive/v0.13.3.tar.gz
tar zxvf v0.13.3.tar.gz
cd hiredis-0.13.3/
make -j
make install
ldconfig
cd /var/setup
git clone https://github.com/swoole/swoole-src.git
cd swoole-src
checkout某个特定的tag作为分支编译
git checkout tags/v1.9.6 -b v1.9.6
/var/software/php71/bin/phpize
./configure -with-php-config=/var/software/php71/bin/php-config --enable-async-redis --enable-jemalloc
make && make install
修改php.ini
vim /var/software/php71/etc/php.ini
加入
extension=swoole.so
安装composer(可选)
cd /var/software/
mkdir /var/software/composer71
cd /var/software/composer71
curl -s http://getcomposer.org/installer | /var/software/php71/bin/php
常用命令
/var/software/php71/bin/php composer.phar install
安装redis服务端(可选)
cd /var/setup/
wget http://download.redis.io/releases/redis-3.2.8.tar.gz
tar zxvf redis-3.2.8.tar.gz
mv redis-3.2.8 /var/software/
cd /var/software/redis-3.2.8/
make
开机启动
cp /var/software/redis-3.2.8/utils/redis_init_script /etc/init.d/redisd
vim /etc/init.d/redisd
在#!/bin/sh下面,加入
# chkconfig: 23459010
将
EXEC=/usr/local/bin/redis-server
修改为
EXEC=/var/software/redis-3.2.8/src/redis-server
将
CLIEXEC=/usr/local/bin/redis-cli
修改为
CLIEXEC=/var/software/redis-3.2.8/src/redis-cli
将
CONF="/etc/redis/${REDISPORT}.conf"
修改为
CONF="/var/software/redis-3.2.8/redis.conf"
设置为开机自启动服务器
chkconfig redisd on
常用命令
service redisd start|stop
virtualbox端口映射
80与443端口转发
参考文章Mac下Virtualbox端口转发到虚机的问题。由于1024以下的端口比较特殊,所以这里特意讲解一下
设置virtualbox的端口映射
Mac的系统设置
sudo -i
echo "rdr pass on lo0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080" > /etc/pf.anchors/vbox
echo "rdr pass on lo0 inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443" > /etc/pf.anchors/vbox443
vi /etc/pf.conf
加入如下两行代码
rdr-anchor "vbox"
rdr-anchor "vbox443"
load anchor "vbox" from "/etc/pf.anchors/vbox"
load anchor "vbox443" from "/etc/pf.anchors/vbox443"
最终的代码,一定要按照下面的顺序,要不然要报错的
#
# com.apple anchor point
#
scrub-anchor "com.apple/*"
nat-anchor "com.apple/*"
rdr-anchor "com.apple/*"
rdr-anchor "vbox"
rdr-anchor "vbox443"
dummynet-anchor "com.apple/*"
anchor "com.apple/*"
load anchor "com.apple" from "/etc/pf.anchors/com.apple"
load anchor "vbox" from "/etc/pf.anchors/vbox"
load anchor "vbox443" from "/etc/pf.anchors/vbox443"
激活配置
pfctl -ef /etc/pf.conf
设置开机启动
方法一
vi /System/Library/LaunchDaemons/com.apple.pfctl.plist
添加第二行 (-e这一行)
<string>pfctl</string>
<string>-e</string>
<string>-f</string>
<string>/etc/pf.conf</string>
参考如何编辑以上文件:Editing the /System/Library/LaunchDaemons/com.apple.pfctl.plist file
方法二(未验证是否可行)
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.pfctl.plist
短命令
vim ~/.bash_profile
添加以下内容
alias nginx.start='systemctl start nginx.service'
alias nginx.stop='systemctl stop nginx.service'
alias nginx.restart='systemctl restart nginx.service'
alias nginx.reload='systemctl reload nginx.service'
alias php-fpm.force-quit='/etc/init.d/php56-fpm force-quit'
alias php-fpm.start='/etc/init.d/php56-fpm start'
alias php-fpm.stop='/etc/init.d/php56-fpm stop'
alias php-fpm.reload='/etc/init.d/php56-fpm reload'
alias php-fpm.restart='/etc/init.d/php56-fpm restart'
alias php-fpm.status='/etc/init.d/php56-fpm status'
alias php71-fpm.force-quit='/etc/init.d/php71-fpm force-quit'
alias php71-fpm.start='/etc/init.d/php71-fpm start'
alias php71-fpm.stop='/etc/init.d/php71-fpm stop'
alias php71-fpm.reload='/etc/init.d/php71-fpm reload'
alias php71-fpm.restart='/etc/init.d/php71-fpm restart'
alias php71-fpm.status='/etc/init.d/php71-fpm status'
alias mysql.start='/etc/init.d/mysql.server start'
alias mysql.stop='/etc/init.d/mysql.server stop'
alias mysql.restart='/etc/init.d/mysql.server restart'
alias mysql.reload='/etc/init.d/mysql.server reload'
alias mysql.status='/etc/init.d/mysql.server status'
alias redis.start='service redisd start'
alias redis.stop='service redisd stop'
alias redis.restart='redis.stop && redis.start'
alias memcached.start='/etc/rc.d/init.d/memcached start'
alias memcached.stop='/etc/rc.d/init.d/memcached stop'
alias memcached.restart='/etc/rc.d/init.d/memcached restart'
这样就不用打那么多字啦