创业阶段,进一步实践了Linux环境搭建和维护,下面是一些常用软件的搭建步骤和参考资料,仅供自己和诸位参考。
我个人还是比较倾向“一站式Web开发”的,自己想做点事,需要太多的技能。
非商业软件项目,自己全盘负责比较灵活和高效。
1.mysql(关键是创建mysql用户,并用mysql用户执行安装程序)
参考资料
rpm -qa | grep mysql // 这个命令就会查看该操作系统上是否已经安装了mysql数据库
Mysql下载地址
http://dev.mysql.com/downloads/file.php?id=451491
http://blog.sina.com.cn/s/blog_694ac4520100zbbd.html
----------------------
./mysqld_safe --user=mysql &
不能直接使用mysqld,以root用户的身份执行(--user=mysql,可以解决这个问题)
2014-04-24 09:19:50 8011 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
./bin/mysqld --user=mysql &
不要使用root用户,使用mysql用户
mysql启动
http://swordshadow.iteye.com/blog/1921814
//这种方式,有时候,不起作用,直接按Enter,mysql就被杀死了
./mysqld --user=mysql &
可以使用nohup命令启动
nohup /usr/bin/mysql --user=mysql &
------------------------
启动报错
2014-04-24 09:25:09 8276 [Note] InnoDB: 128 rollback segment(s) are active.
InnoDB: Error: pthread_create returned 11
临时解决方法:
# ulimit -s unlimited
./mysqld_safe: line 166: 8796 Killed
nohup /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/AY1404221737304200fcZ.err --pid-file=/usr/local/mysql/data/AY1404221737304200fcZ.pid < /dev/null >> /usr/local/mysql/data/AY1404221737304200fcZ.err 2>&1
140424 09:35:47 mysqld_safe Number of processes running now: 0
mysqld --basedir=/usr/local/mysql --datadir=/var/lib/mysql --user=mysql &
该方法在系统重启,或者重新登录后将失效。
另外一种方法:
修改/etc/profile文件,添加
ulimit -s unlimited
---------------卸载自带的mysql---------------
rpm -qa |grep mysql
卸载centos自带的mysql,rpm -e --nodeps mysql-libs-5.1.61-4.el6.x86_64
------------------------------------
2014-04-24 11:17:25 14210 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
--------------------------------------------------------------------------
Can't find messagefile '/usr/share/mysql/errmsg.sys'
将源码包里面的sql/share/english/errmsg.sys复制到/usr/share/mysql/errmsg.sys
----------------------------------------------------------------------------
[mysqld]
datadir=/home/mysql/mysql/data
basedir=/home/mysql/mysql
socket=/home/mysql/mysql/run/mysql.sock
log-error=/home/mysql/mysql/log/error.log
user=mysql
innodb_buffer_pool_size=100M
key_buffer_size=50M
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/home/mysql/log/mysqld.log
pid-file=/home/mysql/mysqld.pid
[client]
socket=/home/mysql/mysql/run/mysql.sock
grant all privileges on *.* to root@"%" identified by "lw198962" with grant option; flush privileges;
./constraints_parser -5 -D -f pages-1400495572/FIL_PAGE_INDEX/0-161 >/tmp/t_bibasic_salessend.sql
#生成数据文件
./constraints_parser -5 -f pages-1400495572/FIL_PAGE_INDEX/4294967295-0 >/tmp/xiaolei_.sql
#生成load-data语句
./constraints_parser -5 -D -f pages-1400495572/FIL_PAGE_INDEX/4294967295-0
2.Redis配置
http://hi.baidu.com/cxc0378/item/40f4b70e7fda603af3eafcbb
3.Mongodb
/usr/local/mongodb/start-mongo
4.node
下载二进制安装包,解压即可
export NODE_HOME=/usr/local/node/
export PATH=$NODE_HOME/bin:$PATH
Linux下执行,
./node
//使用绝对路径
forever start /var/www/trunk/bootstrap.js &
forever stop /var/www/trunk/bootstrap.js &
forever start -l /var/www/snsforever.log -o /var/www/snsout.log -e /var/www/snserr.log /var/www/sns/bootstrap.js
forever stop /var/www/sns/bootstrap.js
-------------------------------------------------------------------------
关键:使用mysql用户
[mysql@itfriend mysql]$ scripts/mysql_install_db --user=mysql --basedir=/home/mysql/mysql --datadir=/home/mysql/mysql/data
服务器内存太小,没有交换区,手动修改
http://www.prowebdev.us/2012/05/amazon-ec2-linux-micro-swap-space.html
Run dd if=/dev/zero of=/swapfile bs=1M count=1024
Run mkswap /swapfile
Run swapon /swapfile
Add this line /swapfile swap swap defaults 0 0 to /etc/fstab
5.Nginx
下载地址 http://nginx.org/download/,都是源码包,没有二进制安装包
安装过程
wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
yum install nginx-release...
yum install nginx
[root@itfriend bin]# find / -name nginx
/var/cache/yum/x86_64/6/nginx
/var/cache/nginx
/var/log/nginx
/var/lib/yum/repos/x86_64/6/nginx
/usr/share/nginx
/usr/sbin/nginx
/etc/sysconfig/nginx
/etc/logrotate.d/nginx
/etc/rc.d/init.d/nginx
/etc/nginx
启动 nginx
重新加载
nginx -s reload
停止1
nginx -s quit
停止2
ps -ef|grep enigx,找到master的进程号
kill -QUIT 24346
静态资源被Ngnix拦截,直接响应浏览器
http://114.215.191.169/images/fans123/photos/44813db99c67489523bd7edfb14e1bed7b7553a8.gif
参考资料:
http://nginx.org/en/linux_packages.html
http://www.nginx.cn/
6.Linux命令
修改密码: passwd root,输入2次密码
/usr/local/mysql/bin/mysqld_safe --user=mysql
cat /var/log/mysqld.log
mysqladmin -u root password "11"
/usr/local/mysql/bin/mysqladmin -u root password 11
source/etc/profile是让/etc/profile文件修改后立即生效
:tar zxvf
7.crontab
crontab -e
编辑自己这个用户的定时文件
*/1 * * * * /var/www/autobackup-mysql.sh
每分钟执行一次
8.安装JDK
查看可安装的java包yum list java*
yum install java-1.7.0-openjdk* -y
参考资料:
9.安装Tomcat
复制安装包,修改权限 chmod a+x *