新买了阿里云的香港VPS,速度不错哦!不用备案,一月120元,先试用下。
配置是1核1G,1M宽带, 40G高效云盘,操作系统选择了最新的Centos7.0 64位。
装完后,yum update一下,377个软件需要更新,然后空间分布是这样的。
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 2.0G 36G 6% /
devtmpfs 489M 0 489M 0% /dev
tmpfs 497M 0 497M 0% /dev/shm
tmpfs 497M 13M 485M 3% /run
tmpfs 497M 0 497M 0% /sys/fs/cgroup
tmpfs 100M 0 100M 0% /run/user/0
tmpfs 100M 0 100M 0% /run/user/1000
--------------------------------------------------
创建运行web的www用户
--------------------------------------------------
mkdir /www
groupadd www
useradd -g www www
passwd www
创建安装web服务器的目录
mkdir /usr/local/hx
创建存放web软件的目录
mkdir /root/soft
cd /root/soft
--------------------------------------------------
更新软件和安装常用软件
--------------------------------------------------
启用epel仓库:yum install -y epel-release
使用centos7之前的ifconfig,ss等命令 yum install net-tools
再装些常用的软件:
yum -y install gcc gcc-c++ autoconf zlib zlib-devel libxml2 libxml2-devel ncurses ncurses-devel libtool-ltdl libtool-ltdl-devel bison
yum -y install wget zlib zlib-devel mhash libmcrypt php-mcrypt
--------------------------------------------------
装Nginx
--------------------------------------------------
wget http://nginx.org/download/nginx-1.9.12.tar.gz
tar zxf nginx-1.9.12.tar.gz
cd nginx-1.9.12
./configure --user=www --group=www --prefix=/usr/local/hx/nginx --with-http_stub_status_module --with-http_v2_module
make && make install
--------------------------------------------------
装php7
--------------------------------------------------
wget http://cn2.php.net/distributions/php-7.0.4.tar.gz
tar zxf php-7.0.4.tar.gz
cd php-7.0.4
./configure --prefix=/usr/local/hx/php7 --with-config-file-path=/usr/local/hx/php7/etc --enable-fpm --with-zlib --with-curl --with-mhash --with-mcrypt --enable-mbstring --with-gd --enable-gd-native-ttf --enable-soap --with-jpeg-dir --with-freetype-dir --with-png-dir --enable-sockets --without-pear -with-mysqli --enable-zip --enable-bcmath
make && make install
cd /usr/local/hx/php7/etc/
cp php-fpm.conf.default php-fpm.conf
cp php-fpm.d/www.conf.default php-fpm.d/www.conf
--------------------------------------------------
创建php-fpm启动脚本
--------------------------------------------------
cp -f php安装目录路径/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
#启动php-fpm
/etc/init.d/php-fpm start
#添加到开机服务列表
chkconfig --add php-fpm
#默认打开
chkconfig php-fpm on
--------------------------------------------------
装mysql
--------------------------------------------------
之前都是编译的,这次偷懒直接用yum吧
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server
装完了:)
mysql -uroot
就可以进去了,把一些空密码的账号删除,留一个就行了。
delete from mysql.user WHERE host <> 'localhost';
delete from mysql.user WHERE user = '';
启动:service mysqld start
重启:service mysqld restart
--------------------------------------------------
一些安全设置
--------------------------------------------------
vi /etc/ssh/sshd_config
修改ssh端口
port 2222(不用默认的22)
禁止root直接登陆
permitrootlogin no
重启ssh
service sshd restart
--------------------------------------------------
设置iptables
--------------------------------------------------
自带的firewalld用不惯,还是恢复使用iptables
yum install iptables-services
systemctl mask firewalld.service
systemctl enable iptables.service
service iptables start
iptables -I INPUT 4 -p TCP --dport 2222 -j ACCEPT
iptables -I INPUT 4 -p TCP --dport 80 -j ACCEPT
保存iptable:
service iptables save
service iptables restart
--------------------------------------------------
一些错误记录和解决
--------------------------------------------------
php7 configure时:
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=
yum install openssl-devel
configure: error: xml2-config not found. Please check your libxml2 installation.
yum install libxml2-devel
基本上,如果发现提示少什么的时候,找对应的-devel包安装即可。
configure: error: xml2-config not found. Please check your libxml2 installation.
yum install libxml2-devel
If configure fails try --with-webp-dir=
If configure fails try --with-webp-dir=
If configure fails try --with-webp-dir=