centos中OpenSUSE安裝LEMP/LNMP套件

來源:互聯網
上載者:User

OpenSUSE安裝LEMP/LNMP套件

1.裝nginx、php5和MariaDB

zypper install nginx php5 php5-fpm php5-mysql mariadb-tool mariadb mariadb-client
2.調整nginx設定檔

在/etc/nginx/nginx.conf中的server塊裡加入如下內容

注意:預設安裝nginx裡面被注釋掉的有類似的內容,但是與下面配置$document_root不同,採用預設配置的話,會造成無法定位檔案的錯誤

location ~\.php$
{
      root /usr/share/nginx/html;
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME  $document_root/$fastcgi_script_name;
      include fastcgi_params;
}
3.啟動Nginx

systemctl start nginx
4.複製php-fpm設定檔

cp /etc/php5/fpm/php-fpm.conf.default /etc/php5/fpm/php-fpm.conf
5.啟動php-fpm

systemctl start php-fpm
6.在預設目錄(/srv/www/htdocs)下建立測試檔案info.php檔案,內容如下

 <?php phpinfo(); ?>
如果訪問http://公網ip/info.php,能夠看到php資訊頁面的話,即成功。

7.啟動MariaDB

systemctl start mysql
8.設定自啟動

systemctl enable mysql nginx php-fpm
預設的設定檔位置

Nginx設定檔:
主設定檔:/etc/nginx/nginx.conf
Nginx Server設定檔:/etc/nginx/conf.d/default.conf

PHP設定檔:
/etc/php5/cli/php.ini

php-fpm設定檔:
/etc/php5/fpm/php-fpm.conf
9. 拓展:為php安裝memcached拓展

安裝memcached拓展的方法很多,可以使用pcel進行安裝(傳送),本文將採用的是傳統的編譯安裝模式

a.安裝必要的庫及編譯軟體

zypper in libmemcached libmemcached-devel php5-devel gcc
b.下載並解壓php-memcached(推薦下載地址:http://pecl.php.net/package/memcached)

wget http://pecl.php.net/get/memcached-2.2.0.tgz
tar zxvf memcached-2.2.0.tgz
cd memcached-2.2.0
c.phpize命令產生configure

phpize
d.編譯並安裝memcached拓展庫

./configure --enable-memcached
make && make install
成功後會在/usr/lib64/php5/extensions下組建檔案memcached.so

e.將本目錄下的memcached.ini,加入如下內容

extension=memcached.so
複製memcached到php設定檔夾

cp memcached.ini /etc/php5/conf.d
f.檢驗memcached安裝是否成功

php -m
若成功,則會在返回內容中看到memcached

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.