2018-12-10 14:01:36 1548瀏覽
今天扣丁學(xué)堂Linux培訓(xùn)老師給大家介紹一下關(guān)于CentOS7.6系統(tǒng)下使用yum配置lnmp環(huán)境的方法,希望對同學(xué)們學(xué)習(xí)Linux有所幫助,下面我們一起來看一下吧,Server: MariaDB Server version: 5.5.60-MariaDB MariaDB Server [root@ln-125 ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@ln-125 ~]# nginx -v nginx version: nginx/1.14.2 [root@ln-125 ~]# php-fpm -v PHP 5.4.16 (fpm-fcgi) (built: Oct 30 2018 19:32:20) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
[root@ln-125 ~]# cat >> /etc/yum.repos.d/nginx.repo <<EOF [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ #releasever 是linux 的版本號centos 7 gpgcheck=0 enabled=1 EOF
yum clean all ; yum makecache ; yum list nginx ; #這時就可以看到nginx安裝包了 ; yum install nginx ; systemctl enable nginx ; systemctl start nginx
[root@ln-125 ~]# nginx -V nginx version: nginx/1.14.2 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
yum list php php-fmp
yum install -y php php-fpm php-pear php-devel #httpd
vim /etc/nginx/conf.d/default.conf ... location / { root /usr/share/nginx/html; #設(shè)置根目錄的絕對路徑 index index.html index.htm index.php; #匹配php文件 } location ~ \.php$ { #原來是注釋掉的需要開啟或復(fù)制 root /usr/share/nginx/html; #設(shè)置絕對路徑 fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #設(shè)置根目錄匹配 include fastcgi_params; } ...
touch /dev/shm/php-fpm-default.sock [root@ln-125 ~]# cat /etc/php-fpm.d/www.conf |grep -Ev '^;|^$' [www] listen = /dev/shm/php-fpm-default.sock listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = nobody listen.group = nobody listen.mode = 0666 user = nginx group = nginx 。。。 systemctl restart php-fpm.service systemctl enable php-fpm
vim /etc/php.ini cgi.fix_pathinfo=1 #將注釋去掉,開啟PHP的pathinfo偽靜態(tài)功能。 max_execution_time = 0 #腳本運行的最長時間,默認30秒 max_input_time = 300#腳本可以消耗的時間,默認60秒 memory_limit = 256M#腳本運行最大消耗的內(nèi)存,根據(jù)你的需求更改數(shù)值,默認128M post_max_size = 100M #單提交的最大數(shù)據(jù),此項不是限制上傳單個文件的大小,而是針對整個表單的提交數(shù)據(jù)進行限制的。限制范圍包括表單提交的所有內(nèi)容.例如:發(fā)表貼子時,貼子標(biāo)題,內(nèi)容,附件等…默認8M upload_max_filesize = 10M#上載文件的最大許可大小 ,默認2M
vim /etc/php-fpm.d/www.conf 找到以下兩行,解除注釋 listen.owner = nobody listen.group = nobody 找下以下兩行,將各自的apache改為nginx user = apache -> user = nginx group = apache -> group = nginx
yum install -y mariadb mariadb-server #開機自啟 [root@ln-125 ~]# systemctl start mariadb.service [root@ln-125 ~]# systemctl enable mariadb.service #初始化數(shù)據(jù)庫配置 mysql_secure_installation #配置默認設(shè)置(root密碼登錄方式等) #設(shè)置默認字符集 編輯 vim /etc/my.cnf [root@ln-125 ~]# grep -Ev '^#|^$' /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock symbolic-links=0 character-set-server = utf8 ##設(shè)置默認編碼 [mysqld_safe] log-error=/var/log/mariadb/mariadb.log pid-file=/var/run/mariadb/mariadb.pid !includedir /etc/my.cnf.d systemctl restart mariadb.service
cat >> /usr/share/nginx/html/index.php << EOF <?php echo phpinfo(); ?>
【關(guān)注微信公眾號獲取更多學(xué)習(xí)資料】
查看更多關(guān)于“Linux培訓(xùn)資訊”的相關(guān)文章>>