yum源更改
- 備份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup - 更換阿里云
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
openrestry(nginx) 安裝
-
安裝開發庫
yum install readline-devel pcre-devel openssl-devel gcc
下載openrestry源碼
wget https://openresty.org/download/openresty-1.11.2.2.tar.gz
解壓
tar -xzvf openresty-VERSION.tar.gz
-
./configure
然后在進入 openresty-VERSION/ 目錄, 然后輸入以下命令配置:./configure
默認, --prefix=/usr/local/openresty 程序會被安裝到/usr/local/openresty目錄。您可以指定各種選項,比如
./configure --prefix=/opt/openresty
--with-luajit
--without-http_redis2_module
--with-http_iconv_module
--with-http_postgres_module
試著使用 ./configure --help 查看更多的選項。配置文件(./configure script)運行出錯可以到 build/nginx-VERSION/objs/autoconf.err 找到。 VERSION 的地方必須與OpenResty版本號相對應, 比如 0.8.54.6。
-
make
您可以使用下面的命令來編譯:make
如果您的電腦支持多核 make 工作的特性, 您可以這樣編譯:make -j2
假設您是的機器是雙核。 -
make install
如果前面的步驟都沒有問題的話,您可以使用下面的命令安裝l OpenResty到您的系統之中:make install
在 Linux,通常包括 sudo來執行root權限做的事情。 -
啟動
PATH=/usr/local/openresty/nginx/sbin:$PATH export PATH nginx -p `pwd`/ -c conf/nginx.conf
開機自動啟動可參考http://www.lxweimin.com/p/50d37e23470f
外網無法訪問
首先在centos下嘗試使用$curl http://127.0.0.1命令訪問nginx。
如果能夠成功獲取到nginx的默認主頁。
那么,問題基本出在防火墻上,centos 7的防火墻使用firewalld。
所以,你需要讓firewalld放行80端口。
firewalld默認已經安裝并啟用了,如果需要nginx可以訪問需要執行以下命令:
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --zone=trusted --add-port=80/tcp
安裝PHP7
-
rpm 安裝 Php7 相應的 yum源:
rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm yum install php php-fpm php-cli php-pdo php-mysql php-gd php-bcmath php-xml php-mbstring php-mcrypt php-redis
推薦這個源,大量的擴展可以直接安裝使用
-
webtatic源安裝
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm yum install php70w php70w-fpm
安裝redis
安裝
yum install redis
安裝mysql5.7
添加mysql源
rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
安裝mysql5.7客戶端 服務端
yum install mysql mysql-server
-
初始化數據庫
mysql_install_db –usrer=mysql datadir=/var/lib/mysql
5.7使用如下命令初始化
mysqld --initialize
如果報錯:
[ERROR] --initialize specified but the data directory has files in it. Aborting.
刪除data目錄然后執行:
chown mysql:mysql -R /var/lib/mysql
啟動:
systemctl start mysqld.service
修改密碼:
mysqladmin -u UserName -h Host password 'new_password' -p
設置權限
安裝composer
下載
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
安裝
php composer-setup.php --install-dir=/usr/bin --filename=composer
刪除安裝包
php -r "unlink('composer-setup.php');"
測試
執行composer -v 看看,如果有顯示它的相關選項那就表示安裝成功了!設置國空鏡像
有兩種方式啟用本鏡像服務:
- 系統全局配置: 即將配置信息添加到 Composer 的全局配置文件 config.json 中
- 單個項目配置: 將配置信息添加到某個項目的 composer.json 文件中
修改 composer 的全局配置文件
控制臺(Linux、Mac 用戶)并執行如下命令設置全局配置文件:
composer config -g repo.packagist composer https://packagist.phpcomposer.com
一些centos7 systemctl命令簡單實用實例:
systemctl start httpd.service /啟動Apache httpd
systemctl restart httpd.service /重新啟動
systemctl stop httpd.service /停止服務
systemctl enable httpd.service /開機啟動httpd
systemctl disable httpd.service /禁止開機啟動httpd
systemctl status httpd.service /httpd當前狀態